🐶 Sync 2025-11-02 14:26:26

This commit is contained in:
actions-user
2025-11-02 14:26:26 +08:00
parent 64bcc56c2a
commit ac011db799
1557 changed files with 746465 additions and 0 deletions

View File

@@ -0,0 +1,144 @@
module("luci.controller.istorex", package.seeall)
function index()
if luci.sys.call("pgrep quickstart >/dev/null") == 0 then
entry({"admin", "istorex"}, call("istorex_template")).leaf = true
if nixio.fs.access("/usr/lib/lua/luci/view/istorex/main_dev.htm") then
entry({"admin", "istorex_dev"}, call("istorex_template_dev")).leaf = true
end
else
entry({"admin", "istorex"}, call("redirect_fallback")).leaf = true
end
entry({"admin", "istorex_api","status"}, call("istorex_api_status")).dependent = false
entry({"admin", "istorex_api","update"}, call("istorex_api_update")).dependent = false
entry({"admin", "istorex_api","upload-bg"}, call("istorex_api_uploadbg")).dependent = false
end
local function user_id()
local jsonc = require "luci.jsonc"
local json_parse = jsonc.parse
local fs = require "nixio.fs"
local data = fs.readfile("/etc/.app_store.id")
local id
if data ~= nil then
id = json_parse(data)
end
if id == nil then
fs.unlink("/etc/.app_store.id")
id = {arch="",uid=""}
end
id.version = (fs.readfile("/etc/.app_store.version") or "?"):gsub("[\r\n]", "")
return id
end
function get_config_data()
local uci = require "luci.model.uci".cursor()
local model = uci:get_first("istorex", "istorex", "model")
local enabled = uci:get_first("istorex", "istorex", "enabled")
local data = {
model = model,
enabled = enabled,
}
return data
end
function get_params()
local config = get_config_data()
local data = {
prefix=luci.dispatcher.build_url(unpack({"admin", "istorex"})),
id=user_id(),
model = config.model,
}
return data
end
function get_dev_params()
local config = get_config_data()
local data = {
prefix=luci.dispatcher.build_url(unpack({"admin", "istorex_dev"})),
id=user_id(),
model = config.model,
}
return data
end
function redirect_fallback()
luci.http.redirect(luci.dispatcher.build_url("admin","status"))
end
function istorex_template()
luci.template.render("istorex/main", get_params())
end
function istorex_template_dev()
luci.template.render("istorex/main_dev", get_dev_params())
end
function istorex_api_status()
local result = get_config_data()
luci.http.prepare_content("application/json")
luci.http.write_json({
success = 0,
result = result,
})
end
function istorex_api_update()
local http = require "luci.http"
local jsonc = require "luci.jsonc"
local uci = require "luci.model.uci".cursor()
local content = http.content()
local json_parse = jsonc.parse
local req = json_parse(content)
local data = {
}
if req == nil or next(req) == nil then
data.error = "invalid request"
else
uci:set("istorex","@istorex[0]","model", req.model)
uci:commit("istorex")
data.success = 0
end
http.prepare_content("application/json")
http.write_json(data)
end
function istorex_api_uploadbg()
local uci = require "uci"
local x = uci.cursor()
local fd
local path
local finished = false
local tmpdir = "/www/luci-static/istorex/image"
local filename = ""
luci.http.setfilehandler(
function(meta, chunk, eof)
if not fd then
filename = meta.file
path = tmpdir .. "/bg.gif"
fd = io.open(path, "w")
end
if chunk then
fd:write(chunk)
end
if eof then
fd:close()
finished = true
end
end
)
luci.http.formvalue("file")
local result = {
filename = filename
}
local data = {
success = finished,
result = result
}
luci.http.prepare_content("application/json")
luci.http.write_json(data)
end

View File

@@ -0,0 +1,4 @@
<%
local istorex = require "luci.controller.istorex"
istorex.istorex_template()
%>

View File

