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
08edb05e
authored
Nov 08, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志添加查看信息功能
parent
63c4b162
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
web/package.json
+1
-1
web/src/components/LogsTable.js
+26
-3
No files found.
web/package.json
View file @
08edb05e
...
...
@@ -49,5 +49,5 @@
"singleQuote"
:
true
,
"jsxSingleQuote"
:
true
},
"proxy"
:
"http
://localhost:3000
"
"proxy"
:
"http
s://nekoapi.com
"
}
web/src/components/LogsTable.js
View file @
08edb05e
...
...
@@ -2,9 +2,9 @@ import React, {useEffect, useState} from 'react';
import
{
Label
}
from
'semantic-ui-react'
;
import
{
API
,
isAdmin
,
showError
,
timestamp2string
}
from
'../helpers'
;
import
{
Table
,
Avatar
,
Tag
,
Form
,
Button
,
Layout
,
Select
}
from
'@douyinfe/semi-ui'
;
import
{
Table
,
Avatar
,
Tag
,
Form
,
Button
,
Layout
,
Select
,
Popover
,
Modal
}
from
'@douyinfe/semi-ui'
;
import
{
ITEMS_PER_PAGE
}
from
'../constants'
;
import
{
renderQuota
,
stringToColor
}
from
'../helpers/render'
;
import
{
render
Number
,
render
Quota
,
stringToColor
}
from
'../helpers/render'
;
import
{
IconAt
,
IconHistogram
,
...
...
@@ -88,7 +88,8 @@ const LogsTable = () => {
return
(
isAdminUser
?
<
div
>
<
Avatar
size
=
"small"
color
=
{
stringToColor
(
text
)}
style
=
{{
marginRight
:
4
}}
>
<
Avatar
size
=
"small"
color
=
{
stringToColor
(
text
)}
style
=
{{
marginRight
:
4
}}
onClick
=
{()
=>
showUserInfo
(
record
.
user_id
)}
>
{
typeof
text
===
'string'
&&
text
.
slice
(
0
,
1
)}
<
/Avatar
>
{
text
}
...
...
@@ -251,6 +252,28 @@ const LogsTable = () => {
setShowStat
(
!
showStat
);
};
const
showUserInfo
=
async
(
userId
)
=>
{
if
(
!
isAdminUser
)
{
return
;
}
const
res
=
await
API
.
get
(
`/api/user/
${
userId
}
`
);
const
{
success
,
message
,
data
}
=
res
.
data
;
if
(
success
)
{
Modal
.
info
({
title
:
'用户信息'
,
content
:
<
div
style
=
{{
padding
:
12
}}
>
<
p
>
用户名
:
{
data
.
username
}
<
/p
>
<
p
>
余额
:
{
renderQuota
(
data
.
quota
)}
<
/p
>
<
p
>
已用额度:
{
renderQuota
(
data
.
used_quota
)}
<
/p
>
<
p
>
请求次数:
{
renderNumber
(
data
.
request_count
)}
<
/p
>
<
/div>
,
centered
:
true
,
})
}
else
{
showError
(
message
);
}
};
const
setLogsFormat
=
(
logs
)
=>
{
for
(
let
i
=
0
;
i
<
logs
.
length
;
i
++
)
{
logs
[
i
].
timestamp2string
=
timestamp2string
(
logs
[
i
].
created_at
);
...
...
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