feat(admin): 新增模板管理功能并完善用户认证
- 新增模板管理模块,包含模板列表和详情页面 - 重构用户认证逻辑,支持用户ID存储和API调用 - 新增排行榜API接口和类型定义 - 更新环境配置,添加开发环境配置 - 优化表格操作钩子,增强类型安全性 - 新增文件上传工具类和验证工具函数 - 更新路由配置,支持模板详情页面导航 - 修复登录表单默认值问题
This commit is contained in:
@ -176,7 +176,18 @@ export function useTableOperate<TableData>(
|
||||
data: Ref<TableData[]>,
|
||||
idKey: keyof TableData,
|
||||
getData: () => Promise<void>,
|
||||
) {
|
||||
): {
|
||||
drawerVisible: Ref<boolean>
|
||||
openDrawer: () => void
|
||||
closeDrawer: () => void
|
||||
operateType: Ref<NaiveUI.TableOperateType>
|
||||
handleAdd: () => void
|
||||
editingData: Ref<TableData | null>
|
||||
handleEdit: (id: TableData[keyof TableData]) => void
|
||||
checkedRowKeys: Ref<string[]>
|
||||
onBatchDeleted: () => Promise<void>
|
||||
onDeleted: () => Promise<void>
|
||||
} {
|
||||
const { bool: drawerVisible, setTrue: openDrawer, setFalse: closeDrawer } = useBoolean()
|
||||
|
||||
const operateType = shallowRef<NaiveUI.TableOperateType>('add')
|
||||
@ -230,17 +241,23 @@ export function useTableOperate<TableData>(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认的表格数据转换函数
|
||||
*
|
||||
* @param response 原始的 API 响应数据
|
||||
* @returns 转换后的分页数据
|
||||
*/
|
||||
export function defaultTransform<ApiData>(
|
||||
response: FlatResponseData<any, Api.Common.PaginatingQueryRecord<ApiData>>,
|
||||
): PaginationData<ApiData> {
|
||||
const { data, error } = response
|
||||
|
||||
if (!error) {
|
||||
const { records, current, size, total } = data
|
||||
const { list, currentPage: pageNum, pageSize: size, total } = data
|
||||
|
||||
return {
|
||||
data: records,
|
||||
pageNum: current,
|
||||
data: list,
|
||||
pageNum,
|
||||
pageSize: size,
|
||||
total,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user