Commit 1acd91b5 authored by 陈前坚's avatar 陈前坚

perf: log

parent eaa833ea
This diff is collapsed.
...@@ -28,9 +28,14 @@ const ServiceLog = () => { ...@@ -28,9 +28,14 @@ const ServiceLog = () => {
moment(new Date(), 'YYYY-MM-DD HH:mm:ss'), // 默认值当前时间 moment(new Date(), 'YYYY-MM-DD HH:mm:ss'), // 默认值当前时间
); );
const [logType, setLogType] = useState(0); // 请求参数,日志类型,默认是正常,0:成功 -1:错误 9999:全部 const [logType, setLogType] = useState(0); // 请求参数,日志类型,默认是正常,0:成功 -1:错误 9999:全部
const [tableColumns, setTableColumns] = useState([]); // 源数据
const columns11 = [ const columns = [
{
title: '接口名称',
dataIndex: 'Path',
key: 'Path',
fixed: 'left',
},
{ {
title: '调用时间', title: '调用时间',
dataIndex: 'CallTime', dataIndex: 'CallTime',
...@@ -43,42 +48,36 @@ const ServiceLog = () => { ...@@ -43,42 +48,36 @@ const ServiceLog = () => {
dataIndex: 'IP', dataIndex: 'IP',
key: 'IP', key: 'IP',
}, },
{
title: '接口名称',
dataIndex: 'Path',
key: 'Path',
width: 200,
ellipsis: true,
},
{ {
title: '请求方法', title: '请求方法',
dataIndex: 'Method', dataIndex: 'Method',
key: 'Method', key: 'Method',
ellipsis: true,
}, },
{ {
title: '查询参数', title: '查询参数',
dataIndex: 'QueryString', dataIndex: 'QueryString',
key: 'QueryString', key: 'QueryString',
width: 150,
ellipsis: true,
}, },
{ {
title: '请求体', title: '请求体',
dataIndex: 'Body', dataIndex: 'Body',
key: 'Body', key: 'Body',
width: 200,
ellipsis: true,
}, },
{ {
title: '状态码', title: '状态码',
dataIndex: 'Result', dataIndex: 'Result',
key: 'Result', key: 'Result',
}, },
{
title: '错误信息',
dataIndex: 'ErrorMsg',
key: 'ErrorMsg',
},
{ {
title: '耗时/ms', title: '耗时/ms',
dataIndex: 'ConsumerTime', dataIndex: 'ConsumerTime',
key: 'ConsumerTime', key: 'ConsumerTime',
fixed: 'right',
defaultSortOrder: 'descend', defaultSortOrder: 'descend',
sorter: (a, b) => a.ConsumerTime - b.ConsumerTime, sorter: (a, b) => a.ConsumerTime - b.ConsumerTime,
}, },
...@@ -86,16 +85,9 @@ const ServiceLog = () => { ...@@ -86,16 +85,9 @@ const ServiceLog = () => {
title: '返回体大小/byte', title: '返回体大小/byte',
dataIndex: 'ResponseSize', dataIndex: 'ResponseSize',
key: 'ResponseSize', key: 'ResponseSize',
ellipsis: true, fixed: 'right',
sorter: (a, b) => a.ResponseSize - b.ResponseSize, sorter: (a, b) => a.ResponseSize - b.ResponseSize,
}, },
{
title: '错误信息',
dataIndex: 'ErrorMsg',
key: 'ErrorMsg',
width: 200,
ellipsis: true,
},
]; ];
// 在起止时间任意一个变化后获取数据 // 在起止时间任意一个变化后获取数据
useEffect(() => { useEffect(() => {
...@@ -110,8 +102,6 @@ const ServiceLog = () => { ...@@ -110,8 +102,6 @@ const ServiceLog = () => {
PageSize: 0, PageSize: 0,
DateFrom: startTime.format('YYYY-MM-DD HH:mm:ss'), DateFrom: startTime.format('YYYY-MM-DD HH:mm:ss'),
DateTo: endTime.format('YYYY-MM-DD HH:mm:ss'), DateTo: endTime.format('YYYY-MM-DD HH:mm:ss'),
// HourFrom: startTime.format('HH:mm:ss'),
// HourTo: endTime.format('HH:mm:ss'),
IP: '', IP: '',
Module: '', Module: '',
LogType: +logType, LogType: +logType,
...@@ -142,29 +132,7 @@ const ServiceLog = () => { ...@@ -142,29 +132,7 @@ const ServiceLog = () => {
item.key = index; item.key = index;
return item; return item;
}); });
// const columns = Object.keys(data[0]).map(key => {
// if (key === 'ResponseSize') {
// return {
// title: key,
// dataIndex: key,
// key,
// defaultSortOrder: 'descend',
// sorter: (a, b) => a.ResponseSize - b.ResponseSize,
// };
// }
// if (key === 'Body' || key === 'QueryString' || key === 'Path') {
// return {
// title: key,
// dataIndex: key,
// key,
// width: 150,
// ellipsis: true,
// };
// }
// return { title: key, dataIndex: key, key };
// });
// setTableColumns(columns);
// console.log(Object.keys(data[0]));
const scale1 = { const scale1 = {
Path: { Path: {
alias: '接口名称', // 别名 alias: '接口名称', // 别名
...@@ -234,9 +202,16 @@ const ServiceLog = () => { ...@@ -234,9 +202,16 @@ const ServiceLog = () => {
return ( return (
<> <>
<Row style={{ padding: '10px', background: 'white' }}> <Row
style={{
padding: '10px',
background: 'white',
marginBottom: '2px',
minWidth: '1030px',
}}
>
<Col span={24}> <Col span={24}>
<span style={{ lineHeight: 2 }}>时间:</span> <span>时间:</span>
<DatePicker <DatePicker
showTime showTime
format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
...@@ -245,7 +220,7 @@ const ServiceLog = () => { ...@@ -245,7 +220,7 @@ const ServiceLog = () => {
onChange={changeStartTime} onChange={changeStartTime}
allowClear={false} allowClear={false}
/> />
<SwapRightOutlined style={{ lineHeight: 2 }} /> <SwapRightOutlined style={{ verticalAlign: '0.125em' }} />
<DatePicker <DatePicker
showTime showTime
format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
...@@ -260,7 +235,7 @@ const ServiceLog = () => { ...@@ -260,7 +235,7 @@ const ServiceLog = () => {
<Button onClick={() => setTime(12)}>12小时</Button> <Button onClick={() => setTime(12)}>12小时</Button>
<Button onClick={() => setTime(24)}>1</Button> <Button onClick={() => setTime(24)}>1</Button>
<Button onClick={() => setTime(24 * 7)}>1</Button> <Button onClick={() => setTime(24 * 7)}>1</Button>
<span style={{ lineHeight: 2, marginLeft: '20px' }}>日志类型:</span> <span style={{ marginLeft: '20px' }}>日志类型:</span>
<Select defaultValue="正常" onChange={selectChange}> <Select defaultValue="正常" onChange={selectChange}>
<Option value="9999">全部</Option> <Option value="9999">全部</Option>
<Option value="0">正常</Option> <Option value="0">正常</Option>
...@@ -269,10 +244,10 @@ const ServiceLog = () => { ...@@ -269,10 +244,10 @@ const ServiceLog = () => {
</Col> </Col>
</Row> </Row>
<Spin spinning={loading} tip="loading"> <Spin spinning={loading} tip="loading">
<Row style={{ padding: '10px', background: 'white' }}> <Row style={{ padding: '16px', background: 'white' }}>
<Col span={12}> <Col span={12}>
<Chart <Chart
height={316} height={300}
width={400} width={400}
autoFit autoFit
data={pathCount} data={pathCount}
...@@ -293,7 +268,7 @@ const ServiceLog = () => { ...@@ -293,7 +268,7 @@ const ServiceLog = () => {
</Col> </Col>
<Col span={12}> <Col span={12}>
<Chart <Chart
height={316} height={300}
width={400} width={400}
autoFit autoFit
data={reponseTime} data={reponseTime}
...@@ -315,7 +290,7 @@ const ServiceLog = () => { ...@@ -315,7 +290,7 @@ const ServiceLog = () => {
<Table <Table
size="small" size="small"
bordered bordered
columns={columns11} columns={columns}
dataSource={data0} dataSource={data0}
scroll={{ x: 'max-content' }} scroll={{ x: 'max-content' }}
pagination={{ pagination={{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment