This commit is contained in:
@@ -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>
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user