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
78ffd8d2
authored
Aug 01, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 优化日志查初始时间
parent
d59bf0b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
web/src/components/LogsTable.js
+4
-4
web/src/helpers/utils.js
+6
-0
No files found.
web/src/components/LogsTable.js
View file @
78ffd8d2
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
import
{
API
,
API
,
copy
,
copy
,
getTodayStartTimestamp
,
isAdmin
,
isAdmin
,
showError
,
showError
,
showSuccess
,
showSuccess
,
timestamp2string
,
timestamp2string
}
from
'../helpers'
;
}
from
'../helpers'
;
import
{
import
{
...
@@ -419,12 +419,12 @@ const LogsTable = () => {
...
@@ -419,12 +419,12 @@ const LogsTable = () => {
const
[
logType
,
setLogType
]
=
useState
(
0
);
const
[
logType
,
setLogType
]
=
useState
(
0
);
const
isAdminUser
=
isAdmin
();
const
isAdminUser
=
isAdmin
();
let
now
=
new
Date
();
let
now
=
new
Date
();
// 初始化start_timestamp为
前一天
// 初始化start_timestamp为
今天0点
const
[
inputs
,
setInputs
]
=
useState
({
const
[
inputs
,
setInputs
]
=
useState
({
username
:
''
,
username
:
''
,
token_name
:
''
,
token_name
:
''
,
model_name
:
''
,
model_name
:
''
,
start_timestamp
:
timestamp2string
(
now
.
getTime
()
/
1000
-
86400
),
start_timestamp
:
timestamp2string
(
getTodayStartTimestamp
()
),
end_timestamp
:
timestamp2string
(
now
.
getTime
()
/
1000
+
3600
),
end_timestamp
:
timestamp2string
(
now
.
getTime
()
/
1000
+
3600
),
channel
:
''
,
channel
:
''
,
});
});
...
...
web/src/helpers/utils.js
View file @
78ffd8d2
...
@@ -140,6 +140,12 @@ export function removeTrailingSlash(url) {
...
@@ -140,6 +140,12 @@ export function removeTrailingSlash(url) {
}
}
}
}
export
function
getTodayStartTimestamp
()
{
var
now
=
new
Date
();
now
.
setHours
(
0
,
0
,
0
,
0
);
return
Math
.
floor
(
now
.
getTime
()
/
1000
);
}
export
function
timestamp2string
(
timestamp
)
{
export
function
timestamp2string
(
timestamp
)
{
let
date
=
new
Date
(
timestamp
*
1000
);
let
date
=
new
Date
(
timestamp
*
1000
);
let
year
=
date
.
getFullYear
().
toString
();
let
year
=
date
.
getFullYear
().
toString
();
...
...
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