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
40c626cb
authored
Nov 01, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善令牌界面
parent
607358c9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
8 deletions
+34
-8
web/src/components/TokensTable.js
+34
-8
web/src/pages/Token/EditToken.js
+0
-0
No files found.
web/src/components/TokensTable.js
View file @
40c626cb
...
@@ -5,6 +5,7 @@ import {API, copy, isAdmin, showError, showSuccess, showWarning, timestamp2strin
...
@@ -5,6 +5,7 @@ import {API, copy, isAdmin, showError, showSuccess, showWarning, timestamp2strin
import
{
ITEMS_PER_PAGE
}
from
'../constants'
;
import
{
ITEMS_PER_PAGE
}
from
'../constants'
;
import
{
renderQuota
,
stringToColor
}
from
'../helpers/render'
;
import
{
renderQuota
,
stringToColor
}
from
'../helpers/render'
;
import
{
Avatar
,
Tag
,
Table
,
Button
,
Popover
,
Form
,
Modal
,
Popconfirm
}
from
"@douyinfe/semi-ui"
;
import
{
Avatar
,
Tag
,
Table
,
Button
,
Popover
,
Form
,
Modal
,
Popconfirm
}
from
"@douyinfe/semi-ui"
;
import
EditToken
from
"../pages/Token/EditToken"
;
const
{
Column
}
=
Table
;
const
{
Column
}
=
Table
;
...
@@ -77,7 +78,7 @@ const TokensTable = () => {
...
@@ -77,7 +78,7 @@ const TokensTable = () => {
render
:
(
text
,
record
,
index
)
=>
{
render
:
(
text
,
record
,
index
)
=>
{
return
(
return
(
<
div
>
<
div
>
{
re
nderQuota
(
parseInt
(
text
))
}
{
re
cord
.
unlimited_quota
?
<
Tag
size
=
{
'large'
}
color
=
{
'white'
}
>
无限制
<
/Tag> : <Tag size={'large'} color={'light-blue'}>{renderQuota
(
parseInt
(
text
))
}</
Tag
>
}
<
/div
>
<
/div
>
);
);
},
},
...
@@ -95,11 +96,11 @@ const TokensTable = () => {
...
@@ -95,11 +96,11 @@ const TokensTable = () => {
},
},
{
{
title
:
'过期时间'
,
title
:
'过期时间'
,
dataIndex
:
'
access
ed_time'
,
dataIndex
:
'
expir
ed_time'
,
render
:
(
text
,
record
,
index
)
=>
{
render
:
(
text
,
record
,
index
)
=>
{
return
(
return
(
<
div
>
<
div
>
{
renderTimestamp
(
text
)}
{
re
cord
.
expired_time
===
-
1
?
"永不过期"
:
re
nderTimestamp
(
text
)}
<
/div
>
<
/div
>
);
);
},
},
...
@@ -159,12 +160,18 @@ const TokensTable = () => {
...
@@ -159,12 +160,18 @@ const TokensTable = () => {
}
}
}
>
启用
<
/Button
>
}
>
启用
<
/Button
>
}
}
<
Button
theme
=
'light'
type
=
'tertiary'
style
=
{{
marginRight
:
1
}}
>
编辑
<
/Button
>
<
Button
theme
=
'light'
type
=
'tertiary'
style
=
{{
marginRight
:
1
}}
onClick
=
{
()
=>
{
setEditingToken
(
record
);
setShowEdit
(
true
);
}
}
>
编辑
<
/Button
>
<
/div
>
<
/div
>
),
),
},
},
];
];
const
[
showEdit
,
setShowEdit
]
=
useState
(
false
);
const
[
tokens
,
setTokens
]
=
useState
([]);
const
[
tokens
,
setTokens
]
=
useState
([]);
const
[
selectedKeys
,
setSelectedKeys
]
=
useState
([]);
const
[
selectedKeys
,
setSelectedKeys
]
=
useState
([]);
const
[
tokenCount
,
setTokenCount
]
=
useState
(
ITEMS_PER_PAGE
);
const
[
tokenCount
,
setTokenCount
]
=
useState
(
ITEMS_PER_PAGE
);
...
@@ -174,6 +181,16 @@ const TokensTable = () => {
...
@@ -174,6 +181,16 @@ const TokensTable = () => {
const
[
searching
,
setSearching
]
=
useState
(
false
);
const
[
searching
,
setSearching
]
=
useState
(
false
);
const
[
showTopUpModal
,
setShowTopUpModal
]
=
useState
(
false
);
const
[
showTopUpModal
,
setShowTopUpModal
]
=
useState
(
false
);
const
[
targetTokenIdx
,
setTargetTokenIdx
]
=
useState
(
0
);
const
[
targetTokenIdx
,
setTargetTokenIdx
]
=
useState
(
0
);
const
[
editingToken
,
setEditingToken
]
=
useState
({
id
:
undefined
,
});
const
closeEdit
=
()
=>
{
setShowEdit
(
false
);
setEditingToken
({
id
:
undefined
,
});
}
const
setTokensFormat
=
(
tokens
)
=>
{
const
setTokensFormat
=
(
tokens
)
=>
{
setTokens
(
tokens
);
setTokens
(
tokens
);
...
@@ -409,19 +426,17 @@ const TokensTable = () => {
...
@@ -409,19 +426,17 @@ const TokensTable = () => {
const
rowSelection
=
{
const
rowSelection
=
{
onSelect
:
(
record
,
selected
)
=>
{
onSelect
:
(
record
,
selected
)
=>
{
// console.log(`select row: ${selected}`, record);
},
},
onSelectAll
:
(
selected
,
selectedRows
)
=>
{
onSelectAll
:
(
selected
,
selectedRows
)
=>
{
// console.log(`select all rows: ${selected}`, selectedRows);
},
},
onChange
:
(
selectedRowKeys
,
selectedRows
)
=>
{
onChange
:
(
selectedRowKeys
,
selectedRows
)
=>
{
// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
setSelectedKeys
(
selectedRows
);
setSelectedKeys
(
selectedRows
);
},
},
};
};
return
(
return
(
<>
<>
<
EditToken
refresh
=
{
refresh
}
editingToken
=
{
editingToken
}
visiable
=
{
showEdit
}
handleClose
=
{
closeEdit
}
><
/EditToken
>
<
Form
layout
=
'horizontal'
style
=
{{
marginTop
:
10
}}
labelPosition
=
{
'left'
}
>
<
Form
layout
=
'horizontal'
style
=
{{
marginTop
:
10
}}
labelPosition
=
{
'left'
}
>
<
Form
.
Input
<
Form
.
Input
field
=
"keyword"
field
=
"keyword"
...
@@ -443,9 +458,20 @@ const TokensTable = () => {
...
@@ -443,9 +458,20 @@ const TokensTable = () => {
onPageChange
:
handlePageChange
,
onPageChange
:
handlePageChange
,
}}
loading
=
{
loading
}
rowSelection
=
{
rowSelection
}
>
}}
loading
=
{
loading
}
rowSelection
=
{
rowSelection
}
>
<
/Table
>
<
/Table
>
<
Button
theme
=
'light'
type
=
'primary'
style
=
{{
marginRight
:
8
}}
>
添加令牌
<
/Button
>
<
Button
theme
=
'light'
type
=
'primary'
style
=
{{
marginRight
:
8
}}
onClick
=
{
()
=>
{
setEditingToken
({
id
:
undefined
,
});
setShowEdit
(
true
);
}
}
>
添加令牌
<
/Button
>
<
Button
label
=
'复制所选令牌'
type
=
"warning"
onClick
=
{
<
Button
label
=
'复制所选令牌'
type
=
"warning"
onClick
=
{
async
()
=>
{
async
()
=>
{
if
(
selectedKeys
.
length
===
0
)
{
showError
(
'请至少选择一个令牌!'
);
return
;
}
let
keys
=
""
;
let
keys
=
""
;
for
(
let
i
=
0
;
i
<
selectedKeys
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
selectedKeys
.
length
;
i
++
)
{
keys
+=
selectedKeys
[
i
].
name
+
" sk-"
+
selectedKeys
[
i
].
key
+
"\n"
;
keys
+=
selectedKeys
[
i
].
name
+
" sk-"
+
selectedKeys
[
i
].
key
+
"\n"
;
...
...
web/src/pages/Token/EditToken.js
View file @
40c626cb
This diff is collapsed.
Click to expand it.
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