some changes

- check all configs
- log when response data is null instead of crashing
This commit is contained in:
Zichao Lin 2023-01-12 09:31:35 +08:00
parent eea36a2fa1
commit 47fe03e978
Signed by: earthjasonlin
GPG Key ID: 406D9913DE2E42FB
2 changed files with 14 additions and 11 deletions

@ -87,14 +87,13 @@ exports.checkConfigs = function(configs){
if(configThis[configKeys[key]] == "" || configThis[configKeys[key]] == undefined || configThis[configKeys[key]] == null || configThis[configKeys[key]] == NaN) { if(configThis[configKeys[key]] == "" || configThis[configKeys[key]] == undefined || configThis[configKeys[key]] == null || configThis[configKeys[key]] == NaN) {
log.error(`配置文件 ${file} 异常:`); log.error(`配置文件 ${file} 异常:`);
log.error(` —— ${configKeys[key]}字段缺失`); log.error(` —— ${configKeys[key]}字段缺失`);
isNoProbem = false; // isNoProbem = false;
break;
} }
} }
if(!isNoProbem) { // if(!isNoProbem) {
exit(); // exit();
} // }
} }
} }

@ -59,12 +59,16 @@ for(key in configs) {
logContent += `<span style="color: orange">${key} Wallet返回体 <br> ${JSON.stringify(WalletRespond)}</span><br>`; logContent += `<span style="color: orange">${key} Wallet返回体 <br> ${JSON.stringify(WalletRespond)}</span><br>`;
var NotificationRespond = Notification(makeHeader(configs[key])); var NotificationRespond = Notification(makeHeader(configs[key]));
logContent += `<span style="color: orange">${key} Notification返回体 <br> ${JSON.stringify(NotificationRespond)}</span><br>`; logContent += `<span style="color: orange">${key} Notification返回体 <br> ${JSON.stringify(NotificationRespond)}</span><br>`;
if(WalletRespond.data.free_time.free_time != undefined) { if(WalletRespond.data != null) {
successNum ++; if(WalletRespond.data.free_time.free_time != undefined) {
log.info(`签到完毕! 剩余时长:${WalletRespond.data.free_time.free_time}分钟`) successNum ++;
let NotificationLength = NotificationRespond.data.list.length log.info(`签到完毕! 剩余时长:${WalletRespond.data.free_time.free_time}分钟`)
if(NotificationLength != 0) { let NotificationLength = NotificationRespond.data.list.length
log.info(`已堆积 ${NotificationLength} 个签到通知 请及时处理!`) if(NotificationLength != 0) {
log.info(`已堆积 ${NotificationLength} 个签到通知 请及时处理!`)
}
} else {
log.error("签到失败")
} }
} else { } else {
log.error("签到失败") log.error("签到失败")