* 开始旋转
()
| 177 | * 开始旋转 |
| 178 | */ |
| 179 | public start(): void { |
| 180 | if (this.interval) { |
| 181 | this.stop(); |
| 182 | } |
| 183 | |
| 184 | this.interval = setInterval(() => { |
| 185 | const frame = this.frames[this.frameIndex]; |
| 186 | const coloredFrame = this.colorize(frame); |
| 187 | process.stdout.write(`\r${coloredFrame} ${this.text}`); |
| 188 | |
| 189 | this.frameIndex = (this.frameIndex + 1) % this.frames.length; |
| 190 | }, this.options.interval); |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * 停止旋转 |