mirror of
https://github.com/xiaoshi930/xiaoshi-pad-card.git
synced 2026-01-13 07:04:59 +00:00
Update xiaoshi-device-balance-button.js
This commit is contained in:
@@ -1217,7 +1217,6 @@ class XiaoshiBalanceButton extends LitElement {
|
|||||||
super();
|
super();
|
||||||
this._oilPriceData = [];
|
this._oilPriceData = [];
|
||||||
this._loading = false;
|
this._loading = false;
|
||||||
this._dataLoaded = false; //button新元素
|
|
||||||
this._refreshInterval = null;
|
this._refreshInterval = null;
|
||||||
this.theme = 'on';
|
this.theme = 'on';
|
||||||
}
|
}
|
||||||
@@ -1236,7 +1235,7 @@ class XiaoshiBalanceButton extends LitElement {
|
|||||||
// 每300秒刷新一次数据,减少频繁刷新
|
// 每300秒刷新一次数据,减少频繁刷新
|
||||||
this._refreshInterval = setInterval(() => {
|
this._refreshInterval = setInterval(() => {
|
||||||
this._loadOilPriceData();
|
this._loadOilPriceData();
|
||||||
}, 3000);
|
}, 300000);
|
||||||
}
|
}
|
||||||
|
|
||||||
_evaluateTheme() {
|
_evaluateTheme() {
|
||||||
@@ -1330,11 +1329,9 @@ class XiaoshiBalanceButton extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._oilPriceData = balanceData;
|
this._oilPriceData = balanceData;
|
||||||
this._dataLoaded = true; //button新元素
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('加载设备余额数据失败:', error);
|
console.error('加载设备余额数据失败:', error);
|
||||||
this._oilPriceData = [];
|
this._oilPriceData = [];
|
||||||
this._dataLoaded = true; //button新元素
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._loading = false;
|
this._loading = false;
|
||||||
@@ -1668,15 +1665,7 @@ class XiaoshiBalanceButton extends LitElement {
|
|||||||
let displayUnit = '元';
|
let displayUnit = '元';
|
||||||
let isWarning = false; // 是否处于预警状态
|
let isWarning = false; // 是否处于预警状态
|
||||||
|
|
||||||
if (!this._dataLoaded) {
|
if (displayMode === 'min_value') {
|
||||||
// 数据加载中
|
|
||||||
displayValue = '加载中';
|
|
||||||
displayUnit = '';
|
|
||||||
} else if (this._oilPriceData.length === 0) {
|
|
||||||
// 无数据
|
|
||||||
displayValue = '无数据';
|
|
||||||
displayUnit = '';
|
|
||||||
} else if (displayMode === 'min_value') {
|
|
||||||
// 显示最小值模式
|
// 显示最小值模式
|
||||||
const numericValues = this._oilPriceData
|
const numericValues = this._oilPriceData
|
||||||
.map(item => {
|
.map(item => {
|
||||||
|
|||||||
Reference in New Issue
Block a user