feat: add user management features including user creation, editing, and role management

- Implemented user API functions for fetching, creating, updating, and managing users.
- Created a UsersPage component for displaying and managing users with search and pagination.
- Added types for user data and mutation payloads.
- Introduced a LegacyRouteRedirect component for handling legacy routes.
- Defined settings-related types for better type safety in settings management.
This commit is contained in:
ryan
2026-03-11 15:40:41 +08:00
parent 13cc880f67
commit 4f8970ff5c
30 changed files with 2577 additions and 99 deletions
+7 -4
View File
@@ -17,12 +17,15 @@ export function getApiUrl(path: string) {
}
export async function apiRequest<T>(path: string, init?: RequestInit) {
const headers = new Headers(init?.headers ?? {});
if (!(init?.body instanceof FormData) && !headers.has('Content-Type')) {
headers.set('Content-Type', 'application/json');
}
const response = await fetch(getApiUrl(path), {
credentials: 'include',
headers: {
'Content-Type': 'application/json',
...(init?.headers ?? {}),
},
headers,
...init,
});
+3 -3
View File
@@ -47,18 +47,18 @@ export const dashboardNavigation: NavigationItem[] = [
href: '/files',
label: '文件管理',
shortLabel: '文件',
description: '阶段 4 接入列表、下载与管理动作。',
description: '已接入上传、下载、复制链接、搜索与删除动作。',
},
{
href: '/users',
label: '用户管理',
shortLabel: '用户',
description: '阶段 4 接入用户列表、角色与搜索体验。',
description: '已接入搜索、创建、编辑、封禁与权限调整。',
},
{
href: '/settings',
label: '设置',
shortLabel: '设置',
description: '阶段 4 接入系统设置、运维设置与个人设置。',
description: '已接入个人、运维、系统与关于内容维护。',
},
];
+2 -1
View File
@@ -17,7 +17,8 @@ function toDate(value: string | Date | null | undefined) {
return null;
}
const date = value instanceof Date ? value : new Date(value);
const normalizedValue = typeof value === 'string' ? value.replace(' ', 'T') : value;
const date = normalizedValue instanceof Date ? normalizedValue : new Date(normalizedValue);
return Number.isNaN(date.getTime()) ? null : date;
}