()
| 69 | } |
| 70 | |
| 71 | async run() { |
| 72 | const cached = this.getCachedToken(); |
| 73 | if (cached?.access_token || cached?.accessToken) { |
| 74 | this.loginResult = cached; |
| 75 | $.log(`账号[${this.index}] 使用缓存token: ${maskToken(this.accessToken)}`); |
| 76 | if (!(await this.checkToken())) { |
| 77 | this.removeCachedToken(); |
| 78 | $.log(`账号[${this.index}] 缓存token失效,重新code登录`); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | if (!this.accessToken) { |
| 83 | await this.loginByWxCode(); |
| 84 | if (!this.accessToken) return; |
| 85 | } |
| 86 | |
| 87 | await this.getPointsInfo("签到前"); |
| 88 | await this.getSignConfig(); |
| 89 | const today = await this.getTodaySignItem(); |
| 90 | if (today?.daySignStatus === 2) { |
| 91 | $.log(`账号[${this.index}] 今日已签到`); |
| 92 | } else { |
| 93 | await this.signIn(today?.dateStr); |
| 94 | } |
| 95 | await this.getPointsInfo("签到后"); |
| 96 | } |
| 97 | |
| 98 | getCachedToken() { |
| 99 | const cache = readTokenCache(); |
no test coverage detected