From 55354d3270da3776694d8253dc6a75158726c0d3 Mon Sep 17 00:00:00 2001 From: Denozordec Date: Tue, 31 Mar 2026 17:18:23 +0700 Subject: [PATCH] Enhance Mihomo proxy groups component with improved data handling and UI updates - Introduced a stable order for selectable proxy groups to minimize DOM changes during JSON updates. - Added a refresh icon to the update button for better user feedback during loading states. - Enhanced error handling to prevent UI flickering when fetching proxy data. - Updated layout in the Mihomo page to utilize a grid system for better responsiveness and organization. --- .../mihomo/mihomo-proxy-groups.svelte | 25 ++++++++++++++++--- web/src/routes/mihomo/+page.svelte | 6 +++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/web/src/lib/components/mihomo/mihomo-proxy-groups.svelte b/web/src/lib/components/mihomo/mihomo-proxy-groups.svelte index 9e1a002..df207ec 100644 --- a/web/src/lib/components/mihomo/mihomo-proxy-groups.svelte +++ b/web/src/lib/components/mihomo/mihomo-proxy-groups.svelte @@ -6,6 +6,7 @@ import DataQueryState from '$lib/components/fleet/data-query-state.svelte'; import { Skeleton } from '$lib/components/ui/skeleton/index.js'; import { cn } from '$lib/utils.js'; + import RefreshCwIcon from '@lucide/svelte/icons/refresh-cw'; let { alias, @@ -39,8 +40,8 @@ try { proxiesData = await fetchMihomoJson(a, 'proxies'); } catch (e) { - proxiesData = null; proxiesErr = e instanceof ApiError ? e.message : String(e); + // не затираем успешный снимок при сбое обновления — без мерцания UI } finally { proxiesLoading = false; } @@ -59,6 +60,15 @@ return false; } + /** Стабильный порядок групп — меньше скачков DOM при обновлении JSON. */ + let selectableGroups = $derived.by((): [string, MihomoProxyEntry][] => { + const p = proxiesData?.proxies; + if (!p) return []; + return Object.entries(p) + .filter(([_, v]) => isSelectableGroup(v)) + .sort(([a], [b]) => a.localeCompare(b)); + }); + function lastDelay(p: MihomoProxyEntry): number | null { const h = p.history; if (!h?.length) return null; @@ -139,11 +149,20 @@ onclick={() => loadProxies()} disabled={proxiesLoading || !alias} > +