diff --git a/vite-frontend/src/pages/config.tsx b/vite-frontend/src/pages/config.tsx
index 4a005a1..00af8a1 100644
--- a/vite-frontend/src/pages/config.tsx
+++ b/vite-frontend/src/pages/config.tsx
@@ -124,6 +124,12 @@ const CONFIG_ITEMS: ConfigItem[] = [
description: "开启后,规则页面列表使用 2.1.6-alpha8 样式(全局配置)",
type: "switch",
},
+ {
+ key: "monitor_tunnel_quality_enabled",
+ label: "实时隧道质量检测",
+ description: "关闭后,前端停止自动刷新,后端停止实时隧道质量探测(全局配置)",
+ type: "switch",
+ },
{
key: "captcha_enabled",
label: "启用验证码",
@@ -175,6 +181,7 @@ const getInitialConfigs = (): Record => {
"cloudflare_site_key",
"cloudflare_secret_key",
"forward_compact_mode",
+ "monitor_tunnel_quality_enabled",
"ip",
"panel_domain",
"app_logo",
@@ -407,6 +414,15 @@ export default function ConfigPage() {
detail: { changedKeys },
}),
);
+
+ // 如果隧道质量检测开关变更,通知 tunnel-monitor-view
+ if (changedKeys.includes("monitor_tunnel_quality_enabled")) {
+ window.dispatchEvent(
+ new CustomEvent("monitorTunnelQualityEnabledChanged", {
+ detail: { enabled: configs["monitor_tunnel_quality_enabled"] === "true" },
+ }),
+ );
+ }
} else {
toast.error("保存配置失败: " + response.msg);
}
diff --git a/vite-frontend/src/pages/settings.tsx b/vite-frontend/src/pages/settings.tsx
index 0f4d1ce..63dc0a7 100644
--- a/vite-frontend/src/pages/settings.tsx
+++ b/vite-frontend/src/pages/settings.tsx
@@ -31,9 +31,6 @@ interface PanelAddress {
}
const FORWARD_COMPACT_MODE_CONFIG_KEY = "forward_compact_mode";
-const MONITOR_TUNNEL_QUALITY_ENABLED_CONFIG_KEY = "monitor_tunnel_quality_enabled";
-const MONITOR_TUNNEL_QUALITY_ENABLED_EVENT =
- "monitorTunnelQualityEnabledChanged";
const parseBooleanConfig = (value: unknown, defaultValue: boolean) =>
typeof value === "string" ? value === "true" : defaultValue;
@@ -49,10 +46,6 @@ export const SettingsPage = () => {
const [forwardCompactMode, setForwardCompactMode] = useState(false);
const [forwardCompactModeSaving, setForwardCompactModeSaving] =
useState(false);
- const [monitorTunnelQualityEnabled, setMonitorTunnelQualityEnabled] =
- useState(true);
- const [monitorTunnelQualitySaving, setMonitorTunnelQualitySaving] =
- useState(false);
const admin = isAdmin();
@@ -112,7 +105,6 @@ export const SettingsPage = () => {
useEffect(() => {
loadPanelAddresses();
loadForwardCompactMode();
- loadMonitorTunnelQualityEnabled();
}, []);
const loadForwardCompactMode = async () => {
@@ -124,15 +116,6 @@ export const SettingsPage = () => {
}
};
- const loadMonitorTunnelQualityEnabled = async () => {
- try {
- const res = await getConfigByName(MONITOR_TUNNEL_QUALITY_ENABLED_CONFIG_KEY);
- setMonitorTunnelQualityEnabled(parseBooleanConfig(res.data?.value, true));
- } catch {
- setMonitorTunnelQualityEnabled(true);
- }
- };
-
const handleForwardCompactModeChange = async (enabled: boolean) => {
if (!admin || forwardCompactModeSaving) {
return;
@@ -167,40 +150,6 @@ export const SettingsPage = () => {
}
};
- const handleMonitorTunnelQualityEnabledChange = async (enabled: boolean) => {
- if (!admin || monitorTunnelQualitySaving) {
- return;
- }
-
- const previous = monitorTunnelQualityEnabled;
-
- setMonitorTunnelQualityEnabled(enabled);
- setMonitorTunnelQualitySaving(true);
- try {
- const response = await updateConfig(
- MONITOR_TUNNEL_QUALITY_ENABLED_CONFIG_KEY,
- enabled ? "true" : "false",
- );
-
- if (response.code === 0) {
- toast.success(`实时隧道质量检测已${enabled ? "开启" : "关闭"}`);
- window.dispatchEvent(
- new CustomEvent(MONITOR_TUNNEL_QUALITY_ENABLED_EVENT, {
- detail: { enabled },
- }),
- );
- } else {
- setMonitorTunnelQualityEnabled(previous);
- toast.error(response.msg || "保存隧道质量检测配置失败");
- }
- } catch {
- setMonitorTunnelQualityEnabled(previous);
- toast.error("保存隧道质量检测配置失败");
- } finally {
- setMonitorTunnelQualitySaving(false);
- }
- };
-
const handleUpdateChannelChange = (channel: UpdateReleaseChannel) => {
setUpdateChannel(channel);
setUpdateReleaseChannel(channel);
@@ -293,30 +242,6 @@ export const SettingsPage = () => {
)}
-
-
-
-
-
- 实时隧道质量检测
-
-
- 关闭后,前端停止自动刷新,后端停止实时隧道质量探测。
-
-
-
-
- {!admin && (
-
- 仅管理员可修改该全局配置。
-
- )}
-