From c60793a8e70e9d85ac5c17403aebc61d42926d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=B8=85?= Date: Mon, 22 Sep 2025 17:36:49 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E5=AF=86=E7=A0=81=E8=BF=9B=E8=A1=8C=E8=A7=84=E5=88=99?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maintain-ui/src/views/login.vue | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/maintain-ui/src/views/login.vue b/maintain-ui/src/views/login.vue index 88a03a5..d0b6577 100644 --- a/maintain-ui/src/views/login.vue +++ b/maintain-ui/src/views/login.vue @@ -19,6 +19,7 @@ auto-complete="off" placeholder="密码" @keyup.enter.native="handleLogin" + @input="checkPasswordStrength" > @@ -120,6 +121,26 @@ export default { this.getCookie(); }, methods: { + // 检查密码强度 + checkPasswordStrength() { + if (!this.loginForm.password) { + this.isPasswordStrong = false; + return; + } + let strength = 0; + // 长度检查 + if (this.loginForm.password.length >= 8) strength++; + // 包含小写字母 + if (/[a-z]/.test(this.loginForm.password)) strength++; + // 包含大写字母 + if (/[A-Z]/.test(this.loginForm.password)) strength++; + // 包含数字 + if (/[0-9]/.test(this.loginForm.password)) strength++; + // 包含特殊字符 + if (/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(this.loginForm.password)) strength++; + // 设置强度等级 + this.isPasswordStrong = strength > 4; + }, getCode() { getCodeImg().then(res => { this.captchaEnabled = res.data.captchaEnabled === undefined ? true : res.data.captchaEnabled; @@ -142,6 +163,11 @@ export default { handleLogin() { this.$refs.loginForm.validate(valid => { if (valid) { + // 再次确认密码强度 + if (!this.isPasswordStrong) { + this.$message.error("密码强度不足,请确保包含大小写字母、数字和特殊字符"); + return; + } this.loading = true; if (this.loginForm.rememberMe) { Cookies.set("username", this.loginForm.username, { expires: 30 }); -- 2.22.0