feat:流量是否无限制判断修复
This commit is contained in:
@@ -298,26 +298,25 @@ async function mockDataUpdate() {
|
|||||||
const totalTraffic = response.trafficEnable ? (response.traffic || 0) : 0;
|
const totalTraffic = response.trafficEnable ? (response.traffic || 0) : 0;
|
||||||
const usedTraffic = response.trafficEnable ? (response.trafficUsed || 0) : 0;
|
const usedTraffic = response.trafficEnable ? (response.trafficUsed || 0) : 0;
|
||||||
const remainingTraffic = Math.max(0, totalTraffic - usedTraffic);
|
const remainingTraffic = Math.max(0, totalTraffic - usedTraffic);
|
||||||
const progressRatio = totalTraffic ? Math.min(1, Math.max(0, remainingTraffic / totalTraffic)) : 0;
|
|
||||||
|
|
||||||
// 格式化流量显示
|
// 格式化流量显示
|
||||||
const formattedTotal = response.trafficEnable ? formatTraffic(totalTraffic) : { value: 0, unit: '' };
|
const formattedTotal = formatTraffic(totalTraffic);
|
||||||
const formattedUsed = response.trafficEnable ? formatTraffic(usedTraffic) : { value: 0, unit: '' };
|
const formattedUsed = formatTraffic(usedTraffic);
|
||||||
const formattedRemaining = response.trafficEnable ? formatTraffic(remainingTraffic) : { value: 0, unit: '' };
|
const formattedRemaining = formatTraffic(remainingTraffic);
|
||||||
|
|
||||||
// 更新流量数据显示
|
// 更新流量数据显示
|
||||||
baseData.value[1] = {
|
baseData.value[1] = {
|
||||||
...baseData.value[1],
|
...baseData.value[1],
|
||||||
value: remainingTraffic,
|
value: remainingTraffic,
|
||||||
max: totalTraffic,
|
max: totalTraffic,
|
||||||
displayValue: response.trafficEnable ? `${formattedRemaining.value}${formattedRemaining.unit}` : t('page.headerbanner.nolimit'),
|
displayValue: !response.trafficEnable ? t('page.headerbanner.nolimit') : `${formattedRemaining.value}${formattedRemaining.unit}`,
|
||||||
unit: '',
|
unit: '',
|
||||||
description: response.trafficEnable
|
description: !response.trafficEnable
|
||||||
? `${t('page.headerbanner.monthflowr')} (${formattedTotal.value}${formattedTotal.unit})`
|
? `${t('page.headerbanner.monthflowr')} (${t('page.headerbanner.nolimit')})`
|
||||||
: `${t('page.headerbanner.monthflowr')} (${t('page.headerbanner.nolimit')})`,
|
: `${t('page.headerbanner.monthflowr')} (${formattedTotal.value}${formattedTotal.unit})`,
|
||||||
subTitle: response.trafficEnable
|
subTitle: !response.trafficEnable
|
||||||
? t('page.headerbanner.Used') + `: ${formattedUsed.value}${formattedUsed.unit}`
|
? t('page.headerbanner.Used') + `: ${t('page.headerbanner.nolimit')}`
|
||||||
: t('page.headerbanner.Used') + `: 0B`,
|
: t('page.headerbanner.Used') + `: ${formattedUsed.value}${formattedUsed.unit}`,
|
||||||
speedLimits: {
|
speedLimits: {
|
||||||
upLimit: speedLimits.value.upLimit,
|
upLimit: speedLimits.value.upLimit,
|
||||||
downLimit: speedLimits.value.downLimit
|
downLimit: speedLimits.value.downLimit
|
||||||
@@ -340,7 +339,7 @@ async function mockDataUpdate() {
|
|||||||
// 更新图表
|
// 更新图表
|
||||||
updateGauge1(opts => updateGaugeData(opts, baseData.value[0]));
|
updateGauge1(opts => updateGaugeData(opts, baseData.value[0]));
|
||||||
updateGauge2(opts => {
|
updateGauge2(opts => {
|
||||||
const newOpts = updateGaugeData(opts, baseData.value[1], progressRatio);
|
const newOpts = updateGaugeData(opts, baseData.value[1], remainingTraffic / totalTraffic);
|
||||||
return {
|
return {
|
||||||
...newOpts,
|
...newOpts,
|
||||||
animation: true,
|
animation: true,
|
||||||
@@ -350,7 +349,7 @@ async function mockDataUpdate() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Dashboard update failed:', error);
|
console.error('Failed to update data:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user