From 43d4fcfabce8606501edeab6b846ca2be9adf05d Mon Sep 17 00:00:00 2001 From: Garfield Date: Mon, 16 Nov 2026 14:07:45 +0800 Subject: [PATCH] =?UTF-8?q?:recycle:=20=E4=B9=A6=E6=BA=90=20id=20=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=20ext.=20=E5=89=8D=E7=BC=80=EF=BC=8C=E6=B2=BF?= =?UTF-8?q?=E7=94=A8=E6=97=A7=E5=86=85=E7=BD=AE=E6=BA=90=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../moonsource_kuaikan/_meta.lua | 2 +- .../moonsource_kuaikan/client.lua | 20 +++++++++---------- .../moonsource_kuaikan/login.lua | 12 +++++------ .../moonsource_kuaikan/mapper.lua | 2 +- .../moonsource_kuaikan/setting.lua | 16 +++++++-------- tests/kuaikan/chapter_spec.lua | 2 +- tests/kuaikan/client_spec.lua | 2 +- tests/kuaikan/operations_spec.lua | 2 +- tests/kuaikan/reviews_spec.lua | 2 +- tests/kuaikan/shelf_spec.lua | 2 +- tests/kuaikan/sync_spec.lua | 2 +- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/moonsource-kuaikan.koplugin/moonsource_kuaikan/_meta.lua b/moonsource-kuaikan.koplugin/moonsource_kuaikan/_meta.lua index 29e3e42..b44c7b6 100644 --- a/moonsource-kuaikan.koplugin/moonsource_kuaikan/_meta.lua +++ b/moonsource-kuaikan.koplugin/moonsource_kuaikan/_meta.lua @@ -7,7 +7,7 @@ local _ = require("l10n").get("moonsource_kuaikan") return { - id = "ext.kuaikan", + id = "kuaikan", name = _("快看漫画"), type = "chapter", description = _("快看漫画在线阅读"), diff --git a/moonsource-kuaikan.koplugin/moonsource_kuaikan/client.lua b/moonsource-kuaikan.koplugin/moonsource_kuaikan/client.lua index 7b6944d..3b3a612 100644 --- a/moonsource-kuaikan.koplugin/moonsource_kuaikan/client.lua +++ b/moonsource-kuaikan.koplugin/moonsource_kuaikan/client.lua @@ -71,7 +71,7 @@ end ---@param headers table|nil ---@return table|nil local function withCookie(headers, cookie) - if cookie == nil then cookie = require("utils.settings").getSource("ext.kuaikan").cookie end + if cookie == nil then cookie = require("utils.settings").getSource("kuaikan").cookie end local saved = type(cookie) == "string" and cookie or "" if saved == "" then return headers end headers = headers or {} @@ -185,7 +185,7 @@ end ---@param cookie string|nil 本轮已校验的 Cookie;缺省取当前配置 ---@return { cancel: fun() } function Client.favAsync(cb, cookie) - if cookie == nil then cookie = require("utils.settings").getSource("ext.kuaikan").cookie or "" end + if cookie == nil then cookie = require("utils.settings").getSource("kuaikan").cookie or "" end local cancelled, active = false, nil local offset, collected, seen = 0, {}, {} local function nextPage() @@ -226,7 +226,7 @@ end --- 有稳定账号身份的登录态默认同步,真实有效性由请求前的账号校验确认。 ---@return boolean function Client.hasAccount() - local cfg = require("utils.settings").getSource("ext.kuaikan") + local cfg = require("utils.settings").getSource("kuaikan") return type(cfg.cookie) == "string" and cfg.cookie ~= "" and type(cfg.user_id) == "string" and cfg.user_id ~= "" end @@ -246,7 +246,7 @@ Sync.__index = Sync ---@param writing boolean|nil ---@return KuaikanSync function Client.newSync(writing) - local cfg = require("utils.settings").getSource("ext.kuaikan") + local cfg = require("utils.settings").getSource("kuaikan") return setmetatable({ cookie = cfg.cookie or "", previous_cookie = cfg.cookie, user_id = cfg.user_id, revision = Client.login_revision, writing = writing == true, @@ -255,7 +255,7 @@ end ---@return boolean function Sync:current() - local cfg = require("utils.settings").getSource("ext.kuaikan") + local cfg = require("utils.settings").getSource("kuaikan") return not self.cancelled and self.revision == Client.login_revision and cfg.cookie == self.previous_cookie and cfg.user_id == self.user_id and (not self.writing or self.user_id ~= nil) @@ -291,12 +291,12 @@ function Sync:checkAsync(cb) self:request("/v2/pweb/user_info/get", function(raw, err, res) local account, reason, expired = Client.accountResponse(raw, err, res) if not account then - if expired then require("source.auth").expire("ext.kuaikan", reason) end + if expired then require("source.auth").expire("kuaikan", reason) end cb(nil, reason) elseif self.user_id and tostring(self.user_id) ~= account.user_id then cb(nil, _("登录状态已变化,请重试")) else - require("source.auth").ok("ext.kuaikan") + require("source.auth").ok("kuaikan") cb(account) end end) @@ -473,7 +473,7 @@ end ---@return HttpJob function Client.imagesAsync(comic_id, cb) local state = { cancelled = false, job = nil } - local cfg = require("utils.settings").getSource("ext.kuaikan") + local cfg = require("utils.settings").getSource("kuaikan") local saved_cookie, saved_id, logged_in = cfg.cookie or "", cfg.user_id, cfg.logged_in == true local challenged = false local challenge = get(HOST .. "/v1/aegis/api/web/challenge?callback=callback_1", nil, function(_body, err, res) @@ -506,9 +506,9 @@ function Client.imagesAsync(comic_id, cb) state.job = nil local account, reason, expired = Client.accountResponse(account_raw, account_err, account_res) if expired then - local current = require("utils.settings").getSource("ext.kuaikan") + local current = require("utils.settings").getSource("kuaikan") if current.cookie == saved_cookie and current.user_id == saved_id then - require("source.auth").expire("ext.kuaikan", reason) + require("source.auth").expire("kuaikan", reason) else reason = _("登录状态已变化,请重试") end diff --git a/moonsource-kuaikan.koplugin/moonsource_kuaikan/login.lua b/moonsource-kuaikan.koplugin/moonsource_kuaikan/login.lua index e46b8e4..6c369dc 100644 --- a/moonsource-kuaikan.koplugin/moonsource_kuaikan/login.lua +++ b/moonsource-kuaikan.koplugin/moonsource_kuaikan/login.lua @@ -28,7 +28,7 @@ local Login = {} Login.__index = Login function Login.new() - local cfg = require("utils.settings").getSource("ext.kuaikan") + local cfg = require("utils.settings").getSource("kuaikan") return setmetatable({ cookies = {}, serial = 0, revision = Client.login_revision, previous_cookie = cfg.cookie, previous_id = cfg.user_id, @@ -155,7 +155,7 @@ end ---@param cb fun(account: table|nil, err: string|nil) function Login:accept(account, cb) local settings = require("utils.settings") - local cfg = settings.getSource("ext.kuaikan") + local cfg = settings.getSource("kuaikan") if self.revision ~= Client.login_revision or cfg.cookie ~= self.previous_cookie or cfg.user_id ~= self.previous_id then cb(nil, _("登录状态已变化,请重试")) return @@ -164,18 +164,18 @@ function Login:accept(account, cb) if cookie == "" then cb(nil, _("没有读到 Cookie")); return end if (self.previous_id and tostring(self.previous_id) ~= account.user_id) or (not self.previous_id and self.previous_cookie and cookie ~= CookieLogin.parse(self.previous_cookie)) then - local cleared = require("source.logout").clear("ext.kuaikan", function() + local cleared = require("source.logout").clear("kuaikan", function() cfg.cookie, cfg.user_id, cfg.logged_in = nil, nil, nil Client.login_revision = Client.login_revision + 1 - settings.saveSource("ext.kuaikan") + settings.saveSource("kuaikan") end) if not cleared then cb(nil, _("准备本地同步失败")); return end end cfg.cookie, cfg.user_id, cfg.logged_in = cookie, account.user_id, true - settings.saveSource("ext.kuaikan") + settings.saveSource("kuaikan") Client.login_revision = Client.login_revision + 1 self.revision = Client.login_revision - require("source.auth").ok("ext.kuaikan") + require("source.auth").ok("kuaikan") cb(account) end diff --git a/moonsource-kuaikan.koplugin/moonsource_kuaikan/mapper.lua b/moonsource-kuaikan.koplugin/moonsource_kuaikan/mapper.lua index ca21165..635106d 100644 --- a/moonsource-kuaikan.koplugin/moonsource_kuaikan/mapper.lua +++ b/moonsource-kuaikan.koplugin/moonsource_kuaikan/mapper.lua @@ -12,7 +12,7 @@ local Text = require("utils.text") local Mapper = {} Mapper.TOC_VERSION = 1 -local SOURCE_ID = "ext.kuaikan" +local SOURCE_ID = "kuaikan" ---@param topic_id string ---@param comic_id string diff --git a/moonsource-kuaikan.koplugin/moonsource_kuaikan/setting.lua b/moonsource-kuaikan.koplugin/moonsource_kuaikan/setting.lua index a55c98d..3fdca69 100644 --- a/moonsource-kuaikan.koplugin/moonsource_kuaikan/setting.lua +++ b/moonsource-kuaikan.koplugin/moonsource_kuaikan/setting.lua @@ -12,9 +12,9 @@ local Setting = {} local COOKIE_PATHS = { ["/"] = true, ["/v2"] = true, ["/v2/"] = true, ["/v2/pweb"] = true, ["/v2/pweb/"] = true } function Setting.rowStatus() - local cfg = require("utils.settings").getSource("ext.kuaikan") + local cfg = require("utils.settings").getSource("kuaikan") local on = cfg.logged_in == true and type(cfg.cookie) == "string" and cfg.cookie ~= "" - and type(cfg.user_id) == "string" and cfg.user_id ~= "" and not require("source.auth").expired("ext.kuaikan") + and type(cfg.user_id) == "string" and cfg.user_id ~= "" and not require("source.auth").expired("kuaikan") return on and _("已登录") or _("未登录 · 点此登录"), on end @@ -109,23 +109,23 @@ function Setting.rows(plugin) end, function(iw) local reviews = require("source.review_setting") - local on = reviews.enabled("ext.kuaikan") + local on = reviews.enabled("kuaikan") return Row.widget({ width = iw, chevron = false, kind = "toggle", icon = "forum", title = _("章节评论"), subtitle = _("在章末显示本章讨论,不是段落评论"), status = on and _("开") or _("关"), status_on = on, callback = function() - reviews.set("ext.kuaikan", not on) + reviews.set("kuaikan", not on) if plugin and plugin.desktop then plugin.desktop:updateView() end end }) end, } - local cfg = require("utils.settings").getSource("ext.kuaikan") + local cfg = require("utils.settings").getSource("kuaikan") if type(cfg.cookie) == "string" and cfg.cookie ~= "" then - rows[#rows + 1] = require("source.logout").row("ext.kuaikan", _("确定退出快看账号?"), function() - cfg = require("utils.settings").getSource("ext.kuaikan") + rows[#rows + 1] = require("source.logout").row("kuaikan", _("确定退出快看账号?"), function() + cfg = require("utils.settings").getSource("kuaikan") cfg.cookie, cfg.user_id, cfg.logged_in = nil, nil, nil Client.login_revision = Client.login_revision + 1 - require("utils.settings").saveSource("ext.kuaikan") + require("utils.settings").saveSource("kuaikan") end) end return rows diff --git a/tests/kuaikan/chapter_spec.lua b/tests/kuaikan/chapter_spec.lua index f852c0b..e66e2e3 100644 --- a/tests/kuaikan/chapter_spec.lua +++ b/tests/kuaikan/chapter_spec.lua @@ -38,7 +38,7 @@ package.loaded["http.request"] = { } local Chapter = require("moonsource_kuaikan.chapter") local called = false -local identity = { source_id = "ext.kuaikan", stable_id = "book" } +local identity = { source_id = "kuaikan", stable_id = "book" } local handle = Chapter.materializeAsync(identity, { uid = "1", vip = true }, nil, function() called = true end) Assert.is_true(fetched) handle.cancel() diff --git a/tests/kuaikan/client_spec.lua b/tests/kuaikan/client_spec.lua index cf39278..344a405 100644 --- a/tests/kuaikan/client_spec.lua +++ b/tests/kuaikan/client_spec.lua @@ -35,7 +35,7 @@ local detail = Mapper.detail(page.info, page.nickname) Assert.eq(detail.stable_id, "9") Assert.eq(detail.authors, "翘摇") Assert.eq(detail.cover, "https://c/a.jpg") -Assert.eq(detail.source_id, "ext.kuaikan") +Assert.eq(detail.source_id, "kuaikan") Assert.eq(detail.intro, "简介") local toc = Mapper.chapters(page.chapters) Assert.eq(#toc, 2) diff --git a/tests/kuaikan/operations_spec.lua b/tests/kuaikan/operations_spec.lua index 13ed950..83f1503 100644 --- a/tests/kuaikan/operations_spec.lua +++ b/tests/kuaikan/operations_spec.lua @@ -36,7 +36,7 @@ source.loadTocAsync = function(_self, _identity, cb) cb(toc) return { cancel = function() cancelled.toc = true end } end -local identity = { source_id = "ext.kuaikan", stable_id = "book" } +local identity = { source_id = "kuaikan", stable_id = "book" } local called = false local handle = source:openBookAsync(identity, nil, function() called = true end) Stubs.flush() diff --git a/tests/kuaikan/reviews_spec.lua b/tests/kuaikan/reviews_spec.lua index bb5bedf..f8b4103 100644 --- a/tests/kuaikan/reviews_spec.lua +++ b/tests/kuaikan/reviews_spec.lua @@ -29,7 +29,7 @@ function source:loadTocAsync(_identity, cb) cb({ { uid = "11", idx = 1, title = "One" }, { uid = "22", idx = 2, title = "Two" } }) return { cancel = function() end } end -local identity = { source_id = "ext.kuaikan", stable_id = "review-test", chapter_idx = 1 } +local identity = { source_id = "kuaikan", stable_id = "review-test", chapter_idx = 1 } local page, err source:paragraphReviewPageAsync(identity, "chapter", 0, function(value, reason) page, err = value, reason end) Assert.is_nil(err) diff --git a/tests/kuaikan/shelf_spec.lua b/tests/kuaikan/shelf_spec.lua index 688de75..42dd01d 100644 --- a/tests/kuaikan/shelf_spec.lua +++ b/tests/kuaikan/shelf_spec.lua @@ -25,7 +25,7 @@ package.loaded["source.auth"] = { expire = function() expired = true end, } package.loaded["source.shelf"] = { syncAsync = function(id, remote, _mapper, opts, cb) - Assert.eq(id, "ext.kuaikan") + Assert.eq(id, "kuaikan") Assert.is_true(opts.force) Assert.is_true(remote.writing) return remote:shelfSyncAsync(function(books, err) diff --git a/tests/kuaikan/sync_spec.lua b/tests/kuaikan/sync_spec.lua index 52e3b2d..b464654 100644 --- a/tests/kuaikan/sync_spec.lua +++ b/tests/kuaikan/sync_spec.lua @@ -103,7 +103,7 @@ source.loadTocAsync = function(_self, _identity, cb) cb(toc) return { cancel = function() error("已完成目录不得覆盖当前请求") end } end -local identity = { source_id = "ext.kuaikan", stable_id = "9" } +local identity = { source_id = "kuaikan", stable_id = "9" } local handle = source:putProgressAsync(identity, { fraction = 0.6875, chapter_idx = 2, chapter_fraction = 0.375, page = 3, total_pages = 8 }, done) reply(account)