From 23fb2fbac180a6a82bf8f92232138d1f94fb8ace Mon Sep 17 00:00:00 2001 From: aeizzz Date: Tue, 7 Mar 2023 14:40:51 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20Introducing=20new=20features.=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=86=E7=A0=81=E5=BC=BA=E5=BA=A6=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- src/components/StrengthMeter/index.vue | 119 +++++++++++++++++++++++++ src/utils/toolsValidate.ts | 10 +-- src/views/admin/user/personal.vue | 16 +++- src/views/login/component/register.vue | 33 ++++--- src/views/login/index.vue | 2 +- 6 files changed, 160 insertions(+), 22 deletions(-) create mode 100644 src/components/StrengthMeter/index.vue diff --git a/.env b/.env index 9af53db1..a863648b 100644 --- a/.env +++ b/.env @@ -20,7 +20,7 @@ VITE_GEN_PROXY_PATH = http://localhost:5003 VITE_WEBSOCKET_ENABLE = false # 是否开启注册 -VITE_REGISTER_ENABLE = false +VITE_REGISTER_ENABLE = true # 代码代码前缀 VITE_PUBLIC_PATH = / diff --git a/src/components/StrengthMeter/index.vue b/src/components/StrengthMeter/index.vue new file mode 100644 index 00000000..93b0ab17 --- /dev/null +++ b/src/components/StrengthMeter/index.vue @@ -0,0 +1,119 @@ + + + + + diff --git a/src/utils/toolsValidate.ts b/src/utils/toolsValidate.ts index f2cb9d6f..c3b80d3c 100644 --- a/src/utils/toolsValidate.ts +++ b/src/utils/toolsValidate.ts @@ -253,14 +253,14 @@ export function verifyPasswordPowerful(val: string) { * @returns 返回处理后的字符串:弱、中、强 */ export function verifyPasswordStrength(val: string) { - let v = ''; + let v = '0'; // 弱:纯数字,纯字母,纯特殊字符 - if (/^(?:\d+|[a-zA-Z]+|[!@#$%^&\.*]+){6,16}$/.test(val)) v = '弱'; + if (/^(?:\d+|[a-zA-Z]+|[!@#$%^&\.*]+){6,100}$/.test(val)) v = '1'; // 中:字母+数字,字母+特殊字符,数字+特殊字符 - if (/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,16}$/.test(val)) v = '中'; + if (/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,100}$/.test(val)) v = '2'; // 强:字母+数字+特殊字符 - if (/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&\.*]+$)(?![\d!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,16}$/.test(val)) - v = '强'; + if (/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&\.*]+$)(?![\d!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,100}$/.test(val)) + v = '3'; // 返回结果 return v; } diff --git a/src/views/admin/user/personal.vue b/src/views/admin/user/personal.vue index 46813e14..f6ead13e 100644 --- a/src/views/admin/user/personal.vue +++ b/src/views/admin/user/personal.vue @@ -61,12 +61,19 @@ - + + - + @@ -114,6 +121,7 @@ import { useI18n } from 'vue-i18n'; const { t } = useI18n(); const ImageUpload = defineAsyncComponent(() => import('/@/components/Upload/Image.vue')); +const StrengthMeter = defineAsyncComponent(() => import('/@/components/StrengthMeter/index.vue')); const visible = ref(false); @@ -154,6 +162,10 @@ const validatorPassword2 = (rule: any, value: any, callback: any) => { } }; +const handleScore = (e) => { + console.log(e, 'eee'); +}; + const passwordRuleForm = reactive({ password: [{ required: true, message: '密码不能为空', trigger: 'blur' }], newpassword1: [ diff --git a/src/views/login/component/register.vue b/src/views/login/component/register.vue index 08930c1c..36e5abd2 100644 --- a/src/views/login/component/register.vue +++ b/src/views/login/component/register.vue @@ -10,26 +10,19 @@