* 模拟加载过程
(duration: number, message: string = '处理中')
| 134 | * 模拟加载过程 |
| 135 | */ |
| 136 | public static async simulate(duration: number, message: string = '处理中'): Promise<void> { |
| 137 | const steps = 20; |
| 138 | const stepDuration = duration / steps; |
| 139 | |
| 140 | for (let i = 0; i <= steps; i++) { |
| 141 | const percentage = Math.round((i / steps) * 100); |
| 142 | const progress = this.createProgressBar(percentage); |
| 143 | |
| 144 | process.stdout.write(`\r${message}: ${progress} ${percentage}%`); |
| 145 | |
| 146 | if (i < steps) { |
| 147 | await new Promise(resolve => setTimeout(resolve, stepDuration)); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | process.stdout.write('\n'); |
| 152 | UIDisplay.success('完成!'); |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | /** |
nothing calls this directly
no test coverage detected