From 7dfbb2de3dd2664b73c1bc4c3f6e00aa95b2ea5a Mon Sep 17 00:00:00 2001 From: sexygoat <1538832180@qq.com> Date: Wed, 6 May 2026 18:09:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9C=AC=E6=9C=88=E6=B5=81=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/TrafficCard.vue | 22 ++++++++-------- .../asset-package-history.vue | 26 ++++--------------- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/components/TrafficCard.vue b/components/TrafficCard.vue index 93353fe..1fe3692 100644 --- a/components/TrafficCard.vue +++ b/components/TrafficCard.vue @@ -64,6 +64,7 @@ // 流量数据 const usedMB = ref(0); + const realUsedMB = ref(0); const totalMB = ref(0); const remainMB = ref(0); @@ -103,8 +104,8 @@ // 使用百分比 const usedFlowPercent = computed(() => { - if (totalMB.value && usedMB.value) { - const percent = (usedMB.value / totalMB.value * 100); + if (totalMB.value && realUsedMB.value) { + const percent = (realUsedMB.value / totalMB.value * 100); return Math.min(percent, 100).toFixed(2); } return '0.00'; @@ -119,17 +120,16 @@ const data = await assetApi.getInfo(identifier); if (data.current_package_usage_id) { - if (data.enable_virtual_data) { - usedMB.value = data.virtual_used_mb || 0; - totalMB.value = data.virtual_total_mb || 0; - } else { - usedMB.value = data.real_used_mb || 0; - totalMB.value = data.real_total_mb || 0; - } - remainMB.value = Math.max(totalMB.value - usedMB.value, 0); + const realUsed = data.real_used_mb || 0; + const realTotal = data.real_total_mb || 0; + usedMB.value = data.enable_virtual_data ? (data.virtual_used_mb || 0) : realUsed; + realUsedMB.value = realUsed; + totalMB.value = realTotal; + remainMB.value = Math.max(realTotal - realUsed, 0); emit('packageLoaded', data); } else { usedMB.value = 0; + realUsedMB.value = 0; totalMB.value = 0; remainMB.value = 0; emit('packageLoaded', null); @@ -174,4 +174,4 @@ } } } - \ No newline at end of file + diff --git a/pages/asset-package-history/asset-package-history.vue b/pages/asset-package-history/asset-package-history.vue index 6d8085e..c5b6458 100644 --- a/pages/asset-package-history/asset-package-history.vue +++ b/pages/asset-package-history/asset-package-history.vue @@ -119,35 +119,19 @@ // 获取总流量 const getTotalFlow = (item) => { - if (item.enable_virtual_data) { - return formatMB(item.virtual_total_mb || 0); - } else { - return formatMB(item.real_total_mb || 0); - } + return formatMB(item.real_total_mb || 0); }; // 获取剩余流量 const getRemainFlow = (item) => { - if (item.enable_virtual_data) { - const remain = (item.virtual_total_mb || 0) - (item.virtual_used_mb || 0); - return formatMB(remain); - } else { - const remain = (item.real_total_mb || 0) - (item.real_used_mb || 0); - return formatMB(remain); - } + const remain = (item.real_total_mb || 0) - (item.real_used_mb || 0); + return formatMB(remain); }; // 获取使用百分比 const getUsagePercent = (item) => { - let used, total; - - if (item.enable_virtual_data) { - used = item.virtual_used_mb || 0; - total = item.virtual_total_mb || 0; - } else { - used = item.real_used_mb || 0; - total = item.real_total_mb || 0; - } + const used = item.real_used_mb || 0; + const total = item.real_total_mb || 0; if (!total) return 0; return Math.min((used / total) * 100, 100).toFixed(2);