()
| 107 | } |
| 108 | |
| 109 | async run() { |
| 110 | const cached = this.getCachedToken(); |
| 111 | if (cached) { |
| 112 | this.applyToken(cached); |
| 113 | $.log(`账号[${this.index}] 使用缓存token`); |
| 114 | if (!(await this.checkToken())) { |
| 115 | this.removeCachedToken(); |
| 116 | $.log(`账号[${this.index}] 缓存token失效,重新登录`); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | if (!this.token) { |
| 121 | await this.loginByWxCode(); |
| 122 | if (!this.token) return; |
| 123 | } |
| 124 | |
| 125 | await this.getUser(); |
| 126 | await this.signIn(); |
| 127 | await this.doTargetTasks(); |
| 128 | this.saveCachedToken(); |
| 129 | } |
| 130 | |
| 131 | getCachedToken() { |
| 132 | const cache = readTokenCache(); |
no test coverage detected