fix: 本月流量
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 1m1s

This commit is contained in:
sexygoat
2026-05-06 18:09:48 +08:00
parent ce7e2152b1
commit 7dfbb2de3d
2 changed files with 16 additions and 32 deletions

View File

@@ -64,6 +64,7 @@
// 流量数据 // 流量数据
const usedMB = ref(0); const usedMB = ref(0);
const realUsedMB = ref(0);
const totalMB = ref(0); const totalMB = ref(0);
const remainMB = ref(0); const remainMB = ref(0);
@@ -103,8 +104,8 @@
// 使用百分比 // 使用百分比
const usedFlowPercent = computed(() => { const usedFlowPercent = computed(() => {
if (totalMB.value && usedMB.value) { if (totalMB.value && realUsedMB.value) {
const percent = (usedMB.value / totalMB.value * 100); const percent = (realUsedMB.value / totalMB.value * 100);
return Math.min(percent, 100).toFixed(2); return Math.min(percent, 100).toFixed(2);
} }
return '0.00'; return '0.00';
@@ -119,17 +120,16 @@
const data = await assetApi.getInfo(identifier); const data = await assetApi.getInfo(identifier);
if (data.current_package_usage_id) { if (data.current_package_usage_id) {
if (data.enable_virtual_data) { const realUsed = data.real_used_mb || 0;
usedMB.value = data.virtual_used_mb || 0; const realTotal = data.real_total_mb || 0;
totalMB.value = data.virtual_total_mb || 0; usedMB.value = data.enable_virtual_data ? (data.virtual_used_mb || 0) : realUsed;
} else { realUsedMB.value = realUsed;
usedMB.value = data.real_used_mb || 0; totalMB.value = realTotal;
totalMB.value = data.real_total_mb || 0; remainMB.value = Math.max(realTotal - realUsed, 0);
}
remainMB.value = Math.max(totalMB.value - usedMB.value, 0);
emit('packageLoaded', data); emit('packageLoaded', data);
} else { } else {
usedMB.value = 0; usedMB.value = 0;
realUsedMB.value = 0;
totalMB.value = 0; totalMB.value = 0;
remainMB.value = 0; remainMB.value = 0;
emit('packageLoaded', null); emit('packageLoaded', null);
@@ -174,4 +174,4 @@
} }
} }
} }
</style> </style>

View File

@@ -119,35 +119,19 @@
// 获取总流量 // 获取总流量
const getTotalFlow = (item) => { const getTotalFlow = (item) => {
if (item.enable_virtual_data) { return formatMB(item.real_total_mb || 0);
return formatMB(item.virtual_total_mb || 0);
} else {
return formatMB(item.real_total_mb || 0);
}
}; };
// 获取剩余流量 // 获取剩余流量
const getRemainFlow = (item) => { const getRemainFlow = (item) => {
if (item.enable_virtual_data) { const remain = (item.real_total_mb || 0) - (item.real_used_mb || 0);
const remain = (item.virtual_total_mb || 0) - (item.virtual_used_mb || 0); return formatMB(remain);
return formatMB(remain);
} else {
const remain = (item.real_total_mb || 0) - (item.real_used_mb || 0);
return formatMB(remain);
}
}; };
// 获取使用百分比 // 获取使用百分比
const getUsagePercent = (item) => { const getUsagePercent = (item) => {
let used, total; const used = item.real_used_mb || 0;
const total = item.real_total_mb || 0;
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;
}
if (!total) return 0; if (!total) return 0;
return Math.min((used / total) * 100, 100).toFixed(2); return Math.min((used / total) * 100, 100).toFixed(2);