附协议分析笔记,沿用统一的 update.lua 与打包脚本。 Co-authored-by: Copilot <[email protected]>
83 lines
2.9 KiB
Lua
83 lines
2.9 KiB
Lua
local _ = require("moonsource_bilimanga.l10n")
|
|
|
|
local ID = "bilimanga"
|
|
|
|
local function entries(desktop)
|
|
return { {
|
|
group = "network",
|
|
order = 100,
|
|
id = "login",
|
|
icon = "d_overwrite_feature",
|
|
title = _("哔哩哔哩漫画"),
|
|
page = {
|
|
title = _("哔哩哔哩漫画"),
|
|
sections = function()
|
|
local cfg = require("utils.settings").getSource(ID)
|
|
local has_cookie = cfg.cookie and cfg.cookie ~= ""
|
|
|
|
local function doLogin()
|
|
require("ui/modal").input({
|
|
title = _("请输入 SESSDATA Cookie"),
|
|
button = _("登录"),
|
|
text = cfg.cookie or "",
|
|
hint = "SESSDATA",
|
|
hint_is_field = true,
|
|
}, function(entry)
|
|
if not entry or entry == "" then return end
|
|
require("utils.settings").saveSource(ID, {
|
|
cookie = entry,
|
|
})
|
|
require("ui/uimanager"):popMenu()
|
|
local Toast = require("ui/themed").Toast
|
|
Toast:new({
|
|
text = _("已登录"),
|
|
timeout = 2,
|
|
}):show()
|
|
desktop:onEvent("book_source_refresh")
|
|
end)
|
|
end
|
|
|
|
local function doClear()
|
|
require("utils.settings").saveSource(ID, {
|
|
cookie = "",
|
|
})
|
|
require("ui/uimanager"):popMenu()
|
|
local Toast = require("ui/themed").Toast
|
|
Toast:new({
|
|
text = _("已清除 Cookie"),
|
|
timeout = 2,
|
|
}):show()
|
|
desktop:onEvent("book_source_refresh")
|
|
end
|
|
|
|
local rows = { {
|
|
fn = function()
|
|
return require("desktop.pages.setting.tree").Row.action({
|
|
text = has_cookie and _("已登录") or _("未登录"),
|
|
callback = doLogin,
|
|
})
|
|
end,
|
|
} }
|
|
|
|
if has_cookie then
|
|
rows[#rows + 1] = {
|
|
fn = function()
|
|
return require("desktop.pages.setting.tree").Row.action({
|
|
text = _("清除"),
|
|
callback = doClear,
|
|
})
|
|
end,
|
|
}
|
|
end
|
|
|
|
return { {
|
|
title = "",
|
|
rows = rows,
|
|
} }
|
|
end,
|
|
},
|
|
} }
|
|
end
|
|
|
|
return { entries = entries }
|