From 93f3b6b7ab87a7b8c8406b720a20b6bc7fe53618 Mon Sep 17 00:00:00 2001 From: LTbinglingfeng Date: Sat, 13 Jun 2026 02:06:14 +0800 Subject: [PATCH] perf(auth-files): sort locally without refetching the file list Sorting is computed in a useMemo over already-loaded files; changing the sort mode does not need a network round-trip. Also drop a duplicated property read in the priority comparator. --- src/pages/AuthFilesPage.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pages/AuthFilesPage.tsx b/src/pages/AuthFilesPage.tsx index 3f1123d..5b4c498 100644 --- a/src/pages/AuthFilesPage.tsx +++ b/src/pages/AuthFilesPage.tsx @@ -321,9 +321,8 @@ export function AuthFilesPage() { if (!isAuthFilesSortMode(value) || value === sortMode) return; setSortMode(value); setPage(1); - void loadFiles().catch(() => {}); }, - [loadFiles, sortMode] + [sortMode] ); const handleHeaderRefresh = useCallback(async () => { @@ -419,8 +418,8 @@ export function AuthFilesPage() { copy.sort((a, b) => a.name.localeCompare(b.name)); } else if (sortMode === 'priority') { copy.sort((a, b) => { - const pa = parsePriorityValue(a.priority ?? a['priority']) ?? 0; - const pb = parsePriorityValue(b.priority ?? b['priority']) ?? 0; + const pa = parsePriorityValue(a.priority) ?? 0; + const pb = parsePriorityValue(b.priority) ?? 0; return pb - pa; // 高优先级排前面 }); }