♻️ 书源 id 去掉 ext. 前缀,沿用旧内置源数据
Co-authored-by: Copilot <[email protected]>
This commit is contained in:
1 parent
7a09f7c834
commit
86b1f0c562
11 files changed
+26
-26
No files matched your search
@@ -7,7 +7,7 @@
|
|||||||
local _ = require("l10n").get("moonsource_zymk")
|
local _ = require("l10n").get("moonsource_zymk")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id = "ext.zymk",
|
id = "zymk",
|
||||||
name = _("知音漫客"),
|
name = _("知音漫客"),
|
||||||
type = "chapter",
|
type = "chapter",
|
||||||
description = _("知音漫客在线阅读"),
|
description = _("知音漫客在线阅读"),
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ end
|
|||||||
---@return { cancel: fun() }
|
---@return { cancel: fun() }
|
||||||
function Client.shelfAsync(account, cb)
|
function Client.shelfAsync(account, cb)
|
||||||
local Settings = require("utils.settings")
|
local Settings = require("utils.settings")
|
||||||
if not Mapper.account(account) or require("source.auth").expired("ext.zymk") then
|
if not Mapper.account(account) or require("source.auth").expired("zymk") then
|
||||||
return SourceBase.defer(cb, nil, _("请先登录知音漫客"))
|
return SourceBase.defer(cb, nil, _("请先登录知音漫客"))
|
||||||
end
|
end
|
||||||
if Settings.getSource("ext.zymk").account ~= account then
|
if Settings.getSource("zymk").account ~= account then
|
||||||
return SourceBase.defer(cb, nil, _("登录状态已变化,请重试"))
|
return SourceBase.defer(cb, nil, _("登录状态已变化,请重试"))
|
||||||
end
|
end
|
||||||
if not require("ui/network/manager"):isConnected() then
|
if not require("ui/network/manager"):isConnected() then
|
||||||
@@ -75,7 +75,7 @@ function Client.shelfAsync(account, cb)
|
|||||||
local cancelled = false
|
local cancelled = false
|
||||||
local job = Client.authAsync("/apinew/getuserrecord/", fields, function(data, err)
|
local job = Client.authAsync("/apinew/getuserrecord/", fields, function(data, err)
|
||||||
if cancelled then return end
|
if cancelled then return end
|
||||||
if Settings.getSource("ext.zymk").account ~= account then
|
if Settings.getSource("zymk").account ~= account then
|
||||||
cb(nil, _("登录状态已变化,请重试")); return
|
cb(nil, _("登录状态已变化,请重试")); return
|
||||||
end
|
end
|
||||||
local books = data and Mapper.shelf(data)
|
local books = data and Mapper.shelf(data)
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ local Login = {}
|
|||||||
Login.__index = Login
|
Login.__index = Login
|
||||||
|
|
||||||
function Login.new()
|
function Login.new()
|
||||||
return setmetatable({ previous = Settings.getSource("ext.zymk").account, serial = 0 }, Login)
|
return setmetatable({ previous = Settings.getSource("zymk").account, serial = 0 }, Login)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Login.hasAccount()
|
function Login.hasAccount()
|
||||||
return Mapper.account(Settings.getSource("ext.zymk").account) ~= nil
|
return Mapper.account(Settings.getSource("zymk").account) ~= nil
|
||||||
and not require("source.auth").expired("ext.zymk")
|
and not require("source.auth").expired("zymk")
|
||||||
end
|
end
|
||||||
|
|
||||||
function Login:cancel()
|
function Login:cancel()
|
||||||
@@ -46,7 +46,7 @@ function Login:request(path, fields, cb)
|
|||||||
pending = false
|
pending = false
|
||||||
if self.serial ~= serial then return end
|
if self.serial ~= serial then return end
|
||||||
self.job = nil
|
self.job = nil
|
||||||
if Settings.getSource("ext.zymk").account ~= self.previous then
|
if Settings.getSource("zymk").account ~= self.previous then
|
||||||
cb(nil, _("登录状态已变化,请重试")); return
|
cb(nil, _("登录状态已变化,请重试")); return
|
||||||
end
|
end
|
||||||
cb(data, err and tostring(err) or nil)
|
cb(data, err and tostring(err) or nil)
|
||||||
@@ -66,15 +66,15 @@ function Login:confirm(fields, cb)
|
|||||||
cb(nil, _("登录响应无效")); return
|
cb(nil, _("登录响应无效")); return
|
||||||
end
|
end
|
||||||
if self.previous and (self.previous.openid ~= account.openid or self.previous.type ~= account.type) then
|
if self.previous and (self.previous.openid ~= account.openid or self.previous.type ~= account.type) then
|
||||||
local cleared = require("source.logout").clear("ext.zymk", function()
|
local cleared = require("source.logout").clear("zymk", function()
|
||||||
Settings.getSource("ext.zymk").account = nil
|
Settings.getSource("zymk").account = nil
|
||||||
Settings.saveSource("ext.zymk")
|
Settings.saveSource("zymk")
|
||||||
end)
|
end)
|
||||||
if not cleared then cb(nil, _("准备本地同步失败")); return end
|
if not cleared then cb(nil, _("准备本地同步失败")); return end
|
||||||
end
|
end
|
||||||
Settings.getSource("ext.zymk").account = account
|
Settings.getSource("zymk").account = account
|
||||||
Settings.saveSource("ext.zymk")
|
Settings.saveSource("zymk")
|
||||||
require("source.auth").ok("ext.zymk")
|
require("source.auth").ok("zymk")
|
||||||
require("source.registry").reload()
|
require("source.registry").reload()
|
||||||
cb(account)
|
cb(account)
|
||||||
end)
|
end)
|
||||||
@@ -101,7 +101,7 @@ function Login:sendSmsAsync(phone, points, refresh, cb)
|
|||||||
end
|
end
|
||||||
self.captcha = nil
|
self.captcha = nil
|
||||||
self:request("/apinew/sendsms/", {
|
self:request("/apinew/sendsms/", {
|
||||||
mobile = phone, service = "ext.zymk", imgCode = img_code, refresh = refresh and 1 or 0,
|
mobile = phone, service = "zymk", imgCode = img_code, refresh = refresh and 1 or 0,
|
||||||
}, function(data, err)
|
}, function(data, err)
|
||||||
if data and data.sent then self.sms_phone, self.retry_at = phone, os.time() + 60
|
if data and data.sent then self.sms_phone, self.retry_at = phone, os.time() + 60
|
||||||
elseif data then self.captcha = data end
|
elseif data then self.captcha = data end
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ local Text = require("utils.text")
|
|||||||
local Mapper = {}
|
local Mapper = {}
|
||||||
|
|
||||||
Mapper.TOC_VERSION = 1
|
Mapper.TOC_VERSION = 1
|
||||||
local SOURCE_ID = "ext.zymk"
|
local SOURCE_ID = "zymk"
|
||||||
local COVER = "https://chapter-cover.yyhao.com/file/cover/%s.jpg-300x400"
|
local COVER = "https://chapter-cover.yyhao.com/file/cover/%s.jpg-300x400"
|
||||||
|
|
||||||
---@class ZymkAccount
|
---@class ZymkAccount
|
||||||
|
|||||||
@@ -87,11 +87,11 @@ function Setting.rows()
|
|||||||
callback = function() Setting.prompt(false) end })
|
callback = function() Setting.prompt(false) end })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
if require("utils.settings").getSource("ext.zymk").account then
|
if require("utils.settings").getSource("zymk").account then
|
||||||
rows[#rows + 1] = require("source.logout").row("ext.zymk", _("确定退出知音漫客账号?"), function()
|
rows[#rows + 1] = require("source.logout").row("zymk", _("确定退出知音漫客账号?"), function()
|
||||||
local Settings = require("utils.settings")
|
local Settings = require("utils.settings")
|
||||||
Settings.getSource("ext.zymk").account = nil
|
Settings.getSource("zymk").account = nil
|
||||||
Settings.saveSource("ext.zymk")
|
Settings.saveSource("zymk")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
return rows
|
return rows
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ function Zhiyinmanke.new()
|
|||||||
local meta = Zhiyinmanke.meta()
|
local meta = Zhiyinmanke.meta()
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
id = meta.id, name = meta.name, type = meta.type,
|
id = meta.id, name = meta.name, type = meta.type,
|
||||||
account = require("utils.settings").getSource("ext.zymk").account,
|
account = require("utils.settings").getSource("zymk").account,
|
||||||
}, Source)
|
}, Source)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ package.loaded["http.request"] = {
|
|||||||
}
|
}
|
||||||
local Chapter = require("moonsource_zymk.chapter")
|
local Chapter = require("moonsource_zymk.chapter")
|
||||||
local called = false
|
local called = false
|
||||||
local identity = { source_id = "ext.zymk", stable_id = "book" }
|
local identity = { source_id = "zymk", stable_id = "book" }
|
||||||
local handle = Chapter.materializeAsync(identity, { uid = "123/first" }, nil, function() called = true end)
|
local handle = Chapter.materializeAsync(identity, { uid = "123/first" }, nil, function() called = true end)
|
||||||
handle.cancel()
|
handle.cancel()
|
||||||
Assert.is_true(cancelled.download)
|
Assert.is_true(cancelled.download)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ Assert.is_nil(Page.detail("<html></html>"))
|
|||||||
local detail = Mapper.detail(parsed, 4982)
|
local detail = Mapper.detail(parsed, 4982)
|
||||||
Assert.eq(detail.authors, "飒飒动漫")
|
Assert.eq(detail.authors, "飒飒动漫")
|
||||||
Assert.eq(detail.cover, "https://img/cover.jpg")
|
Assert.eq(detail.cover, "https://img/cover.jpg")
|
||||||
Assert.eq(detail.source_id, "ext.zymk")
|
Assert.eq(detail.source_id, "zymk")
|
||||||
Assert.eq(detail.intro, "简介")
|
Assert.eq(detail.intro, "简介")
|
||||||
|
|
||||||
local toc = Mapper.chapters(25289, {
|
local toc = Mapper.chapters(25289, {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ Assert.is_false(Login.hasAccount())
|
|||||||
Assert.is_nil(Mapper.account({ openid = "guest", type = "device" }))
|
Assert.is_nil(Mapper.account({ openid = "guest", type = "device" }))
|
||||||
session:sendSmsAsync(phone, nil, false, done)
|
session:sendSmsAsync(phone, nil, false, done)
|
||||||
Assert.matches(requests[#requests].url, "/apinew/sendsms/$")
|
Assert.matches(requests[#requests].url, "/apinew/sendsms/$")
|
||||||
Assert.matches(requests[#requests].body, "service=ext.zymk")
|
Assert.matches(requests[#requests].body, "service=zymk")
|
||||||
Assert.matches(requests[#requests].body, "refresh=0")
|
Assert.matches(requests[#requests].body, "refresh=0")
|
||||||
local captcha = { Image = "image", Width = 320, Height = 120, Content = "文字" }
|
local captcha = { Image = "image", Width = 320, Height = 120, Content = "文字" }
|
||||||
requests[#requests].cb(JSON.encode({ status = 1031, data = captcha }))
|
requests[#requests].cb(JSON.encode({ status = 1031, data = captcha }))
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ source.loadTocAsync = function(_self, _identity, cb)
|
|||||||
cb(toc)
|
cb(toc)
|
||||||
return { cancel = function() cancelled.toc = true end }
|
return { cancel = function() cancelled.toc = true end }
|
||||||
end
|
end
|
||||||
local identity = { source_id = "ext.zymk", stable_id = "book" }
|
local identity = { source_id = "zymk", stable_id = "book" }
|
||||||
local called = false
|
local called = false
|
||||||
local handle = source:openBookAsync(identity, nil, function() called = true end)
|
local handle = source:openBookAsync(identity, nil, function() called = true end)
|
||||||
Stubs.flush()
|
Stubs.flush()
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ end }
|
|||||||
local written, options, calls = nil, nil, 0
|
local written, options, calls = nil, nil, 0
|
||||||
package.loaded["book.books_db"] = {
|
package.loaded["book.books_db"] = {
|
||||||
reconcile = function(source_id, books, opts)
|
reconcile = function(source_id, books, opts)
|
||||||
Assert.eq(source_id, "ext.zymk")
|
Assert.eq(source_id, "zymk")
|
||||||
written, options, calls = books, opts, calls + 1
|
written, options, calls = books, opts, calls + 1
|
||||||
return true, 0
|
return true, 0
|
||||||
end,
|
end,
|
||||||
|
|||||||
Reference in new issue
Block a user