From ae73ecfd92eb604bc8936417d40de864de777980 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Sun, 5 Nov 2023 22:54:55 +0800 Subject: [PATCH] Optimize log page --- src/assets/css/components/common/card.scss | 2 +- src/global.d.ts | 1 + src/pages/system/Log.tsx | 62 +++++++++++++++------- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/assets/css/components/common/card.scss b/src/assets/css/components/common/card.scss index 7b78684..8daf288 100644 --- a/src/assets/css/components/common/card.scss +++ b/src/assets/css/components/common/card.scss @@ -4,5 +4,5 @@ background-color: constants.$origin-color; border-radius: 8px; overflow: hidden; - box-shadow: 5px 5px 10px 0 rgba(0,0,0,0.1); + box-shadow: 5px 5px 15px 0 rgba(0,0,0,0.1); } \ No newline at end of file diff --git a/src/global.d.ts b/src/global.d.ts index cdc11bb..47e0779 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -182,4 +182,5 @@ interface SysLogGetVo { endTime: string executeTime: number userAgent: string + operateUsername: string } diff --git a/src/pages/system/Log.tsx b/src/pages/system/Log.tsx index ae7ec32..24d6056 100644 --- a/src/pages/system/Log.tsx +++ b/src/pages/system/Log.tsx @@ -21,44 +21,68 @@ const Log: React.FC = () => { }) const dataColumns: ColumnsType = [ - { title: '类型', dataIndex: 'logType' }, + { + title: '类型', + dataIndex: 'logType', + render: (value) => + value === 'ERROR' ? ( + {value} + ) : ( + {value} + ), + align: 'center' + }, { title: '操作者', - dataIndex: 'operateUserId' + dataIndex: 'operateUsername', + align: 'center', + render: (value, record) => + value ? ( + {`${value}(${record.operateUserId})`} + ) : ( + Anonymous + ) }, { title: '操作时间', dataIndex: 'operateTime', - render: (value) => getLocalTime(value) - }, - { - title: '请求 Uri', - dataIndex: 'requestUri' + render: (value: string) => getLocalTime(value), + align: 'center' }, { title: '请求方式', - dataIndex: 'requestMethod' + dataIndex: 'requestMethod', + align: 'center' }, { - title: '请求参数', - dataIndex: 'requestParams' + title: '请求 Url', + render: (_value, record) => + `${record.requestServerAddress}${record.requestUri}${ + record.requestParams ? `?${record.requestParams}` : '' + }` }, { title: '请求 IP', - dataIndex: 'requestIp' + dataIndex: 'requestIp', + align: 'center' }, { - title: '请求服务器地址', - dataIndex: 'requestServerAddress' - }, - { - title: '异常信息', - dataIndex: 'exceptionInfo' + title: '异常', + dataIndex: 'exception', + render: (value: boolean, record) => (value ? record.exceptionInfo : '无'), + align: 'center' }, { title: '执行时间', dataIndex: 'executeTime', - render: (value) => `${value}ms` + render: (value, record) => ( + + {`${value}ms`} + + ), + align: 'center' }, { title: '用户代理', @@ -83,7 +107,7 @@ const Log: React.FC = () => { return } - r_getSysLog({ + void r_getSysLog({ currentPage: tableParams.pagination?.current, pageSize: tableParams.pagination?.pageSize })