|
@@ -169,12 +169,11 @@
|
|
|
<img src="../assets/images/liuliang.png" alt=""><span>剩余流量</span>
|
|
|
</div>
|
|
|
<div class="cardtopnumber">
|
|
|
- 100.00GB
|
|
|
+ <span>{{formatBytes(this.trafficCount)}}</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="progress">
|
|
|
<el-progress :percentage="90" :show-text="false" define-back-color="#000">
|
|
|
-
|
|
|
</el-progress>
|
|
|
</div>
|
|
|
<div class="cardinnerbox2">
|
|
@@ -847,6 +846,7 @@ export default {
|
|
|
remainMessage: '',
|
|
|
// 当天使用流量
|
|
|
todayTraffic: 0,
|
|
|
+ trafficCount: 0,
|
|
|
// 当月使用流量
|
|
|
thisMonthTraffic: 0,
|
|
|
dataType: '0',
|
|
@@ -1005,6 +1005,9 @@ export default {
|
|
|
* @returns {string} 格式化后的字符串,包含数值和单位
|
|
|
*/
|
|
|
formatBytes(bytes, decimals = 2) {
|
|
|
+ const isNegative = bytes < 0; // 判断是否为负数
|
|
|
+ bytes = Math.abs(bytes); // 获取绝对值
|
|
|
+
|
|
|
if (bytes === 0) return '0 Byte';
|
|
|
|
|
|
const k = 1024;
|
|
@@ -1017,8 +1020,12 @@ export default {
|
|
|
const value = bytes / Math.pow(k, i);
|
|
|
|
|
|
// 格式化为指定小数位的字符串
|
|
|
- return parseFloat(value.toFixed(decimals)) + ' ' + sizes[Math.min(i, sizes.length - 1)];
|
|
|
+ const result = parseFloat(value.toFixed(decimals)) + ' ' + sizes[Math.min(i, sizes.length - 1)];
|
|
|
+
|
|
|
+ // 如果是负数,返回带负号的值
|
|
|
+ return isNegative ? `-${result}` : result;
|
|
|
},
|
|
|
+
|
|
|
// 手动刷新
|
|
|
manualRefresh() {
|
|
|
this.refresh();
|
|
@@ -1061,6 +1068,7 @@ export default {
|
|
|
if(res.code === 200) {
|
|
|
this.todayTraffic = res.data.today;
|
|
|
this.thisMonthTraffic = res.data.thisMonth;
|
|
|
+ this.trafficCount = res.data.traffic;
|
|
|
}
|
|
|
})
|
|
|
|