()
| 101 | } |
| 102 | |
| 103 | async run() { |
| 104 | const cached = this.getCachedToken(); |
| 105 | if (cached) { |
| 106 | this.session = cached; |
| 107 | $.log(`账号[${this.index}] 使用缓存token`); |
| 108 | if (!(await this.checkToken())) { |
| 109 | this.removeCachedToken(); |
| 110 | $.log(`账号[${this.index}] 缓存token失效,重新登录`); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | if (!this.session.token) { |
| 115 | await this.loginByWxCode(); |
| 116 | if (!this.session.token) return; |
| 117 | } |
| 118 | |
| 119 | await this.doSign(); |
| 120 | this.saveCachedToken(); |
| 121 | } |
| 122 | |
| 123 | getCachedToken() { |
| 124 | const cache = readTokenCache(); |
no test coverage detected