Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivManage
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivManage
Commits
51f69593
Commit
51f69593
authored
Dec 01, 2020
by
陈前坚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: log
parent
d27c7e8d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
14 deletions
+39
-14
index.js
src/pages/log/serviceLog/index.js
+39
-14
No files found.
src/pages/log/serviceLog/index.js
View file @
51f69593
...
...
@@ -24,14 +24,31 @@ const ServiceLog = () => {
const
[
pathCount
,
setPathCount
]
=
useState
([]);
// 接口调用次数,统计数据
const
[
reponseTime
,
setReponseTime
]
=
useState
([]);
// 接口调用时长,统计数据
const
[
perMinute
,
setPerMinute
]
=
useState
([]);
// 每分钟访问量,统计数据
const
[
timeIn
rerval
,
setTimeInrerval
]
=
useState
(
'每小时
'
);
const
[
timeIn
terval
,
setTimeInterval
]
=
useState
(
'60
'
);
const
[
scale
,
setScale
]
=
useState
({});
// 坐标轴别名
const
[
startTime
,
setStartTime
]
=
useState
(
moment
().
startOf
(
'day'
));
// 默认值当天0点
const
[
startTime
,
setStartTime
]
=
useState
(
moment
().
startOf
(
'day'
));
// 默认值当天0点
00:00:00
const
[
endTime
,
setEndTime
]
=
useState
(
moment
(
new
Date
(),
'YYYY-MM-DD HH:mm:ss'
),
// 默认值当前时间
);
const
[
logType
,
setLogType
]
=
useState
(
0
);
// 请求参数,日志类型,默认是正常,0:成功 -1:错误 9999:全部
// 计算时间间隔(分钟)
const
countInterval
=
()
=>
{
const
start
=
new
Date
(
startTime
.
format
(
'YYYY-MM-DD HH:mm:ss'
)).
getTime
();
const
end
=
new
Date
(
endTime
.
format
(
'YYYY-MM-DD HH:mm:ss'
)).
getTime
();
const
minuteInterval
=
(
end
-
start
)
/
(
60
*
1000
);
// 相隔多少分钟
// console.log(hourInterval);
if
(
minuteInterval
<=
30
)
{
setTimeInterval
(
'1'
);
}
else
if
(
minuteInterval
>
30
&&
minuteInterval
<=
120
)
{
setTimeInterval
(
'5'
);
}
else
if
(
minuteInterval
>
120
&&
minuteInterval
<=
60
*
24
)
{
setTimeInterval
(
'60'
);
}
else
{
setTimeInterval
(
'1440'
);
}
};
const
columns
=
[
{
title
:
'接口名称'
,
...
...
@@ -100,6 +117,7 @@ const ServiceLog = () => {
];
// 在起止时间任意一个变化后获取数据
useEffect
(()
=>
{
countInterval
();
if
(
startTime
&&
endTime
)
{
setLoading
(
true
);
getData
();
...
...
@@ -122,7 +140,7 @@ const ServiceLog = () => {
if
(
res
.
code
===
0
)
{
setData0
(
res
.
data
);
dataTransforrm
(
res
.
data
);
console
.
log
(
res
.
data
);
//
console.log(res.data);
}
else
{
notification
.
error
({
message
:
'数据获取失败'
,
...
...
@@ -224,12 +242,13 @@ const ServiceLog = () => {
setEndTime
(
time
);
};
// 近1/6/12/24小时,同时设置对应的时间间隔
const
setTime
=
(
time
,
interval
)
=>
{
setTimeInrerval
(
interval
);
const
setTime
=
(
time
,
value
)
=>
{
// setIntervalText(text);
setTimeInterval
(
value
);
setEndTime
(
moment
(
new
Date
(),
'YYYY-MM-DD HH:mm:ss'
));
setStartTime
(
moment
(
new
Date
(
new
Date
().
getTime
()
-
time
*
60
*
60
*
1000
),
new
Date
(
new
Date
().
getTime
()
-
time
*
60
*
1000
),
'YYYY-MM-DD HH:mm:ss'
,
),
);
...
...
@@ -240,7 +259,7 @@ const ServiceLog = () => {
};
// 设置时间间隔
const
selectChange
=
value
=>
{
setTimeIn
r
erval
(
value
);
setTimeIn
t
erval
(
value
);
};
return
(
...
...
@@ -267,11 +286,11 @@ const ServiceLog = () => {
style
=
{{
marginRight
:
'10px'
}}
allowClear
=
{
false
}
/
>
<
Button
onClick
=
{()
=>
setTime
(
1
,
'每分钟
'
)}
>
近
15
分钟
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
6
,
'每5分钟
'
)}
>
近
1
小时
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
12
,
'每小时
'
)}
>
近
12
小时
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
24
,
'每小时
'
)}
>
近
1
天
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
24
*
7
,
'每天
'
)}
>
近
1
周
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
1
5
,
'1
'
)}
>
近
15
分钟
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
6
0
,
'5
'
)}
>
近
1
小时
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
12
*
60
,
'60
'
)}
>
近
12
小时
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
24
*
60
,
'60
'
)}
>
近
1
天
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
24
*
7
*
60
,
'1440
'
)}
>
近
1
周
<
/Button
>
<
span
style
=
{{
marginLeft
:
'20px'
}}
>
返回状态:
<
/span
>
<
Select
defaultValue
=
"正常"
onChange
=
{
changeStatus
}
>
<
Option
value
=
"9999"
>
全部
<
/Option
>
...
...
@@ -284,9 +303,15 @@ const ServiceLog = () => {
<
Row
style
=
{{
background
:
'white'
}}
>
<
Col
offset
=
{
6
}
style
=
{{
paddingTop
:
'8px'
}}
>
<
span
>
间隔:
<
/span
>
<
Select
value
=
{
timeInrerval
}
size
=
"small"
onChange
=
{
selectChange
}
>
{
/* value={intervalText} */
}
<
Select
defaultValue
=
"每小时"
value
=
{
timeInterval
}
size
=
"small"
onChange
=
{
selectChange
}
>
<
Option
value
=
"1"
>
每分钟
<
/Option
>
<
Option
value
=
"
10
"
>
每
5
分钟
<
/Option
>
<
Option
value
=
"
5
"
>
每
5
分钟
<
/Option
>
<
Option
value
=
"60"
>
每小时
<
/Option
>
<
Option
value
=
"1440"
>
每天
<
/Option
>
<
/Select
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment