* 倒计时
(seconds: number, message: string = '倒计时')
| 112 | * 倒计时 |
| 113 | */ |
| 114 | public static countdown(seconds: number, message: string = '倒计时'): Promise<void> { |
| 115 | return new Promise(resolve => { |
| 116 | let remaining = seconds; |
| 117 | |
| 118 | const timer = setInterval(() => { |
| 119 | process.stdout.write(`\r${message}: ${UIStyles.status.warning(remaining.toString())}s `); |
| 120 | |
| 121 | remaining--; |
| 122 | |
| 123 | if (remaining < 0) { |
| 124 | clearInterval(timer); |
| 125 | process.stdout.write('\r'); |
| 126 | UIDisplay.success('倒计时完成!'); |
| 127 | resolve(); |
| 128 | } |
| 129 | }, 1000); |
| 130 | }); |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * 模拟加载过程 |