Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f3a84053
authored
May 08, 2024
by
Calcium-Ion
Committed by
GitHub
May 08, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #232 from kakingone/add-mj-usetime
add-mj-use-time
parents
2fed1a15
c7f515ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
web/src/components/MjLogsTable.js
+34
-0
No files found.
web/src/components/MjLogsTable.js
View file @
f3a84053
...
...
@@ -236,6 +236,31 @@ const renderTimestamp = (timestampInSeconds) => {
return
`
${
year
}
-
${
month
}
-
${
day
}
${
hours
}
:
${
minutes
}
:
${
seconds
}
`
;
// 格式化输出
};
// 修改renderDuration函数以包含颜色逻辑
function
renderDuration
(
submit_time
,
finishTime
)
{
// 确保startTime和finishTime都是有效的时间戳
if
(
!
submit_time
||
!
finishTime
)
return
'N/A'
;
// 将时间戳转换为Date对象
const
start
=
new
Date
(
submit_time
);
const
finish
=
new
Date
(
finishTime
);
// 计算时间差(毫秒)
const
durationMs
=
finish
-
start
;
// 将时间差转换为秒,并保留一位小数
const
durationSec
=
(
durationMs
/
1000
).
toFixed
(
1
);
// 设置颜色:大于60秒则为红色,小于等于60秒则为绿色
const
color
=
durationSec
>
60
?
'red'
:
'green'
;
// 返回带有样式的颜色标签
return
(
<
Tag
color
=
{
color
}
size
=
"large"
>
{
durationSec
}
秒
<
/Tag
>
);
}
const
LogsTable
=
()
=>
{
const
[
isModalOpen
,
setIsModalOpen
]
=
useState
(
false
);
...
...
@@ -249,6 +274,15 @@ const LogsTable = () => {
},
},
{
title
:
'花费时间'
,
dataIndex
:
'finish_time'
,
// 以finish_time作为dataIndex
key
:
'finish_time'
,
render
:
(
finish
,
record
)
=>
{
// 假设record.start_time是存在的,并且finish是完成时间的时间戳
return
renderDuration
(
record
.
submit_time
,
finish
);
},
},
{
title
:
'渠道'
,
dataIndex
:
'channel_id'
,
className
:
isAdmin
()
?
'tableShow'
:
'tableHiddle'
,
...
...
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