@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- <meta name="viewport" content="width=1400, initial-scale=1.0" /> -->
<!-- <meta name="viewport" content="width=1100" /> -->
<title><%=luci.sys.hostname()%></title>
</head>
<body>
<script src="<%=url('admin/translations', luci.i18n.context.lang)%><%# ?v=PKG_VERSION %>"></script>
<script src="<%=resource%>/cbi.js<%# ?v=PKG_VERSION %>"></script>
<script type="text/javascript" src="<%=resource%>/promis.min.js<%# ?v=PKG_VERSION %>"></script>
<script type="text/javascript" src="<%=resource%>/luci.js<%# ?v=PKG_VERSION %>"></script>
<%+tasks/embed%>
<script>
(function(){
var pathe_prefix = "<%=prefix%>"
window.istoreXVer = "<%# PKG_VERSION %>"
window.HostName = "<%=luci.sys.hostname()%>"
window.path_base = pathe_prefix
window.token = "<%=token%>"
window.model = "<%=model%>"
window.device_id = {
arch:"<%=id.arch%>",
uid:"<%=id.uid%>",
version:"<%=id.version%>"
}
})();
</script>
<script type="text/javascript">
L = new LuCI(<%= luci.http.write_json({
token = token,
media = media,
resource = resource,
scriptname = luci.http.getenv("SCRIPT_NAME"),
pathinfo = luci.http.getenv("PATH_INFO"),
documentroot = luci.http.getenv("DOCUMENT_ROOT"),
requestpath = luci.dispatcher.context.requestpath,
dispatchpath = luci.dispatcher.context.path,
pollinterval = luci.config.main.pollinterval or 5,
ubuspath = luci.config.main.ubuspath or '/ubus/',
sessionid = luci.dispatcher.context.authsession,
nodespec = luci.dispatcher.context.dispatched,
apply_rollback = math.max(applyconf and applyconf.rollback or 90, 30),
apply_holdoff = math.max(applyconf and applyconf.holdoff or 4, 1),
apply_timeout = math.max(applyconf and applyconf.timeout or 5, 1),
apply_display = math.max(applyconf and applyconf.display or 1.5, 1),
rollback_token = rollback_token
}) %>);
</script>
<div id="app"></div>
<link rel="stylesheet" href="/luci-static/istorex/style.css<%# ?v=PKG_VERSION %>">
<script type="module" crossorigin src="/luci-static/istorex/index.js<%# ?v=PKG_VERSION %>"></script>
</body>
</html>

View File

@@ -0,0 +1,60 @@
<%
local ver = require "luci.version"
-%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0" /> -->
<meta name="viewport" content="width=1100" />
<title></title>
</head>
<body>
<script src="<%=url('admin/translations', luci.i18n.context.lang)%><%# ?v=PKG_VERSION %>"></script>
<script src="<%=resource%>/cbi.js<%# ?v=PKG_VERSION %>"></script>
<script type="text/javascript" src="<%=resource%>/promis.min.js<%# ?v=PKG_VERSION %>"></script>
<script type="text/javascript" src="<%=resource%>/luci.js<%# ?v=PKG_VERSION %>"></script>
<%+tasks/embed%>
<script>
(function(){
var pathe_prefix = "<%=prefix%>"
window.istoreXVer = "<%# PKG_VERSION %>"
window.HostName = "<%=luci.sys.hostname()%>"
window.path_base = pathe_prefix
window.token = "<%=token%>"
window.model = "<%=model%>"
window.device_id = {
arch:"<%=id.arch%>",
uid:"<%=id.uid%>",
version:"<%=id.version%>"
}
})();
</script>
<script type="text/javascript">
L = new LuCI(<%= luci.http.write_json({
token = token,
media = media,
resource = resource,
scriptname = luci.http.getenv("SCRIPT_NAME"),
pathinfo = luci.http.getenv("PATH_INFO"),
documentroot = luci.http.getenv("DOCUMENT_ROOT"),
requestpath = luci.dispatcher.context.requestpath,
dispatchpath = luci.dispatcher.context.path,
pollinterval = luci.config.main.pollinterval or 5,
ubuspath = luci.config.main.ubuspath or '/ubus/',
sessionid = luci.dispatcher.context.authsession,
nodespec = luci.dispatcher.context.dispatched,
apply_rollback = math.max(applyconf and applyconf.rollback or 90, 30),
apply_holdoff = math.max(applyconf and applyconf.holdoff or 4, 1),
apply_timeout = math.max(applyconf and applyconf.timeout or 5, 1),
apply_display = math.max(applyconf and applyconf.display or 1.5, 1),
rollback_token = rollback_token
}) %>);
</script>
<div id="app"></div>
<script type="module" src="http://localhost:3000/src/main.ts"></script>
</body>
</html>