Browse Source

Merge pull request #1757 from zxlhhyccc/custom

luci-app-ssr-plus: Add save and apply after successful, jump to the node list
zxl hhyccc 3 tháng trước cách đây
mục cha
commit
35db64cdf3

+ 21 - 0
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua

@@ -22,6 +22,22 @@ local function is_installed(e)
 	return luci.model.ipkg.installed(e)
 end
 
+local function showMsg_Redirect(redirectUrl, delay)
+	local redirectUrl = redirectUrl or ""
+	local delay = delay or 3000
+	luci.http.write([[
+		<script type="text/javascript">
+			document.addEventListener('DOMContentLoaded', function() {
+				setTimeout(function() {
+					if ("]] .. redirectUrl .. [[" !== "") {
+						window.location.href = "]] .. redirectUrl .. [[";
+					}
+				}, ]] .. delay .. [[);
+			});
+		</script>
+	]])
+end
+
 local has_ss_rust = is_finded("sslocal") or is_finded("ssserver")
 local has_ss_libev = is_finded("ss-redir") or is_finded("ss-local")
 
@@ -137,6 +153,11 @@ if m.uci:get("shadowsocksr", sid) ~= "servers" then
 	luci.http.redirect(m.redirect)
 	return
 end
+-- 保存&应用成功后跳转到节点列表
+m.apply_on_parse = true
+m.on_after_apply = function(self)
+	showMsg_Redirect(self.redirect, 4500)
+end
 
 -- [[ Servers Setting ]]--
 s = m:section(NamedSection, sid, "servers")