♻️ 书源 id 去掉 ext. 前缀,沿用旧内置源数据
Co-authored-by: Copilot <[email protected]>
This commit is contained in:
1 parent
818a3d9067
commit
a8ce4da366
13 files changed
+42
-42
No files matched your search
@@ -7,7 +7,7 @@
|
||||
local _ = require("l10n").get("moonsource_jdread")
|
||||
|
||||
return {
|
||||
id = "ext.jdread",
|
||||
id = "jdread",
|
||||
name = _("京东读书"),
|
||||
type = "chapter",
|
||||
description = _("京东读书书架与在线阅读"),
|
||||
|
||||
@@ -34,15 +34,15 @@ local TICKET_ERRORS = {
|
||||
|
||||
---@return table
|
||||
local function cfg()
|
||||
return require("utils.settings").getSource("ext.jdread")
|
||||
return require("utils.settings").getSource("jdread")
|
||||
end
|
||||
|
||||
---@param patch table
|
||||
local function saveCfg(patch)
|
||||
local Settings = require("utils.settings")
|
||||
local current = Settings.getSource("ext.jdread")
|
||||
local current = Settings.getSource("jdread")
|
||||
for key, value in pairs(patch) do current[key] = value end
|
||||
Settings.saveSource("ext.jdread", current)
|
||||
Settings.saveSource("jdread", current)
|
||||
end
|
||||
|
||||
--- 全部 Set-Cookie 行:优先 Request.headerAll(Turbo 多值 / 合并行都拆好),否则退回单值读取。
|
||||
@@ -118,9 +118,9 @@ end
|
||||
local function nextQrFile()
|
||||
clearQrFile()
|
||||
local Paths = require("utils.paths")
|
||||
Paths.ensureLayout("ext.jdread")
|
||||
Paths.ensureLayout("jdread")
|
||||
qr_seq = qr_seq + 1
|
||||
qr_file = Paths.imageDir("ext.jdread") .. "/login-qr-" .. qr_seq .. ".png"
|
||||
qr_file = Paths.imageDir("jdread") .. "/login-qr-" .. qr_seq .. ".png"
|
||||
return qr_file
|
||||
end
|
||||
|
||||
@@ -334,21 +334,21 @@ local function saveSessionAsync(jar, cb)
|
||||
cb(false, err or _("京东登录校验失败"))
|
||||
return
|
||||
end
|
||||
current = require("utils.settings").getSource("ext.jdread")
|
||||
current = require("utils.settings").getSource("jdread")
|
||||
local function commit()
|
||||
current.cookie, current.uuid, current.account_id = cookie, uuid, account_id
|
||||
current.user_name = Text.urlDecode(jar.unick or jar.pin or jar.pt_pin or "") or ""
|
||||
require("utils.settings").saveSource("ext.jdread", current)
|
||||
require("utils.settings").saveSource("jdread", current)
|
||||
end
|
||||
if previous_id ~= account_id or not previous_id and previous_cookie ~= cookie then
|
||||
if not require("source.logout").replaceLibrary("ext.jdread", commit) then
|
||||
if not require("source.logout").replaceLibrary("jdread", commit) then
|
||||
cb(false, _("准备本地同步失败"))
|
||||
return
|
||||
end
|
||||
else
|
||||
commit()
|
||||
end
|
||||
require("source.auth").ok("ext.jdread")
|
||||
require("source.auth").ok("jdread")
|
||||
cb(true)
|
||||
end)
|
||||
return { cancel = function()
|
||||
|
||||
@@ -26,7 +26,7 @@ local DOWNLOAD_DENIED = 101
|
||||
|
||||
--- 京东会话失效文案:网页 Cookie 无续期,只能引导重新扫码。
|
||||
local function authExpired()
|
||||
return require("source.auth").expire("ext.jdread", _("点这个提示上的「重新登录」。二维码出来以后,打开手机京东 App,找到「扫一扫」,对准屏幕上的二维码,在手机上点确认。"))
|
||||
return require("source.auth").expire("jdread", _("点这个提示上的「重新登录」。二维码出来以后,打开手机京东 App,找到「扫一扫」,对准屏幕上的二维码,在手机上点确认。"))
|
||||
end
|
||||
|
||||
--- 响应 message 是否表示未登录 / 会话失效。
|
||||
@@ -58,7 +58,7 @@ local function decodeApi(raw, err, authed)
|
||||
end
|
||||
return nil, wire.message or (_("京东读书错误 ") .. tostring(wire.result_code))
|
||||
end
|
||||
if authed then require("source.auth").ok("ext.jdread") end
|
||||
if authed then require("source.auth").ok("jdread") end
|
||||
return wire
|
||||
end
|
||||
|
||||
@@ -84,7 +84,7 @@ end
|
||||
--- 会话罐:保存的 Cookie 打底,服务端轮换的会话 Cookie 留在罐里。
|
||||
---@return CookieJar|nil
|
||||
function Client:jar()
|
||||
return require("http.cookie_jar").session("ext.jdread", self.cookie)
|
||||
return require("http.cookie_jar").session("jdread", self.cookie)
|
||||
end
|
||||
|
||||
---@param referer string
|
||||
|
||||
@@ -9,7 +9,7 @@ local Text = require("utils.text")
|
||||
local _ = require("l10n").get("moonsource_jdread")
|
||||
|
||||
local Mapper = {}
|
||||
local SOURCE_ID = "ext.jdread"
|
||||
local SOURCE_ID = "jdread"
|
||||
|
||||
--- 京东图片地址带 .dpg 后缀(图床转 webp),去掉取原图。
|
||||
---@param value any
|
||||
|
||||
@@ -154,7 +154,7 @@ Setting.browser = {
|
||||
icon = "https://e.m.jd.com/toc-web/ico.png",
|
||||
isAuthorized = function()
|
||||
return require("moonsource_jdread.auth").hasSession()
|
||||
and not require("source.auth").expired("ext.jdread")
|
||||
and not require("source.auth").expired("jdread")
|
||||
end,
|
||||
apply = function(payload, cb)
|
||||
return require("moonsource_jdread.auth").importBrowserAsync(payload, function(ok, err)
|
||||
@@ -180,7 +180,7 @@ function Setting.rows()
|
||||
CookieLogin.browserRow(),
|
||||
}
|
||||
if not Auth.hasSession() then return rows end
|
||||
rows[#rows + 1] = require("source.logout").row("ext.jdread", _("确定退出京东读书账号?"), Auth.clearSession)
|
||||
rows[#rows + 1] = require("source.logout").row("jdread", _("确定退出京东读书账号?"), Auth.clearSession)
|
||||
return rows
|
||||
end
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ Source.__index = Source
|
||||
|
||||
---@return JdreadSource
|
||||
function Jdread.new()
|
||||
local cfg = require("utils.settings").getSource("ext.jdread")
|
||||
local cfg = require("utils.settings").getSource("jdread")
|
||||
local meta = Jdread.meta()
|
||||
return setmetatable({
|
||||
id = meta.id,
|
||||
@@ -279,7 +279,7 @@ local function fetchContent(self, identity, chapter, cb)
|
||||
end
|
||||
asset_job = Assets.localizeAsync(
|
||||
payload.html,
|
||||
Paths.bookWorkDir(identity.stable_id, "ext.jdread") .. "/images",
|
||||
Paths.bookWorkDir(identity.stable_id, "jdread") .. "/images",
|
||||
downloadImage,
|
||||
function(html)
|
||||
if cancelled then return end
|
||||
|
||||
Reference in new issue
Block a user