From 2067c985ee42acac0681a682ca8b89b97b04863c Mon Sep 17 00:00:00 2001 From: gitea-action Date: Sun, 12 Jan 2025 14:30:19 +0800 Subject: [PATCH] luci-app-passwall: sync upstream last commit: https://github.com/xiaorouji/openwrt-passwall/commit/7866380106b445ea1ac9ce5fa5db6907a8c7c3c7 --- .../luasrc/model/cbi/passwall/client/type/ray.lua | 8 +++++--- luci-app-passwall/luasrc/passwall/api.lua | 13 +++++++++---- luci-app-passwall/po/zh-cn/passwall.po | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua index 7cb119bb9..029715699 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua @@ -566,14 +566,12 @@ o = s:option(Value, _n("xhttp_path"), translate("XHTTP Path")) o.placeholder = "/" o:depends({ [_n("transport")] = "xhttp" }) -o = s:option(TextValue, _n("xhttp_extra"), translate("XHTTP Extra"), translate("An XHTTP extra object in raw json")) +o = s:option(TextValue, _n("xhttp_extra"), translate("XHTTP Extra"), translate("An XHttpObject in JSON format, used for sharing.")) o:depends({ [_n("transport")] = "xhttp" }) o.rows = 15 o.wrap = "off" o.custom_write = function(self, section, value) - m:set(section, self.option:sub(1 + #option_prefix), value) - local success, data = pcall(jsonc.parse, value) if success and data then local address = (data.extra and data.extra.downloadSettings and data.extra.downloadSettings.address) @@ -594,6 +592,10 @@ o.validate = function(self, value) end return value end +o.custom_remove = function(self, section, value) + m:del(section, self.option:sub(1 + #option_prefix)) + m:del(section, "download_address") +end -- [[ Mux.Cool ]]-- o = s:option(Flag, _n("mux"), "Mux", translate("Enable Mux.Cool")) diff --git a/luci-app-passwall/luasrc/passwall/api.lua b/luci-app-passwall/luasrc/passwall/api.lua index 48f0dd402..c1a7a283d 100644 --- a/luci-app-passwall/luasrc/passwall/api.lua +++ b/luci-app-passwall/luasrc/passwall/api.lua @@ -1178,11 +1178,16 @@ function luci_types(id, m, s, type_name, option_prefix) end s.fields[key].remove = function(self, section) if s.fields["type"]:formvalue(id) == type_name then - if self.rewrite_option and rewrite_option_table[self.rewrite_option] == 1 then - m:del(section, self.rewrite_option) + -- 添加自定义 custom_remove 属性,如果有自定义的 custom_remove 函数,则使用自定义的 remove 逻辑 + if self.custom_remove then + self:custom_remove(section) else - if self.option:find(option_prefix) == 1 then - m:del(section, self.option:sub(1 + #option_prefix)) + if self.rewrite_option and rewrite_option_table[self.rewrite_option] == 1 then + m:del(section, self.rewrite_option) + else + if self.option:find(option_prefix) == 1 then + m:del(section, self.option:sub(1 + #option_prefix)) + end end end end diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index f5e216e7b..657a00b27 100644 --- a/luci-app-passwall/po/zh-cn/passwall.po +++ b/luci-app-passwall/po/zh-cn/passwall.po @@ -1567,8 +1567,8 @@ msgstr "客户端文件不适合当前设备。" msgid "Can't move new file to path: %s" msgstr "无法移动新文件到:%s" -msgid "An XHTTP extra object in raw json" -msgstr "一个 json 格式的 XHTTP extra object" +msgid "An XHttpObject in JSON format, used for sharing." +msgstr "JSON 格式的 XHttpObject,用来实现分享。" msgid "Enable Mux.Cool" msgstr "启用 Mux.Cool"