Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 99cbab9

Browse files
committed
修复字节大小显示问题,之前是1000进制现在改为1024进制
1 parent c36a5c9 commit 99cbab9

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

front/src/components/Table/index.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
@on-change="toggleAll"></Checkbox>
3333
</div>
3434
<div class="td">{{ task.response.fileName }}</div>
35-
<div class="td">{{ task.response.totalSize?$numeral(task.response.totalSize).format('0.000 ib'):$t('tasks.unknowLeft') }}</div>
35+
<div class="td">{{ task.response.totalSize?$numeral(task.response.totalSize).format('0.00 ib'):$t('tasks.unknowLeft') }}</div>
3636
<div class="td">{{ calcProgress(task) }}</div>
37-
<div class="td">{{ $numeral(task.info.speed).format('0.000 ib') }}/S</div>
37+
<div class="td">{{ $numeral(task.info.speed).format('0.00 ib') }}/S</div>
3838
<div class="td">{{ calcStatus(task) }}</div>
3939
<div class="td">
4040
<Icon v-if="task.info.status === 1"
@@ -75,15 +75,15 @@
7575
</p>
7676
<p>
7777
<b>{{ $t('tasks.fileSize') }}:</b>
78-
<span>{{ $numeral(task.response.totalSize).format('0.000 ib') }}</span>
78+
<span>{{ $numeral(task.response.totalSize).format('0.00 ib') }}</span>
7979
</p>
8080
<p>
8181
<b>{{ $t('tasks.connections') }}:</b>
8282
<span>{{ task.config.connections }}</span>
8383
</p>
8484
<p>
8585
<b>{{ $t('tasks.downloadSpeed') }}:</b>
86-
<span>{{ $numeral(task.info.speed).format('0.000 ib') }}/S</span>
86+
<span>{{ $numeral(task.info.speed).format('0.00 ib') }}/S</span>
8787
</p>
8888
<p>
8989
<b>{{ $t('tasks.status') }}:</b>

front/src/main.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,17 @@ Vue.prototype.$http.interceptors.response.use(
5959
}
6060
)
6161

62+
//去除字节大小格式化后的i字符
63+
const format = numeral.prototype.constructor.fn.format
64+
numeral.prototype.constructor.fn.format = function(fmt) {
65+
let result = format.call(this, fmt)
66+
if (/^.*ib$/.test(fmt)) {
67+
result = result.replace('i', '')
68+
}
69+
return result
70+
}
6271
Vue.prototype.$numeral = numeral
72+
6373
Date.prototype.format = function(fmt) {
6474
var o = {
6575
'M+': this.getMonth() + 1, // Month

front/src/views/About.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
<Circle :percent="updateInfo.progress"
112112
:size="150">
113113
<h1>{{ updateInfo.progress.toFixed(2) }}%</h1>
114-
<p>{{ $numeral(updateInfo.speed).format('0.000 ib') }}/S</p>
114+
<p>{{ $numeral(updateInfo.speed).format('0.00 ib') }}/S</p>
115115
</Circle>
116116
</Spin>
117117

0 commit comments

Comments
 (0)