mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-06-16 21:03:58 +08:00
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:
@@ -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; // 高优先级排前面
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user