mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
feat(misc-viewer): optional delay check interval
This commit is contained in:
@@ -47,7 +47,7 @@ const STORAGE_KEY_PROXY = "clash-verge-selected-proxy";
|
||||
const STORAGE_KEY_SORT_TYPE = "clash-verge-proxy-sort-type";
|
||||
|
||||
const AUTO_CHECK_INITIAL_DELAY_MS = 1500;
|
||||
const AUTO_CHECK_INTERVAL_MS = 5 * 60 * 1000;
|
||||
const AUTO_CHECK_DEFAULT_INTERVAL_MINUTES = 5;
|
||||
|
||||
// 代理节点信息接口
|
||||
interface ProxyOption {
|
||||
@@ -106,6 +106,14 @@ export const CurrentProxyCard = () => {
|
||||
const { current: currentProfile } = useProfiles();
|
||||
const autoDelayEnabled = verge?.enable_auto_delay_detection ?? false;
|
||||
const defaultLatencyTimeout = verge?.default_latency_timeout;
|
||||
const autoDelayIntervalMs = useMemo(() => {
|
||||
const rawInterval = verge?.auto_delay_detection_interval_minutes;
|
||||
const intervalMinutes =
|
||||
typeof rawInterval === "number" && rawInterval > 0
|
||||
? rawInterval
|
||||
: AUTO_CHECK_DEFAULT_INTERVAL_MINUTES;
|
||||
return Math.max(1, Math.round(intervalMinutes)) * 60 * 1000;
|
||||
}, [verge?.auto_delay_detection_interval_minutes]);
|
||||
const currentProfileId = currentProfile?.uid || null;
|
||||
|
||||
const getProfileStorageKey = useCallback(
|
||||
@@ -592,13 +600,13 @@ export const CurrentProxyCard = () => {
|
||||
if (disposed) return;
|
||||
await checkCurrentProxyDelay();
|
||||
if (disposed) return;
|
||||
intervalTimer = setTimeout(runAndSchedule, AUTO_CHECK_INTERVAL_MS);
|
||||
intervalTimer = setTimeout(runAndSchedule, autoDelayIntervalMs);
|
||||
};
|
||||
|
||||
initialTimer = setTimeout(async () => {
|
||||
await checkCurrentProxyDelay();
|
||||
if (disposed) return;
|
||||
intervalTimer = setTimeout(runAndSchedule, AUTO_CHECK_INTERVAL_MS);
|
||||
intervalTimer = setTimeout(runAndSchedule, autoDelayIntervalMs);
|
||||
}, AUTO_CHECK_INITIAL_DELAY_MS);
|
||||
|
||||
return () => {
|
||||
@@ -608,6 +616,7 @@ export const CurrentProxyCard = () => {
|
||||
};
|
||||
}, [
|
||||
checkCurrentProxyDelay,
|
||||
autoDelayIntervalMs,
|
||||
isDirectMode,
|
||||
state.selection.group,
|
||||
state.selection.proxy,
|
||||
|
||||
Reference in New Issue
Block a user