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
67ece62f
authored
Apr 25, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: copy token to search input if clipboard.writeText is not available (close #6)
parent
7856da5d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
2 deletions
+9
-2
web/src/components/TokensTable.js
+3
-2
web/src/constants/toast.constants.js
+1
-0
web/src/helpers/utils.js
+5
-0
No files found.
web/src/components/TokensTable.js
View file @
67ece62f
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Button
,
Form
,
Label
,
Message
,
Pagination
,
Table
}
from
'semantic-ui-react'
;
import
{
Button
,
Form
,
Label
,
Message
,
Pagination
,
Table
}
from
'semantic-ui-react'
;
import
{
Link
}
from
'react-router-dom'
;
import
{
Link
}
from
'react-router-dom'
;
import
{
API
,
copy
,
showError
,
show
Success
,
timestamp2string
}
from
'../helpers'
;
import
{
API
,
copy
,
showError
,
show
Info
,
showSuccess
,
showWarning
,
timestamp2string
}
from
'../helpers'
;
import
{
ITEMS_PER_PAGE
}
from
'../constants'
;
import
{
ITEMS_PER_PAGE
}
from
'../constants'
;
...
@@ -243,7 +243,8 @@ const TokensTable = () => {
...
@@ -243,7 +243,8 @@ const TokensTable = () => {
if
(
await
copy
(
token
.
key
))
{
if
(
await
copy
(
token
.
key
))
{
showSuccess
(
'已复制到剪贴板!'
);
showSuccess
(
'已复制到剪贴板!'
);
}
else
{
}
else
{
showError
(
'复制失败!'
);
showWarning
(
'无法复制到剪贴板,请手动复制,已将令牌填入搜索框。'
)
setSearchKeyword
(
token
.
key
);
}
}
}}
}}
>
>
...
...
web/src/constants/toast.constants.js
View file @
67ece62f
...
@@ -2,5 +2,6 @@ export const toastConstants = {
...
@@ -2,5 +2,6 @@ export const toastConstants = {
SUCCESS_TIMEOUT
:
500
,
SUCCESS_TIMEOUT
:
500
,
INFO_TIMEOUT
:
3000
,
INFO_TIMEOUT
:
3000
,
ERROR_TIMEOUT
:
5000
,
ERROR_TIMEOUT
:
5000
,
WARNING_TIMEOUT
:
10000
,
NOTICE_TIMEOUT
:
20000
NOTICE_TIMEOUT
:
20000
};
};
web/src/helpers/utils.js
View file @
67ece62f
...
@@ -31,6 +31,7 @@ export function isMobile() {
...
@@ -31,6 +31,7 @@ export function isMobile() {
}
}
let
showErrorOptions
=
{
autoClose
:
toastConstants
.
ERROR_TIMEOUT
};
let
showErrorOptions
=
{
autoClose
:
toastConstants
.
ERROR_TIMEOUT
};
let
showWarningOptions
=
{
autoClose
:
toastConstants
.
WARNING_TIMEOUT
};
let
showSuccessOptions
=
{
autoClose
:
toastConstants
.
SUCCESS_TIMEOUT
};
let
showSuccessOptions
=
{
autoClose
:
toastConstants
.
SUCCESS_TIMEOUT
};
let
showInfoOptions
=
{
autoClose
:
toastConstants
.
INFO_TIMEOUT
};
let
showInfoOptions
=
{
autoClose
:
toastConstants
.
INFO_TIMEOUT
};
let
showNoticeOptions
=
{
autoClose
:
false
};
let
showNoticeOptions
=
{
autoClose
:
false
};
...
@@ -74,6 +75,10 @@ export function showError(error) {
...
@@ -74,6 +75,10 @@ export function showError(error) {
}
}
}
}
export
function
showWarning
(
message
)
{
toast
.
warn
(
message
,
showWarningOptions
);
}
export
function
showSuccess
(
message
)
{
export
function
showSuccess
(
message
)
{
toast
.
success
(
message
,
showSuccessOptions
);
toast
.
success
(
message
,
showSuccessOptions
);
}
}
...
...
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