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

Commit

Permalink
修复字节大小显示问题,之前是1000进制现在改为1024进制
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Nov 1, 2018
1 parent c36a5c9 commit 99cbab9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
8 changes: 4 additions & 4 deletions front/src/components/Table/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
@on-change="toggleAll"></Checkbox>
</div>
<div class="td">{{ task.response.fileName }}</div>
<div class="td">{{ task.response.totalSize?$numeral(task.response.totalSize).format('0.000 ib'):$t('tasks.unknowLeft') }}</div>
<div class="td">{{ task.response.totalSize?$numeral(task.response.totalSize).format('0.00 ib'):$t('tasks.unknowLeft') }}</div>
<div class="td">{{ calcProgress(task) }}</div>
<div class="td">{{ $numeral(task.info.speed).format('0.000 ib') }}/S</div>
<div class="td">{{ $numeral(task.info.speed).format('0.00 ib') }}/S</div>
<div class="td">{{ calcStatus(task) }}</div>
<div class="td">
<Icon v-if="task.info.status === 1"
Expand Down Expand Up @@ -75,15 +75,15 @@
</p>
<p>
<b>{{ $t('tasks.fileSize') }}:</b>
<span>{{ $numeral(task.response.totalSize).format('0.000 ib') }}</span>
<span>{{ $numeral(task.response.totalSize).format('0.00 ib') }}</span>
</p>
<p>
<b>{{ $t('tasks.connections') }}:</b>
<span>{{ task.config.connections }}</span>
</p>
<p>
<b>{{ $t('tasks.downloadSpeed') }}:</b>
<span>{{ $numeral(task.info.speed).format('0.000 ib') }}/S</span>
<span>{{ $numeral(task.info.speed).format('0.00 ib') }}/S</span>
</p>
<p>
<b>{{ $t('tasks.status') }}:</b>
Expand Down
10 changes: 10 additions & 0 deletions front/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,17 @@ Vue.prototype.$http.interceptors.response.use(
}
)

//去除字节大小格式化后的i字符
const format = numeral.prototype.constructor.fn.format
numeral.prototype.constructor.fn.format = function(fmt) {
let result = format.call(this, fmt)
if (/^.*ib$/.test(fmt)) {
result = result.replace('i', '')
}
return result
}
Vue.prototype.$numeral = numeral

Date.prototype.format = function(fmt) {
var o = {
'M+': this.getMonth() + 1, // Month
Expand Down
2 changes: 1 addition & 1 deletion front/src/views/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<Circle :percent="updateInfo.progress"
:size="150">
<h1>{{ updateInfo.progress.toFixed(2) }}%</h1>
<p>{{ $numeral(updateInfo.speed).format('0.000 ib') }}/S</p>
<p>{{ $numeral(updateInfo.speed).format('0.00 ib') }}/S</p>
</Circle>
</Spin>

Expand Down

0 comments on commit 99cbab9

Please sign in to comment.