updat key管理功能

pull/1/head
kelvin 3 years ago
parent 370ee4c35f
commit 6ddc79fd4f

@ -50,3 +50,27 @@ export function flushApiToken(id) {
method: 'get' method: 'get'
}) })
} }
//生成用户KEY
export function generateKey(){
return request({
url: '/cert/apiToken/generateKey',
method: 'get'
})
}
//获取当前用户KEY列表
export function getKeyList(){
return request({
url: '/cert/apiToken/getKeyList',
method: 'get'
})
}
//删除用户KEY
export function delKey(key){
return request({
url: '/cert/apiToken/deleteKey/'+key,
method: 'delete'
})
}

@ -38,6 +38,11 @@
<template #header> <template #header>
<div class="card-header"> <div class="card-header">
<span>服务信息</span> <span>服务信息</span>
<div>
<router-link to="/key">
<el-button type="primary">KEY管理</el-button>
</router-link>
</div>
</div> </div>
</template> </template>
<div style="margin-top: 10px; margin-bottom: 10px;"> <div style="margin-top: 10px; margin-bottom: 10px;">
@ -49,7 +54,6 @@
</el-input> </el-input>
</div> </div>
<div style="margin-top: 10px; margin-bottom: 10px;"> <div style="margin-top: 10px; margin-bottom: 10px;">
<el-input v-model="userKey" size="large" readonly @click.stop="handleCopy(userKey)"> <el-input v-model="userKey" size="large" readonly @click.stop="handleCopy(userKey)">
<template #prepend>Api Key:</template> <template #prepend>Api Key:</template>
<template #append> <template #append>

@ -0,0 +1,96 @@
<template>
<div class="main">
<el-card class="box-card">
<template #header>
<div class="card-header">
<span>KEY 管理</span>
<div><el-button type="success" style="margin-right: 10px;" @click="handleAdd()"></el-button></div>
</div>
</template>
<div style="margin-top: 10px; margin-bottom: 10px;" v-for="(obj,index) in keyList" :obj="obj" :index="index" :key="obj.id">
<el-input :value="'AK-'+ obj.id" size="large" readonly @click.stop="handleCopy('AK-'+obj.id)">
<template #prepend>Api Server{{ index + 1 }}:</template>
<template #append>
<el-button @click="handleDel(obj.id)"></el-button>
</template>
</el-input>
</div>
</el-card>
</div>
</template>
<script setup name="key">
import { ref } from 'vue';
import { delKey,getKeyList,generateKey } from "@/api/cert/apiToken";
const { proxy } = getCurrentInstance();
const keyList = ref([]);
function Init(){
getKeyList().then(response => {
keyList.value = response.data
})
}
function handleAdd(){
generateKey().then(response => {
proxy.$modal.msgSuccess("添加成功");
Init();
})
}
function handleDel(key){
proxy.$modal.confirm('是否确认删除KEY:AK-'+key+'').then(function() {
return delKey(key);
}).then(() => {
Init();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
function handleCopy(id){
//
const text = id;
// input
const input = document.createElement("input");
input.value = text;
document.body.appendChild(input);
//
input.select();
document.execCommand("copy");
// input
document.body.removeChild(input);
proxy.$modal.msgSuccess("复制成功");
}
Init();
</script>
<style scoped lang="scss">
.main {
padding: 20px;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.text {
font-size: 14px;
}
.item {
margin-bottom: 18px;
}
.info {
font-size: 15px;
color: #606266;
}
</style>
Loading…
Cancel
Save