Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
client
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
14b17e16
authored
Sep 29, 2026
by
renyizhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apiKey添加复制按钮
parent
a63dfbb0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
src/views/console/components/token.vue
+47
-0
No files found.
src/views/console/components/token.vue
View file @
14b17e16
...
@@ -12,6 +12,14 @@
...
@@ -12,6 +12,14 @@
<el-tooltip
effect=
"dark"
:content=
"apiKey"
placement=
"top"
>
<el-tooltip
effect=
"dark"
:content=
"apiKey"
placement=
"top"
>
<span
class=
"secret-text"
>
{{
maskedKey
}}
</span>
<span
class=
"secret-text"
>
{{
maskedKey
}}
</span>
</el-tooltip>
</el-tooltip>
<el-button
type=
"primary"
link
class=
"ml10"
@
click=
"copyApiKey"
>
<el-icon><DocumentCopy
/></el-icon>
</el-button>
</el-form-item>
</el-form-item>
<el-form-item
label=
"服务地址:"
>
<el-form-item
label=
"服务地址:"
>
<el-tooltip
effect=
"dark"
content=
"http://phslgld.hnluchuan.com:3000/"
placement=
"top"
>
<el-tooltip
effect=
"dark"
content=
"http://phslgld.hnluchuan.com:3000/"
placement=
"top"
>
...
@@ -186,6 +194,7 @@
...
@@ -186,6 +194,7 @@
<
script
setup
>
<
script
setup
>
import
{
getTokenInfo
,
getToken
,
createRecharge
,
getRecharge
}
from
"@/api/console"
;
import
{
getTokenInfo
,
getToken
,
createRecharge
,
getRecharge
}
from
"@/api/console"
;
import
{
ElMessage
,
ElMessageBox
}
from
"element-plus"
;
import
{
ElMessage
,
ElMessageBox
}
from
"element-plus"
;
import
{
DocumentCopy
}
from
"@element-plus/icons-vue"
;
import
QRCode
from
"qrcode"
;
import
QRCode
from
"qrcode"
;
import
useUserStore
from
"@/store/modules/user"
;
import
useUserStore
from
"@/store/modules/user"
;
...
@@ -247,6 +256,44 @@ function maskKey(key) {
...
@@ -247,6 +256,44 @@ function maskKey(key) {
return
key
.
substring
(
0
,
6
)
+
"****"
+
key
.
substring
(
key
.
length
-
6
);
return
key
.
substring
(
0
,
6
)
+
"****"
+
key
.
substring
(
key
.
length
-
6
);
}
}
function
copyApiKey
()
{
if
(
!
apiKey
.
value
)
{
proxy
.
$modal
.
msgError
(
"暂无可复制的 API Key"
);
return
;
}
const
text
=
apiKey
.
value
;
if
(
navigator
.
clipboard
&&
window
.
isSecureContext
)
{
navigator
.
clipboard
.
writeText
(
text
).
then
(()
=>
{
proxy
.
$modal
.
msgSuccess
(
"已复制 API Key"
);
}).
catch
(()
=>
{
fallbackCopy
(
text
);
});
}
else
{
fallbackCopy
(
text
);
}
}
function
fallbackCopy
(
text
)
{
const
textarea
=
document
.
createElement
(
"textarea"
);
textarea
.
value
=
text
;
textarea
.
style
.
position
=
"fixed"
;
textarea
.
style
.
opacity
=
"0"
;
document
.
body
.
appendChild
(
textarea
);
textarea
.
focus
();
textarea
.
select
();
try
{
const
successful
=
document
.
execCommand
(
"copy"
);
if
(
successful
)
{
proxy
.
$modal
.
msgSuccess
(
"已复制 API Key"
);
}
else
{
proxy
.
$modal
.
msgError
(
"复制失败,请手动复制"
);
}
}
catch
(
e
)
{
proxy
.
$modal
.
msgError
(
"复制失败,请手动复制"
);
}
document
.
body
.
removeChild
(
textarea
);
}
function
loadTokenInfo
()
{
function
loadTokenInfo
()
{
getTokenInfo
().
then
(
response
=>
{
getTokenInfo
().
then
(
response
=>
{
if
(
response
&&
response
.
apiKey
&&
response
.
hasToken
)
{
if
(
response
&&
response
.
apiKey
&&
response
.
hasToken
)
{
...
...
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