diff --git a/frontend/mining-admin-web/src/app/(dashboard)/audit-logs/page.tsx b/frontend/mining-admin-web/src/app/(dashboard)/audit-logs/page.tsx index 47d1378b..5d1db1aa 100644 --- a/frontend/mining-admin-web/src/app/(dashboard)/audit-logs/page.tsx +++ b/frontend/mining-admin-web/src/app/(dashboard)/audit-logs/page.tsx @@ -36,20 +36,22 @@ const actionLabels: Record = { export default function AuditLogsPage() { const [page, setPage] = useState(1); - const [action, setAction] = useState(''); + const [action, setAction] = useState('all'); const [keyword, setKeyword] = useState(''); const pageSize = 20; - const { data, isLoading } = useQuery({ + const { data, isLoading, error } = useQuery({ queryKey: ['audit-logs', page, action, keyword], queryFn: async () => { const response = await apiClient.get('/audit', { - params: { page, pageSize, action: action || undefined, keyword: keyword || undefined }, + params: { page, pageSize, action: action === 'all' ? undefined : action, keyword: keyword || undefined }, }); return response.data.data as PaginatedResponse; }, }); + const items = data?.items ?? []; + return (
@@ -71,7 +73,7 @@ export default function AuditLogsPage() { - 全部 + 全部 创建 更新 删除 @@ -108,14 +110,14 @@ export default function AuditLogsPage() { ))} )) - ) : data?.items.length === 0 ? ( + ) : items.length === 0 ? ( 暂无日志 ) : ( - data?.items.map((log) => { + items.map((log) => { const actionInfo = actionLabels[log.action] || { label: log.action, className: '' }; return (