()
| 79 | } |
| 80 | |
| 81 | async run() { |
| 82 | if (this.isLegacyToken) { |
| 83 | $.log(`账号[${this.index}] 检测到旧版token格式,先迁移到缓存`); |
| 84 | this.saveCachedToken(); |
| 85 | } else { |
| 86 | const cached = this.getCachedToken(); |
| 87 | if (cached?.token) { |
| 88 | this.applyToken(cached); |
| 89 | $.log(`账号[${this.index}] 使用缓存token: ${shortToken(this.token)}`); |
| 90 | if (!(await this.checkToken())) { |
| 91 | this.removeCachedToken(); |
| 92 | $.log(`账号[${this.index}] 缓存token失效,重新CODE登录`); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | if (!this.token) { |
| 97 | await this.loginByWxCode(); |
| 98 | if (!this.token) return; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | await this.sign(); |
| 103 | await this.account(); |
| 104 | } |
| 105 | |
| 106 | cacheKey() { |
| 107 | return this.isLegacyToken ? this.accountId : this.raw; |
no test coverage detected