From 33eccb6601cd4eea099ec4ac63280f65feb4ac84 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Tue, 3 Jun 2025 20:06:49 +0330 Subject: [PATCH] Refactor: Clarify service UI update logic in settings --- core/scripts/webpanel/templates/settings.html | 59 +++++++++++-------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/core/scripts/webpanel/templates/settings.html b/core/scripts/webpanel/templates/settings.html index 9a532fd..198a0e0 100644 --- a/core/scripts/webpanel/templates/settings.html +++ b/core/scripts/webpanel/templates/settings.html @@ -626,14 +626,15 @@ "hysteria_telegram_bot": "#telegram_form", "hysteria_normal_sub": "#normal_sub_service_form", "hysteria_iplimit": "#ip-limit-service", - "hysteria_warp": "warp_service" + "hysteria_warp": "#warp_service" }; - Object.keys(servicesMap).forEach(service => { - let targetSelector = servicesMap[service]; - let isRunning = data[service]; + Object.keys(servicesMap).forEach(serviceKey => { + let targetSelector = servicesMap[serviceKey]; + let isRunning = data[serviceKey]; - if (service === "hysteria_normal_sub") { + + if (serviceKey === "hysteria_normal_sub") { const $normalForm = $("#normal_sub_service_form"); const $normalFormGroups = $normalForm.find(".form-group"); const $normalStartBtn = $("#normal_start"); @@ -661,7 +662,7 @@ $("#normal_subpath_input").val(""); $("#normal_subpath_input").removeClass('is-invalid'); } - } else if (service === "hysteria_iplimit") { + } else if (serviceKey === "hysteria_iplimit") { const $ipLimitServiceForm = $("#ip_limit_service_form"); const $configTabLi = $(".ip-limit-config-tab-li"); if (isRunning) { @@ -676,14 +677,16 @@ $("#ip_limit_start").show(); $("#ip_limit_stop").hide(); $configTabLi.hide(); - $('#ip-limit-service-tab').tab('show'); + if ($('#ip-limit-config-tab').hasClass('active')) { + $('#ip-limit-service-tab').tab('show'); + } $ipLimitServiceForm.find(".alert-info").remove(); $("#block_duration").val(""); $("#max_ips").val(""); $("#block_duration, #max_ips").removeClass('is-invalid'); } - } else if (service === "hysteria_warp") { - const isWarpServiceRunning = data[service]; + } else if (serviceKey === "hysteria_warp") { + const isWarpServiceRunning = data[serviceKey]; if (isWarpServiceRunning) { $("#warp_initial_controls").hide(); $("#warp_active_controls").show(); @@ -691,22 +694,26 @@ } else { $("#warp_initial_controls").show(); $("#warp_active_controls").hide(); - $("#warp_config_form")[0].reset(); + if ($("#warp_config_form").length > 0) { + $("#warp_config_form")[0].reset(); + } } } else { const $formSelector = $(targetSelector); - if (isRunning) { - $formSelector.find(".form-group").hide(); - $formSelector.find(".btn-success").hide(); - $formSelector.find(".btn-danger").show(); - if ($formSelector.find(".alert-info").length === 0) { - $formSelector.prepend(`