From 85d304ed8b7ae4c1f209d87c94b44234c679563b Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Tue, 2 Sep 2025 11:42:42 +0800 Subject: [PATCH] perf: Password Change Page - Prompt Wording Optimization --- frontend/src/components/layout/PwdForm.vue | 9 ++++++++- frontend/src/i18n/en.json | 3 ++- frontend/src/i18n/zh-CN.json | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/layout/PwdForm.vue b/frontend/src/components/layout/PwdForm.vue index 465a8138..6c4fe3ae 100644 --- a/frontend/src/components/layout/PwdForm.vue +++ b/frontend/src/components/layout/PwdForm.vue @@ -9,13 +9,18 @@ const pwdForm = reactive({ new_pwd: '', confirm_pwd: '', }) - +const PWD_REGEX = + /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+\-={}|:"<>?`\[\];',./])[A-Za-z\d~!@#$%^&*()_+\-={}|:"<>?`\[\];',./]{8,20}$/ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const validatePass = (rule: any, value: any, callback: any) => { if (value === '') { callback(new Error(t('common.please_input', { msg: t('user.upgrade_pwd.new_pwd') }))) } else { + if (!PWD_REGEX.test(value)) { + callback(new Error(t('user.upgrade_pwd.pwd_format_error'))) + return + } if (pwdForm.confirm_pwd !== '') { if (!pwdRef.value) return pwdRef.value.validateField('confirm_pwd') @@ -28,6 +33,8 @@ const validatePass = (rule: any, value: any, callback: any) => { const validatePass2 = (rule: any, value: any, callback: any) => { if (value === '') { callback(new Error(t('common.please_input', { msg: t('user.upgrade_pwd.confirm_pwd') }))) + } else if (!PWD_REGEX.test(value)) { + callback(new Error(t('user.upgrade_pwd.pwd_format_error'))) } else if (value !== pwdForm.new_pwd) { callback(new Error(t('user.upgrade_pwd.two_pwd_not_match'))) } else { diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 2de562ab..e1494497 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -386,7 +386,8 @@ "old_pwd": "Old password", "new_pwd": "New password", "confirm_pwd": "Confirm password", - "two_pwd_not_match": "The two passwords do not match" + "two_pwd_not_match": "The two passwords do not match", + "pwd_format_error": "8-20 characters including uppercase, lowercase, number, and special character" } }, "workspace": { diff --git a/frontend/src/i18n/zh-CN.json b/frontend/src/i18n/zh-CN.json index 3cbebd6f..dea3e69c 100644 --- a/frontend/src/i18n/zh-CN.json +++ b/frontend/src/i18n/zh-CN.json @@ -386,7 +386,8 @@ "old_pwd": "旧密码", "new_pwd": "新密码", "confirm_pwd": "确认密码", - "two_pwd_not_match": "两次输入的密码不一致" + "two_pwd_not_match": "两次输入的密码不一致", + "pwd_format_error": "8-20位且至少一位大写字母、小写字母、数字、特殊字符" } }, "workspace": {