feat:修复首页控制台报错
This commit is contained in:
@@ -333,6 +333,10 @@ async function mockDataUpdate() {
|
||||
):'-'
|
||||
}`
|
||||
};
|
||||
// 初始化流量变量,在外层定义
|
||||
let totalTraffic = 0;
|
||||
let usedTraffic = 0;
|
||||
let remainingTraffic = 0;
|
||||
|
||||
// 更新流量数据
|
||||
if (!response.packageName) {
|
||||
@@ -351,9 +355,13 @@ async function mockDataUpdate() {
|
||||
};
|
||||
} else {
|
||||
// 有套餐时的正常显示逻辑
|
||||
const totalTraffic = response.trafficEnable ? (response.traffic || 0) : 0;
|
||||
const usedTraffic = response.trafficEnable ? (response.trafficUsed || 0) : 0;
|
||||
const remainingTraffic = Math.max(0, totalTraffic - usedTraffic);
|
||||
// const totalTraffic = response.trafficEnable ? (response.traffic || 0) : 0;
|
||||
// const usedTraffic = response.trafficEnable ? (response.trafficUsed || 0) : 0;
|
||||
// const remainingTraffic = Math.max(0, totalTraffic - usedTraffic);
|
||||
//内层调用,则不会存在控制台报错
|
||||
totalTraffic = response.trafficEnable ? (response.traffic || 0) : 0;
|
||||
usedTraffic = response.trafficEnable ? (response.trafficUsed || 0) : 0;
|
||||
remainingTraffic = Math.max(0, totalTraffic - usedTraffic);
|
||||
|
||||
// 格式化流量显示
|
||||
const formattedTotal = formatTraffic(totalTraffic);
|
||||
@@ -390,6 +398,7 @@ async function mockDataUpdate() {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// 更新速率限制显示
|
||||
if (!response.packageName) {
|
||||
speedLimits.value = {
|
||||
|
||||
Reference in New Issue
Block a user