(method, url, options = {})
| 346 | } |
| 347 | |
| 348 | async request(method, url, options = {}) { |
| 349 | await this.ensureLogin(); |
| 350 | const res = await wpsRequest(method, url, { |
| 351 | ...options, |
| 352 | cookies: this.cookies, |
| 353 | secret: this.secret, |
| 354 | clockConfig: this.clockConfig, |
| 355 | }); |
| 356 | this.cookies = res.cookies; |
| 357 | this.saveCache(); |
| 358 | if (res.data?.msg === "empty wps_sid" || res.data?.result === "userNotLogin") { |
| 359 | if (!this.openid) throw new Error("WPS登录态失效,且缺少 openid 无法刷新"); |
| 360 | $.log(`账号[${this.index}] WPS登录态失效,重新登录`); |
| 361 | this.removeLogin(); |
| 362 | await this.login(); |
| 363 | const retry = await wpsRequest(method, url, { |
| 364 | ...options, |
| 365 | cookies: this.cookies, |
| 366 | secret: this.secret, |
| 367 | clockConfig: this.clockConfig, |
| 368 | }); |
| 369 | this.cookies = retry.cookies; |
| 370 | this.saveCache(); |
| 371 | return retry.data; |
| 372 | } |
| 373 | return res.data; |
| 374 | } |
| 375 | |
| 376 | async loadClockConfig() { |
| 377 | const res = await axios.get(ACTIVITY_CONFIG, { |
no test coverage detected