2
0

feat:流量是否无限制判断修复

This commit is contained in:
zhongzm
2025-01-24 19:28:16 +08:00
parent 900382b0c7
commit 09a31c46b6

View File

@@ -298,26 +298,25 @@ async function mockDataUpdate() {
const totalTraffic = response.trafficEnable ? (response.traffic || 0) : 0;
const usedTraffic = response.trafficEnable ? (response.trafficUsed || 0) : 0;
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 formattedUsed = response.trafficEnable ? formatTraffic(usedTraffic) : { value: 0, unit: '' };
const formattedRemaining = response.trafficEnable ? formatTraffic(remainingTraffic) : { value: 0, unit: '' };
const formattedTotal = formatTraffic(totalTraffic);
const formattedUsed = formatTraffic(usedTraffic);
const formattedRemaining = formatTraffic(remainingTraffic);
// 更新流量数据显示
baseData.value[1] = {
...baseData.value[1],
value: remainingTraffic,
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: '',
description: response.trafficEnable
? `${t('page.headerbanner.monthflowr')} (${formattedTotal.value}${formattedTotal.unit})`
: `${t('page.headerbanner.monthflowr')} (${t('page.headerbanner.nolimit')})`,
subTitle: response.trafficEnable
? t('page.headerbanner.Used') + `: ${formattedUsed.value}${formattedUsed.unit}`
: t('page.headerbanner.Used') + `: 0B`,
description: !response.trafficEnable
? `${t('page.headerbanner.monthflowr')} (${t('page.headerbanner.nolimit')})`
: `${t('page.headerbanner.monthflowr')} (${formattedTotal.value}${formattedTotal.unit})`,
subTitle: !response.trafficEnable
? t('page.headerbanner.Used') + `: ${t('page.headerbanner.nolimit')}`
: t('page.headerbanner.Used') + `: ${formattedUsed.value}${formattedUsed.unit}`,
speedLimits: {
upLimit: speedLimits.value.upLimit,
downLimit: speedLimits.value.downLimit
@@ -340,7 +339,7 @@ async function mockDataUpdate() {
// 更新图表
updateGauge1(opts => updateGaugeData(opts, baseData.value[0]));
updateGauge2(opts => {
const newOpts = updateGaugeData(opts, baseData.value[1], progressRatio);
const newOpts = updateGaugeData(opts, baseData.value[1], remainingTraffic / totalTraffic);
return {
...newOpts,
animation: true,
@@ -350,7 +349,7 @@ async function mockDataUpdate() {
});
}
} catch (error) {
console.warn('Dashboard update failed:', error);
console.error('Failed to update data:', error);
}
}