From 2fd1a3529000ffe1ae4090999dc89d9bb6abd493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=A9=E4=BB=9488?= <> Date: Sat, 6 Jun 2026 12:19:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=86=E7=A0=81=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/views/SystemMngr/User/ChangPwd.vue | 109 +++++++++++++++++-- opencode.json | 42 ------- 2 files changed, 100 insertions(+), 51 deletions(-) delete mode 100644 opencode.json diff --git a/admin/src/views/SystemMngr/User/ChangPwd.vue b/admin/src/views/SystemMngr/User/ChangPwd.vue index c8f069f..944bb4f 100644 --- a/admin/src/views/SystemMngr/User/ChangPwd.vue +++ b/admin/src/views/SystemMngr/User/ChangPwd.vue @@ -38,16 +38,51 @@ - + + + - + + + +
+
+ 至少8位字符 +
+
+ 包含小写字母 +
+
+ 包含大写字母 +
+
+ 包含数字 +
+
+ 包含特殊字符 +
+
- + + +
import { ref, + computed, onMounted } from 'vue'; import { @@ -69,7 +105,7 @@ ElMessageBox } from 'element-plus' import { - Iphone, Refresh + Iphone, Refresh, View, Hide } from '@element-plus/icons-vue' import { adminChangePwd,UpFileUrl,ChangInfo,GetBaseAdminUserInfo @@ -79,11 +115,36 @@ let oldpwd = ref('') let newpwd = ref('') let renewpwd = ref('') + let showOldPwd = ref(false) + let showNewPwd = ref(false) + let showRenewPwd = ref(false) let upfileurl=UpFileUrl() let headerObj={ Authorization: 'Bearer ' + sessionStorage.getItem("token") } + const hasMinLength = computed(() => newpwd.value.length >= 8) + const hasLower = computed(() => /[a-z]/.test(newpwd.value)) + const hasUpper = computed(() => /[A-Z]/.test(newpwd.value)) + const hasNumber = computed(() => /[0-9]/.test(newpwd.value)) + const hasSpecial = computed(() => /[^a-zA-Z0-9]/.test(newpwd.value)) + const validatePassword = (pwd) => { + if (pwd.length < 8) return '密码长度不能少于8位' + if (!/[a-z]/.test(pwd)) return '密码必须包含小写字母' + if (!/[A-Z]/.test(pwd)) return '密码必须包含大写字母' + if (!/[0-9]/.test(pwd)) return '密码必须包含数字' + if (!/[^a-zA-Z0-9]/.test(pwd)) return '密码必须包含特殊字符' + return '' + } const SetPwd = () => { + if (!newpwd.value) { + ElMessage.error('请输入新密码') + return + } + const errMsg = validatePassword(newpwd.value) + if (errMsg) { + ElMessage.error(errMsg) + return + } if (newpwd.value == renewpwd.value && renewpwd.value != '') { adminChangePwd({ oldpwd: oldpwd.value, @@ -92,8 +153,6 @@ if (res.status == 'ok') { ElMessageBox.alert('密码修改成功,请重新登录', '提示', { - // if you want to disable its autofocus - // autofocus: false, confirmButtonText: 'OK', callback: () => { window.location.href = "./#/login" @@ -143,6 +202,38 @@