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.
This commit is contained in:
LTbinglingfeng
2026-06-13 02:06:14 +08:00
Unverified
parent 521350505d
commit 93f3b6b7ab
+3 -4
View File
@@ -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; // 高优先级排前面
});
}