fix: 优化后台体验与导出日志交互

This commit is contained in:
Nixevol
2026-07-05 00:04:35 +08:00
parent 935375a904
commit 4122897725
44 changed files with 798 additions and 221 deletions
+18
View File
@@ -0,0 +1,18 @@
export type SortOrderInput = 'ascend' | 'descend' | 'asc' | 'desc' | undefined;
export function normalizeSortOrder(order: SortOrderInput): 'asc' | 'desc' | null {
if (order === 'asc' || order === 'ascend') return 'asc';
if (order === 'desc' || order === 'descend') return 'desc';
return null;
}
export function buildOrderBy<T extends string>(
field: string | undefined,
order: SortOrderInput,
allowed: readonly T[],
fallback: Record<string, 'asc' | 'desc'>,
): Record<string, 'asc' | 'desc'> {
const normalized = normalizeSortOrder(order);
if (!field || !normalized || !allowed.includes(field as T)) return fallback;
return { [field]: normalized };
}