From ac8f802e7e36797869fecd4cc387647167daa11c Mon Sep 17 00:00:00 2001 From: dompling Date: Thu, 2 Jan 2025 09:47:20 +0800 Subject: [PATCH 1/2] fix --- Scripts/wsgw.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Scripts/wsgw.js b/Scripts/wsgw.js index 08ff1de..9f5e688 100644 --- a/Scripts/wsgw.js +++ b/Scripts/wsgw.js @@ -104,7 +104,7 @@ class Widget extends DmYY { ); console.log(response); this.settings.data = []; - response.forEach((dataInfo) => { + response?.forEach((dataInfo) => { const dataSource = { user: '**', left: { @@ -133,13 +133,13 @@ class Widget extends DmYY { dataSource.left.arrearsOfFees = dataInfo.arrearsOfFees; dataSource.right.previousBill = parseFloat( - this.last(dataInfo.monthElecQuantity.mothEleList).monthEleCost + this.last(dataInfo.monthElecQuantity?.mothEleList || []) + ?.monthEleCost || 0 ); - const oldVal = this.last( - dataInfo.monthElecQuantity.mothEleList, - 2 - ).monthEleCost; + const oldVal = + this.last(dataInfo.monthElecQuantity?.mothEleList || [], 2) + ?.monthEleCost || 1; dataSource.right.previousBillRate = ((dataSource.right.previousBill - oldVal) / oldVal) * 100; @@ -149,7 +149,7 @@ class Widget extends DmYY { ); dataSource.right.thisYear = parseFloat( - dataInfo.monthElecQuantity.dataInfo.totalEleCost + dataInfo.monthElecQuantity?.dataInfo?.totalEleCost || 0 ); const lastYearVal = dataInfo.lastYearElecQuantity.dataInfo.totalEleCost; From c00be22b941a22cfdade52cf7851df69214f7595 Mon Sep 17 00:00:00 2001 From: dompling Date: Thu, 2 Jan 2025 09:53:54 +0800 Subject: [PATCH 2/2] fix --- Scripts/wsgw.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/wsgw.js b/Scripts/wsgw.js index 9f5e688..a8c1007 100644 --- a/Scripts/wsgw.js +++ b/Scripts/wsgw.js @@ -92,6 +92,7 @@ class Widget extends DmYY { `缓存失效时间:${new Date(parseInt(this.settings.cacheDay) + this.cacheTime).toLocaleString()}` ); this.dataSource = { ...this.settings.data[this.userNum] }; + if (!this.dataSource.user) await this.cacheData(); console.log(this.dataSource); } };