feat(app): 实现用户管理页面功能

- 修复用户列表分页参数获取错误的问题
- 添加搜索和角色筛选功能
- 实现批量删除和封禁用户操作
- 优化页面布局和样式
- 添加调试日志输出
- 更新图标资源库
- 修复API客户端请求头传递问题
- 调整侧边栏导航样式和结构
- 减少模拟数据加载时间
- 添加COOKIE常量引用
This commit is contained in:
Chaos
2025-12-02 11:45:38 +08:00
parent ab43a9a140
commit 4cdf6bade8
10 changed files with 344 additions and 410 deletions

View File

@@ -1,8 +1,9 @@
import { ofetch, type FetchOptions, type SearchParameters } from 'ofetch';
import { log } from '$lib/log';
import { COOKIE_TOKEN_KEY } from '$lib/components/constants/cookiesConstants.ts';
// 1. 定义更安全的类型,替代 any
type QueryParams = SearchParameters; // 使用 ofetch 内置的查询参数类型,或者自定义 Record<string, string | number | boolean>
type QueryParams = SearchParameters;
type RequestBody = Record<string, unknown> | FormData | unknown[]; // 替代 any使用 unknown
export interface ApiResult<T> {
@@ -19,12 +20,14 @@ const client = ofetch.create({
onRequest({ options, request }) {
log.debug(`[API] ${options.method} ${request}`, {
body: options.body as unknown, // 类型断言为 unknown 避免隐式 any
headers: options.headers,
query: options.query
});
},
onResponseError({ request, response }) {
log.error(`[API] Error ${request}`, {
status: response.status,
headers: response.headers,
data: response._data as unknown
});
}