From 99687f9b45ea51ee1de8cb647a0ec3a64b8f7ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=9A=E8=BE=B0=E5=85=88=E7=94=9F?= Date: Sat, 30 Nov 2024 22:14:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/hooks/useTableData.ts | 11 ++++++++--- frontend/src/pages/System/User/index.tsx | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/src/hooks/useTableData.ts b/frontend/src/hooks/useTableData.ts index 59721af9..692f3cb8 100644 --- a/frontend/src/hooks/useTableData.ts +++ b/frontend/src/hooks/useTableData.ts @@ -10,7 +10,12 @@ export interface TableService { baseUrl: string; // 基础URL } -export function useTableData({ +interface SortParams { + sortField?: string; + sortOrder?: 'ascend' | 'descend'; +} + +export function useTableData({ service, defaultParams, config = {} @@ -40,10 +45,10 @@ export function useTableData({ setState(prev => ({ ...prev, - list: pageData?.content || [], + list: pageData.content || [], pagination: { ...prev.pagination, - total: pageData?.totalElements || 0 + total: pageData.totalElements || 0 }, loading: false })); diff --git a/frontend/src/pages/System/User/index.tsx b/frontend/src/pages/System/User/index.tsx index 36ea28ac..655d5d79 100644 --- a/frontend/src/pages/System/User/index.tsx +++ b/frontend/src/pages/System/User/index.tsx @@ -113,7 +113,8 @@ const UserPage: React.FC = () => { dataIndex: 'id', key: 'id', width: 60, - fixed: 'left' as FixedType + fixed: 'left' as FixedType, + sorter: true }, { title: '用户名', @@ -162,6 +163,7 @@ const UserPage: React.FC = () => { dataIndex: 'updateTime', key: 'updateTime', width: 150, + sorter: true }, { title: '状态',