komiic auto re-login when token expired (#197)

This commit is contained in:
Ftbom
2025-11-19 22:40:19 +08:00
committed by GitHub
parent 89d9573f65
commit 504766de0e
2 changed files with 7 additions and 6 deletions

View File

@@ -9,7 +9,7 @@
"name": "Komiic", "name": "Komiic",
"fileName": "komiic.js", "fileName": "komiic.js",
"key": "Komiic", "key": "Komiic",
"version": "1.0.2" "version": "1.0.3"
}, },
{ {
"name": "包子漫画", "name": "包子漫画",

View File

@@ -6,7 +6,7 @@ class Komiic extends ComicSource {
// 唯一标识符 // 唯一标识符
key = "Komiic" key = "Komiic"
version = "1.0.2" version = "1.0.3"
minAppVersion = "1.0.0" minAppVersion = "1.0.0"
@@ -27,8 +27,6 @@ class Komiic extends ComicSource {
} }
async queryJson(query) { async queryJson(query) {
let operationName = query["operationName"]
let res = await Network.post( let res = await Network.post(
'https://komiic.com/api/query', 'https://komiic.com/api/query',
this.headers, this.headers,
@@ -42,8 +40,11 @@ class Komiic extends ComicSource {
let json = JSON.parse(res.body) let json = JSON.parse(res.body)
if (json.errors != undefined) { if (json.errors != undefined) {
if(json.errors[0].message.toString().indexOf('token is expired') >= 0){ const errorInfo = json.errors[0].message.toString();
throw 'Login expired' if ((errorInfo.indexOf('token is expired') >= 0) || (errorInfo.indexOf('no token') >= 0)) {
const accountData = this.loadData("account");
await this.account.login(accountData[0], accountData[1]);
return await this.queryJson(query);
} }
throw json.errors[0].message throw json.errors[0].message
} }