From 4f05075f5007d4c02c769b79d9c792f0efbb1f94 Mon Sep 17 00:00:00 2001 From: zhangrenyuan <18990852002@163.com> Date: Fri, 22 Aug 2025 16:00:25 +0800 Subject: [PATCH] fix changePassword --- src/components/changePassword.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/changePassword.vue b/src/components/changePassword.vue index 44954b2..ed70cda 100644 --- a/src/components/changePassword.vue +++ b/src/components/changePassword.vue @@ -32,7 +32,9 @@ const getAccount= async function() { } } // 实时密码规则校验 -const isLengthValid = computed(() => passwd.newPassword.length >= 8 && passwd.newPassword.length <= 16) +const isLengthValid = computed(() => + /^[A-Za-z0-9~!@#$%^&*()_+\-=[\]{}|;:,.<>?/]{8,16}$/.test(passwd.newPassword) +); const isComplexValid = computed(() => { const rules = [/\d/, /[a-z]/, /[A-Z]/, /[^a-zA-Z0-9]/] @@ -62,7 +64,7 @@ const rules = reactive({ } else if (value.length < 8 || value.length > 16) { callback(new Error('长度应在 8 到 16 个字符')) } else { - const types = [/\d/, /[a-z]/, /[A-Z]/, /[^a-zA-Z0-9]/] + const types = [/\d/, /[a-z]/, /[A-Z]/, /[!@#$%^&*()\-_+={}[\]|\\:;"'<>,.?/~`]/]; const matchCount = types.filter((r) => r.test(value)).length if (matchCount < 2) { callback(new Error('密码至少包含两种类型(数字、字母或符号)')) @@ -115,7 +117,7 @@ const changePassword = async function () { router.push('/PasswordSuccess'); }, 1000); }else if (result.code === 0){ - ElMessage.error('原密码错误') + ElMessage.error('原密码错误,请重新输入') passwd.oldPassword = ''; }else if(result.code === 400){