feat: mysql root 密码增加随机和复制按钮 (#556)

This commit is contained in:
ssongliu 2023-04-10 12:56:16 +08:00 committed by GitHub
parent 188a3e0ac5
commit 8603d4347b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,12 @@
<el-row type="flex" justify="center">
<el-col :span="22">
<el-form-item :label="$t('database.rootPassword')" :rules="Rules.requiredInput" prop="password">
<el-input type="password" show-password clearable v-model="form.password" />
<el-input type="password" show-password clearable v-model="form.password">
<template #append>
<el-button @click="copy" icon="DocumentCopy"></el-button>
<el-button style="margin-left: 1px" @click="random" icon="RefreshRight"></el-button>
</template>
</el-input>
</el-form-item>
</el-col>
</el-row>
@ -38,6 +43,7 @@ import ConfirmDialog from '@/components/confirm-dialog/index.vue';
import { GetAppPassword } from '@/api/modules/app';
import DrawerHeader from '@/components/drawer-header/index.vue';
import { MsgSuccess } from '@/utils/message';
import { getRandomStr } from '@/utils/util';
const loading = ref(false);
@ -57,6 +63,20 @@ const acceptParams = (): void => {
dialogVisiable.value = true;
};
const random = async () => {
form.password = getRandomStr(16);
};
const copy = async () => {
let input = document.createElement('input');
input.value = form.password;
document.body.appendChild(input);
input.select();
document.execCommand('Copy');
document.body.removeChild(input);
MsgSuccess(i18n.global.t('commons.msg.copySuccess'));
};
const handleClose = () => {
dialogVisiable.value = false;
};