From 9085d907cd06bebed8f7f1804bb6ecbb5e920cca Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Mon, 24 Aug 2026 18:42:49 +0800 Subject: [PATCH] perf: reduce idle backend work --- src-tauri/src/core/service.rs | 2 +- src-tauri/src/utils/tray_speed.rs | 5 ++++- src/providers/app-data-provider.tsx | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/core/service.rs b/src-tauri/src/core/service.rs index 74d58b947..77cc942d9 100644 --- a/src-tauri/src/core/service.rs +++ b/src-tauri/src/core/service.rs @@ -1067,7 +1067,7 @@ fn mark_service_unavailable_after_owner_loss(store: &RunStateSto } /// How often the owner monitor samples Service status. -const OWNER_MONITOR_INTERVAL: Duration = Duration::from_secs(2); +const OWNER_MONITOR_INTERVAL: Duration = Duration::from_secs(5); /// Mirrors `OwnerWatch`'s tolerance, for the log line only. const SUSTAINED_OWNER_SAMPLES: u8 = 3; diff --git a/src-tauri/src/utils/tray_speed.rs b/src-tauri/src/utils/tray_speed.rs index 7f11c7124..8223ea3fc 100644 --- a/src-tauri/src/utils/tray_speed.rs +++ b/src-tauri/src/utils/tray_speed.rs @@ -101,7 +101,10 @@ fn apply_status_item_attributed_title(status_item: &NSStatusItem, text: &NSStrin let attrs = build_attributes(button.bounds().size.height); let attrs: &NSDictionary = &attrs; let attr_str = create_attributed_string(text, Some(attrs)); - status_item.setLength(status_item_length_for_speed(&attr_str)); + let length = status_item_length_for_speed(&attr_str); + if status_item.length() != length { + status_item.setLength(length); + } attr_str } else { create_attributed_string(text, None) diff --git a/src/providers/app-data-provider.tsx b/src/providers/app-data-provider.tsx index b28a173bb..68c04a475 100644 --- a/src/providers/app-data-provider.tsx +++ b/src/providers/app-data-provider.tsx @@ -67,7 +67,7 @@ export const AppDataProvider = ({ } = useQuery({ queryKey: ['getProxyView'], queryFn: getProxyView, - refetchInterval: 3000, + refetchInterval: 15000, refetchIntervalInBackground: false, ...TQ_MIHOMO, })