This commit is contained in:
1 parent
48af9d7e72
commit
7224137ed2
5 files changed
+35
-4
No files matched your search
@@ -1,5 +1,5 @@
|
||||
--[[--
|
||||
开源阅读书源设置:导入 Legado 书源(地址 / 本地文件 / 粘贴 JSON)、启停与删除、书架换源。
|
||||
开源阅读书源设置:导入 Legado 书源(地址 / 选择 .json、.jsonl 文件 / 粘贴 JSON)、启停与删除、书架换源。
|
||||
|
||||
@module moonsource_legadorule.setting
|
||||
--]]
|
||||
@@ -32,9 +32,11 @@ local function finishImport(text)
|
||||
toast(_("没有找到有效的书源"))
|
||||
return
|
||||
end
|
||||
Sources.add(rules)
|
||||
local _added, disabled = Sources.add(rules)
|
||||
require("source.registry").reload()
|
||||
toast(T(_("已导入 %1 个书源,跳过 %2 个无效项"), #rules, skipped))
|
||||
local msg = T(_("已导入 %1 个书源,跳过 %2 个无效项"), #rules, skipped)
|
||||
if disabled and disabled > 0 then msg = msg .. T(_(",%1 个需要 JS/WebView 已禁用"), disabled) end
|
||||
toast(msg)
|
||||
end
|
||||
|
||||
local function import(value)
|
||||
@@ -72,6 +74,21 @@ local function importDialog()
|
||||
}:show()
|
||||
end
|
||||
|
||||
local function importFile()
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local start = lfs.attributes("/mnt/us", "mode") == "directory" and "/mnt/us"
|
||||
or require("datastorage"):getDataDir()
|
||||
require("ui.themes.widgets.path_picker"):new{
|
||||
path = start,
|
||||
select_file = true,
|
||||
filter = function(name)
|
||||
local lower = name:lower()
|
||||
return lower:match("%.jsonl?$") ~= nil or lower:match("%.txt$") ~= nil
|
||||
end,
|
||||
on_select = import,
|
||||
}:show()
|
||||
end
|
||||
|
||||
local function manageOne(entry)
|
||||
local Sources = require("moonsource_legadorule.sources")
|
||||
require("ui.themes.widgets.list"):new{
|
||||
@@ -193,6 +210,12 @@ function Setting.rows()
|
||||
callback = importDialog,
|
||||
})
|
||||
end,
|
||||
function(iw)
|
||||
return Row().widget({
|
||||
width = iw, chevron = true, kind = "nav", icon = "download", title = _("从文件导入"),
|
||||
callback = importFile,
|
||||
})
|
||||
end,
|
||||
function(iw)
|
||||
return Row().widget({
|
||||
width = iw, chevron = true, kind = "nav", icon = "sync", title = _("书架换源"),
|
||||
|
||||
Reference in new issue
Block a user