mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 16:29:17 +08:00
parent
581ed16b73
commit
1dc2b292ec
@ -1,6 +1,13 @@
|
|||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { FormItemRule } from 'element-plus';
|
import { FormItemRule } from 'element-plus';
|
||||||
|
|
||||||
|
const checkNoSpace = (rule: any, value: any, callback: any) => {
|
||||||
|
if (value.indexOf(' ') !== -1) {
|
||||||
|
return callback(new Error(i18n.global.t('setting.noSpace')));
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
};
|
||||||
|
|
||||||
const checkIp = (rule: any, value: any, callback: any) => {
|
const checkIp = (rule: any, value: any, callback: any) => {
|
||||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||||
callback(new Error(i18n.global.t('commons.rule.requiredInput')));
|
callback(new Error(i18n.global.t('commons.rule.requiredInput')));
|
||||||
@ -431,6 +438,7 @@ interface CommonRule {
|
|||||||
requiredInput: FormItemRule;
|
requiredInput: FormItemRule;
|
||||||
requiredSelect: FormItemRule;
|
requiredSelect: FormItemRule;
|
||||||
requiredSelectBusiness: FormItemRule;
|
requiredSelectBusiness: FormItemRule;
|
||||||
|
noSpace: FormItemRule;
|
||||||
name: FormItemRule;
|
name: FormItemRule;
|
||||||
userName: FormItemRule;
|
userName: FormItemRule;
|
||||||
simpleName: FormItemRule;
|
simpleName: FormItemRule;
|
||||||
@ -484,6 +492,11 @@ export const Rules: CommonRule = {
|
|||||||
message: i18n.global.t('commons.rule.requiredSelect'),
|
message: i18n.global.t('commons.rule.requiredSelect'),
|
||||||
trigger: 'change',
|
trigger: 'change',
|
||||||
},
|
},
|
||||||
|
noSpace: {
|
||||||
|
required: true,
|
||||||
|
validator: checkNoSpace,
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
simpleName: {
|
simpleName: {
|
||||||
required: true,
|
required: true,
|
||||||
validator: checkSimpleName,
|
validator: checkSimpleName,
|
||||||
|
@ -1070,6 +1070,7 @@ const message = {
|
|||||||
oldPassword: 'Original password',
|
oldPassword: 'Original password',
|
||||||
newPassword: 'New password',
|
newPassword: 'New password',
|
||||||
retryPassword: 'Confirm password',
|
retryPassword: 'Confirm password',
|
||||||
|
noSpace: 'Input information cannot include space characters',
|
||||||
duplicatePassword: 'The new password cannot be the same as the original password, please re-enter!',
|
duplicatePassword: 'The new password cannot be the same as the original password, please re-enter!',
|
||||||
diskClean: 'Cache Clean',
|
diskClean: 'Cache Clean',
|
||||||
|
|
||||||
|
@ -1023,6 +1023,7 @@ const message = {
|
|||||||
oldPassword: '原密碼',
|
oldPassword: '原密碼',
|
||||||
newPassword: '新密碼',
|
newPassword: '新密碼',
|
||||||
retryPassword: '確認密碼',
|
retryPassword: '確認密碼',
|
||||||
|
noSpace: '輸入信息不能包括空格符號',
|
||||||
duplicatePassword: '新密碼不能與原始密碼一致,請重新輸入!',
|
duplicatePassword: '新密碼不能與原始密碼一致,請重新輸入!',
|
||||||
diskClean: '缓存清理',
|
diskClean: '缓存清理',
|
||||||
|
|
||||||
|
@ -1024,6 +1024,7 @@ const message = {
|
|||||||
oldPassword: '原密码',
|
oldPassword: '原密码',
|
||||||
newPassword: '新密码',
|
newPassword: '新密码',
|
||||||
retryPassword: '确认密码',
|
retryPassword: '确认密码',
|
||||||
|
noSpace: '输入信息不能包含空格符',
|
||||||
duplicatePassword: '新密码不能与原始密码一致,请重新输入!',
|
duplicatePassword: '新密码不能与原始密码一致,请重新输入!',
|
||||||
diskClean: '缓存清理',
|
diskClean: '缓存清理',
|
||||||
|
|
||||||
|
@ -16,30 +16,22 @@
|
|||||||
label-position="left"
|
label-position="left"
|
||||||
label-width="160px"
|
label-width="160px"
|
||||||
>
|
>
|
||||||
<el-form-item :label="$t('setting.oldPassword')" prop="oldPassword">
|
<el-form-item :label="$t('setting.oldPassword')" prop="oldPass">
|
||||||
<el-input type="password" show-password clearable v-model="passForm.oldPassword" />
|
<el-input type="password" show-password clearable v-model.trim="passForm.oldPass" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item v-if="!isComplexity" :label="$t('setting.newPassword')" prop="newPass">
|
||||||
v-if="settingForm?.complexityVerification === 'disable'"
|
<el-input type="password" show-password clearable v-model.trim="passForm.newPass" />
|
||||||
:label="$t('setting.newPassword')"
|
|
||||||
prop="newPassword"
|
|
||||||
>
|
|
||||||
<el-input type="password" show-password clearable v-model="passForm.newPassword" />
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item v-if="isComplexity" :label="$t('setting.newPassword')" prop="newPassComplexity">
|
||||||
v-if="settingForm?.complexityVerification === 'enable'"
|
|
||||||
:label="$t('setting.newPassword')"
|
|
||||||
prop="newPasswordComplexity"
|
|
||||||
>
|
|
||||||
<el-input
|
<el-input
|
||||||
type="password"
|
type="password"
|
||||||
show-password
|
show-password
|
||||||
clearable
|
clearable
|
||||||
v-model="passForm.newPasswordComplexity"
|
v-model.trim="passForm.newPassComplexity"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('setting.retryPassword')" prop="retryPassword">
|
<el-form-item :label="$t('setting.retryPassword')" prop="rePass">
|
||||||
<el-input type="password" show-password clearable v-model="passForm.retryPassword" />
|
<el-input type="password" show-password clearable v-model.trim="passForm.rePass" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="submitChangePassword(passFormRef)">
|
<el-button type="primary" @click="submitChangePassword(passFormRef)">
|
||||||
@ -61,30 +53,31 @@ import i18n from '@/lang';
|
|||||||
import { Rules } from '@/global/form-rules';
|
import { Rules } from '@/global/form-rules';
|
||||||
import router from '@/routers';
|
import router from '@/routers';
|
||||||
import { MsgError, MsgSuccess } from '@/utils/message';
|
import { MsgError, MsgSuccess } from '@/utils/message';
|
||||||
let settingForm = ref();
|
|
||||||
|
let isComplexity = ref(false);
|
||||||
|
|
||||||
type FormInstance = InstanceType<typeof ElForm>;
|
type FormInstance = InstanceType<typeof ElForm>;
|
||||||
const passFormRef = ref<FormInstance>();
|
const passFormRef = ref<FormInstance>();
|
||||||
const passRules = reactive({
|
const passRules = reactive({
|
||||||
oldPassword: [Rules.requiredInput],
|
oldPass: [Rules.noSpace, Rules.requiredInput],
|
||||||
newPassword: [
|
newPass: [
|
||||||
Rules.requiredInput,
|
Rules.requiredInput,
|
||||||
|
Rules.noSpace,
|
||||||
{ min: 6, message: i18n.global.t('commons.rule.commonPassword'), trigger: 'blur' },
|
{ min: 6, message: i18n.global.t('commons.rule.commonPassword'), trigger: 'blur' },
|
||||||
],
|
],
|
||||||
newPasswordComplexity: [Rules.requiredInput, Rules.password],
|
newPassComplexity: [Rules.requiredInput, Rules.noSpace, Rules.password],
|
||||||
retryPassword: [Rules.requiredInput, { validator: checkPassword, trigger: 'blur' }],
|
rePass: [Rules.requiredInput, Rules.noSpace, { validator: checkPasswordSame, trigger: 'blur' }],
|
||||||
});
|
});
|
||||||
const passForm = reactive({
|
const passForm = reactive({
|
||||||
oldPassword: '',
|
oldPass: '',
|
||||||
newPassword: '',
|
newPass: '',
|
||||||
newPasswordComplexity: '',
|
newPassComplexity: '',
|
||||||
retryPassword: '',
|
rePass: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
function checkPassword(rule: any, value: any, callback: any) {
|
function checkPasswordSame(rule: any, value: any, callback: any) {
|
||||||
let password =
|
let password = !isComplexity.value ? passForm.newPass : passForm.newPassComplexity;
|
||||||
settingForm.value.complexityVerification === 'disable' ? passForm.newPassword : passForm.newPasswordComplexity;
|
if (password !== passForm.rePass) {
|
||||||
if (password !== passForm.retryPassword) {
|
|
||||||
return callback(new Error(i18n.global.t('commons.rule.rePassword')));
|
return callback(new Error(i18n.global.t('commons.rule.rePassword')));
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
@ -94,22 +87,20 @@ const submitChangePassword = async (formEl: FormInstance | undefined) => {
|
|||||||
if (!formEl) return;
|
if (!formEl) return;
|
||||||
formEl.validate(async (valid) => {
|
formEl.validate(async (valid) => {
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
let password =
|
let password = !isComplexity.value ? passForm.newPass : passForm.newPassComplexity;
|
||||||
settingForm.value.complexityVerification === 'disable'
|
if (password === passForm.oldPass) {
|
||||||
? passForm.newPassword
|
|
||||||
: passForm.newPasswordComplexity;
|
|
||||||
if (password === passForm.oldPassword) {
|
|
||||||
MsgError(i18n.global.t('setting.duplicatePassword'));
|
MsgError(i18n.global.t('setting.duplicatePassword'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await handleExpired({ oldPassword: passForm.oldPassword, newPassword: password });
|
await handleExpired({ oldPassword: passForm.oldPass, newPassword: password });
|
||||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||||
router.push({ name: 'home' });
|
router.push({ name: 'home' });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const search = async () => {
|
const search = async () => {
|
||||||
const res = await getSettingInfo();
|
const res = await getSettingInfo();
|
||||||
settingForm.value = res.data;
|
let settingForm = res.data;
|
||||||
|
isComplexity.value = settingForm?.complexityVerification === 'enable';
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
<el-row type="flex" justify="center">
|
<el-row type="flex" justify="center">
|
||||||
<el-col :span="22">
|
<el-col :span="22">
|
||||||
<el-form-item :label="$t('setting.oldPassword')" prop="oldPassword">
|
<el-form-item :label="$t('setting.oldPassword')" prop="oldPassword">
|
||||||
<el-input type="password" show-password clearable v-model="passForm.oldPassword" />
|
<el-input type="password" show-password clearable v-model.trim="passForm.oldPassword" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-if="complexityVerification === 'disable'"
|
v-if="complexityVerification === 'disable'"
|
||||||
:label="$t('setting.newPassword')"
|
:label="$t('setting.newPassword')"
|
||||||
prop="newPassword"
|
prop="newPassword"
|
||||||
>
|
>
|
||||||
<el-input type="password" show-password clearable v-model="passForm.newPassword" />
|
<el-input type="password" show-password clearable v-model.trim="passForm.newPassword" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-if="complexityVerification === 'enable'"
|
v-if="complexityVerification === 'enable'"
|
||||||
@ -26,11 +26,11 @@
|
|||||||
type="password"
|
type="password"
|
||||||
show-password
|
show-password
|
||||||
clearable
|
clearable
|
||||||
v-model="passForm.newPasswordComplexity"
|
v-model.trim="passForm.newPasswordComplexity"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('setting.retryPassword')" prop="retryPassword">
|
<el-form-item :label="$t('setting.retryPassword')" prop="retryPassword">
|
||||||
<el-input type="password" show-password clearable v-model="passForm.retryPassword" />
|
<el-input type="password" show-password clearable v-model.trim="passForm.retryPassword" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -64,14 +64,16 @@ import { logOutApi } from '@/api/modules/auth';
|
|||||||
const globalStore = GlobalStore();
|
const globalStore = GlobalStore();
|
||||||
const passFormRef = ref<FormInstance>();
|
const passFormRef = ref<FormInstance>();
|
||||||
const passRules = reactive({
|
const passRules = reactive({
|
||||||
oldPassword: [Rules.requiredInput],
|
oldPassword: [Rules.noSpace, Rules.requiredInput],
|
||||||
newPassword: [
|
newPassword: [
|
||||||
Rules.requiredInput,
|
Rules.requiredInput,
|
||||||
|
Rules.noSpace,
|
||||||
{ min: 6, message: i18n.global.t('commons.rule.commonPassword'), trigger: 'blur' },
|
{ min: 6, message: i18n.global.t('commons.rule.commonPassword'), trigger: 'blur' },
|
||||||
],
|
],
|
||||||
newPasswordComplexity: [Rules.requiredInput, Rules.password],
|
newPasswordComplexity: [Rules.requiredInput, Rules.noSpace, Rules.password],
|
||||||
retryPassword: [Rules.requiredInput, { validator: checkPassword, trigger: 'blur' }],
|
retryPassword: [Rules.requiredInput, Rules.noSpace, { validator: checkPassword, trigger: 'blur' }],
|
||||||
});
|
});
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const passwordVisible = ref<boolean>(false);
|
const passwordVisible = ref<boolean>(false);
|
||||||
const passForm = reactive({
|
const passForm = reactive({
|
||||||
|
@ -4,11 +4,18 @@
|
|||||||
<template #header>
|
<template #header>
|
||||||
<DrawerHeader :header="$t('commons.login.username')" :back="handleClose" />
|
<DrawerHeader :header="$t('commons.login.username')" :back="handleClose" />
|
||||||
</template>
|
</template>
|
||||||
<el-form ref="formRef" label-position="top" :model="form" @submit.prevent v-loading="loading">
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
label-position="top"
|
||||||
|
:model="form"
|
||||||
|
@submit.prevent
|
||||||
|
v-loading="loading"
|
||||||
|
:rules="rules"
|
||||||
|
>
|
||||||
<el-row type="flex" justify="center">
|
<el-row type="flex" justify="center">
|
||||||
<el-col :span="22">
|
<el-col :span="22">
|
||||||
<el-form-item :label="$t('commons.login.username')" prop="userName" :rules="Rules.userName">
|
<el-form-item :label="$t('commons.login.username')" prop="userName">
|
||||||
<el-input clearable v-model="form.userName" />
|
<el-input clearable v-model.trim="form.userName" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -46,7 +53,9 @@ const loading = ref();
|
|||||||
const form = reactive({
|
const form = reactive({
|
||||||
userName: '',
|
userName: '',
|
||||||
});
|
});
|
||||||
|
const rules = reactive({
|
||||||
|
userName: [Rules.userName, Rules.noSpace],
|
||||||
|
});
|
||||||
const formRef = ref<FormInstance>();
|
const formRef = ref<FormInstance>();
|
||||||
|
|
||||||
const acceptParams = (params: DialogProps): void => {
|
const acceptParams = (params: DialogProps): void => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user