luci: eliminate JS LuCI behavior

This commit is contained in:
xiaorouji 2023-09-22 02:13:40 +08:00 committed by sbwml
parent 6e6647c1e8
commit aaeee88107
17 changed files with 33 additions and 0 deletions

View File

@ -4,6 +4,7 @@ local sys = api.sys
local has_chnlist = api.fs.access("/usr/share/passwall/rules/chnlist")
m = Map(appname)
api.set_apply_on_parse(m)
s = m:section(TypedSection, "global", translate("ACLs"), "<font color='red'>" .. translate("ACLs is a tools which used to designate specific IP proxy mode.") .. "</font>")
s.anonymous = true

View File

@ -6,6 +6,7 @@ local has_xray = api.finded_com("xray")
local has_chnlist = api.fs.access("/usr/share/passwall/rules/chnlist")
m = Map(appname)
api.set_apply_on_parse(m)
local nodes_table = {}
for k, e in ipairs(api.get_valid_nodes()) do

View File

@ -2,6 +2,7 @@ local api = require "luci.passwall.api"
local appname = api.appname
m = Map(appname)
api.set_apply_on_parse(m)
-- [[ App Settings ]]--
s = m:section(TypedSection, "global_app", translate("App Update"),

View File

@ -7,6 +7,7 @@ local has_xray = api.finded_com("xray")
local has_chnlist = api.fs.access("/usr/share/passwall/rules/chnlist")
m = Map(appname)
api.set_apply_on_parse(m)
local nodes_table = {}
for k, e in ipairs(api.get_valid_nodes()) do

View File

@ -16,6 +16,7 @@ for k, e in ipairs(api.get_valid_nodes()) do
end
m = Map(appname)
api.set_apply_on_parse(m)
-- [[ Haproxy Settings ]]--
s = m:section(TypedSection, "global_haproxy")

View File

@ -10,6 +10,7 @@ end
m = Map(appname, translate("Node Config"))
m.redirect = api.url()
api.set_apply_on_parse(m)
s = m:section(NamedSection, arg[1], "nodes", "")
s.addremove = false

View File

@ -4,6 +4,7 @@ local sys = api.sys
local datatypes = api.datatypes
m = Map(appname)
api.set_apply_on_parse(m)
-- [[ Other Settings ]]--
s = m:section(TypedSection, "global_other")

View File

@ -30,6 +30,7 @@ if has_trojan_go then
end
m = Map(appname)
api.set_apply_on_parse(m)
-- [[ Subscribe Settings ]]--
s = m:section(TypedSection, "global_subscribe", "")

View File

@ -32,6 +32,7 @@ end
m = Map(appname)
m.redirect = api.url("node_subscribe")
api.set_apply_on_parse(m)
s = m:section(NamedSection, arg[1])
s.addremove = false

View File

@ -7,6 +7,7 @@ local has_fw3 = api.is_finded("fw3")
local has_fw4 = api.is_finded("fw4")
m = Map(appname)
api.set_apply_on_parse(m)
-- [[ Delay Settings ]]--
s = m:section(TypedSection, "global_delay", translate("Delay Settings"))

View File

@ -3,6 +3,8 @@ local appname = api.appname
local has_xray = api.finded_com("xray")
m = Map(appname)
api.set_apply_on_parse(m)
-- [[ Rule Settings ]]--
s = m:section(TypedSection, "global_rules", translate("Rule status"))
s.anonymous = true

View File

@ -7,6 +7,7 @@ local path = string.format("/usr/share/%s/rules/", appname)
local route_hosts_path = "/etc/"
m = Map(appname)
api.set_apply_on_parse(m)
-- [[ Rule List Settings ]]--
s = m:section(TypedSection, "global_rules")

View File

@ -4,6 +4,7 @@ local datatypes = api.datatypes
m = Map(appname, "Xray " .. translate("Shunt Rule"))
m.redirect = api.url()
api.set_apply_on_parse(m)
s = m:section(NamedSection, arg[1], "shunt_rules", "")
s.addremove = false

View File

@ -4,6 +4,7 @@ local uci = api.uci
local has_xray = api.finded_com("xray")
m = Map(appname)
api.set_apply_on_parse(m)
local nodes_table = {}
for k, e in ipairs(api.get_valid_nodes()) do

View File

@ -1,6 +1,7 @@
local api = require "luci.passwall.api"
m = Map("passwall_server", translate("Server-Side"))
api.set_apply_on_parse(m)
t = m:section(NamedSection, "global", "global")
t.anonymous = true

View File

@ -4,6 +4,7 @@ local types_dir = "/usr/lib/lua/luci/model/cbi/passwall/server/type/"
m = Map("passwall_server", translate("Server Config"))
m.redirect = api.url("server")
api.set_apply_on_parse(m)
s = m:section(NamedSection, arg[1], "user", "")
s.addremove = false

View File

@ -973,6 +973,22 @@ function to_check_self()
}
end
function is_js_luci()
return sys.call('[ -f "/www/luci-static/resources/uci.js" ]') == 0
end
function set_apply_on_parse(map)
if is_js_luci() == true then
map.apply_on_parse = false
map.on_after_apply = function(self)
if self.redirect then
os.execute("sleep 1")
luci.http.redirect(self.redirect)
end
end
end
end
function luci_types(id, m, s, type_name, option_prefix)
local rewrite_option_table = {}
for key, value in pairs(s.fields) do