Skip to content

Commit bb29d3e

Browse files
committed
fix code
1 parent 48e16b9 commit bb29d3e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ const Progress = {
3131
},
3232

3333
percent: {
34-
index: 0, total: 0, text: '',
34+
index: null, total: null, text: '',
3535
toString (percent) {
36-
if (this.total) return percent = Math.ceil(this.index * 100) / this.total, Progress.option.index = '(' + this.index + '/' + this.total + ')', [Progress.option.index, (Progress.option.percent = parseInt(percent <= 100 ? percent >= 0 ? percent : 0 : 100, 10) + '%', Progress.option.percent), this.text].filter(t => t !== '').join(' ' + Progress.option.dash + ' ')
36+
if (this.index !== null && this.total !== null) return percent = Math.ceil(this.index * 100) / this.total, Progress.option.index = '(' + this.index + '/' + this.total + ')', [Progress.option.index, (Progress.option.percent = parseInt(percent <= 100 ? percent >= 0 ? percent : 0 : 100, 10) + '%', Progress.option.percent), this.text].filter(t => t !== '').join(' ' + Progress.option.dash + ' ')
3737
return this.text !== '' ? ' ' + Progress.option.dash + ' ' + this.text.toString() : ''
3838
},
3939
appendTo(lines) {
@@ -53,11 +53,11 @@ const Progress = {
5353
else return Progress.option.$.loading._index = 0, Progress.lines = strs.map((line, index) => { const match = /(?<space>^\s*)(?<str>.*)/gm.exec(line); return match !== null ? { ...match.groups, index } : match }).filter(line => line !== null), Progress.timer = setInterval(_ => Progress.finish ? Progress.stop() : Progress.print(Progress.clean + Progress.percent.appendTo(Progress.lines) + Progress.option.dot + ' ' + Progress.option.loading + ' '), 85), Progress
5454
},
5555
total (total) {
56-
return Progress.percent.total = total, Progress.percent.index = 0
56+
return Progress.percent.total = total, Progress.percent.index = 0, Progress
5757
},
5858
stop () {
5959
if (Progress.timer === null) return Progress
60-
else return Progress.print(Progress.clean + Progress.percent.appendTo(Progress.lines) + "\n"), clearInterval(Progress.timer), Progress.lines = [], Progress.percent.index = 0, Progress.percent.total = 0, Progress.percent.text = '', Progress.option.$.loading._index = 0, Progress.finish(), Progress.finish = null, Progress.timer = null, Progress
60+
else return Progress.print(Progress.clean + Progress.percent.appendTo(Progress.lines) + "\n"), clearInterval(Progress.timer), Progress.lines = [], Progress.percent.index = null, Progress.percent.total = null, Progress.percent.text = '', Progress.option.$.loading._index = 0, Progress.finish(), Progress.finish = null, Progress.timer = null, Progress
6161
},
6262
done (message = '完成') {
6363
return Progress.percent.index = Progress.percent.total, Progress.option.done = message, Progress.percent.text = Progress.option.done, Progress.stop(Progress.finish = _ => {}), Progress

0 commit comments

Comments
 (0)