密码校验

main
岩仔88 2 weeks ago
parent 677b76c6f7
commit 2fd1a35290

@ -38,16 +38,51 @@
<el-row style="padding: 20px;margin:10px ;">
<el-col :span="16">
<el-form-item label="旧密码">
<el-input size="large" v-model="oldpwd" type="password" placeholder="新密码"
style=" margin: auto 20px;" />
<el-input size="large" v-model="oldpwd" :type="showOldPwd ? 'text' : 'password'" placeholder="旧密码"
style=" margin: auto 20px;">
<template #suffix>
<el-icon class="pwd-eye" @click="showOldPwd = !showOldPwd">
<View v-if="showOldPwd" /><Hide v-else />
</el-icon>
</template>
</el-input>
</el-form-item>
<el-form-item label="新密码">
<el-input size="large" v-model="newpwd" type="password" placeholder="新密码"
style=" margin: auto 20px;" />
<el-input size="large" v-model="newpwd" :type="showNewPwd ? 'text' : 'password'" placeholder="新密码"
style=" margin: auto 20px;">
<template #suffix>
<el-icon class="pwd-eye" @click="showNewPwd = !showNewPwd">
<View v-if="showNewPwd" /><Hide v-else />
</el-icon>
</template>
</el-input>
<div class="pwd-rules" v-if="newpwd.length > 0">
<div :class="['pwd-rule-item', hasMinLength ? 'pass' : 'fail']">
<span class="pwd-rule-dot"></span> 至少8位字符
</div>
<div :class="['pwd-rule-item', hasLower ? 'pass' : 'fail']">
<span class="pwd-rule-dot"></span> 包含小写字母
</div>
<div :class="['pwd-rule-item', hasUpper ? 'pass' : 'fail']">
<span class="pwd-rule-dot"></span> 包含大写字母
</div>
<div :class="['pwd-rule-item', hasNumber ? 'pass' : 'fail']">
<span class="pwd-rule-dot"></span> 包含数字
</div>
<div :class="['pwd-rule-item', hasSpecial ? 'pass' : 'fail']">
<span class="pwd-rule-dot"></span> 包含特殊字符
</div>
</div>
</el-form-item>
<el-form-item label="再次输入">
<el-input size="large" v-model="renewpwd" type="password" placeholder="再次输入"
style=" margin: auto 20px;" />
<el-input size="large" v-model="renewpwd" :type="showRenewPwd ? 'text' : 'password'" placeholder="再次输入"
style=" margin: auto 20px;">
<template #suffix>
<el-icon class="pwd-eye" @click="showRenewPwd = !showRenewPwd">
<View v-if="showRenewPwd" /><Hide v-else />
</el-icon>
</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="8" style="display:flex;align-items:center;"><el-button type="primary" size="large"
@ -62,6 +97,7 @@
<script setup>
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 @@
</script>
<style scoped>
.pwd-rules {
width: 100%;
margin: 4px 20px 0;
font-size: 12px;
}
.pwd-rule-item {
display: flex;
align-items: center;
line-height: 22px;
}
.pwd-rule-dot {
display: inline-block;
width: 6px;
height: 6px;
border-radius: 50%;
margin-right: 6px;
}
.pwd-rule-item.pass {
color: #67c23a;
}
.pwd-rule-item.pass .pwd-rule-dot {
background: #67c23a;
}
.pwd-rule-item.fail {
color: #f56c6c;
}
.pwd-rule-item.fail .pwd-rule-dot {
background: #f56c6c;
}
.pwd-eye {
cursor: pointer;
}
.erweima_tu {
height: 310px;

@ -1,42 +0,0 @@
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["oh-my-openagent"],
"mcp": {
"playwright-server": {
"enabled": true,
"type": "local",
"command": ["npx", "-y", "@executeautomation/playwright-mcp-server"]
}
},
"provider":{
"minimax-yangzong": {
"npm": "@ai-sdk/anthropic",
"options": {
"baseURL": "https://api.minimaxi.com/anthropic/v1",
"apiKey": "{env:YANG_MINMAX_KEY}"
},
"models": {
"MiniMax-M2.7": {
"name": "MiniMax-M2.7"
}
}
},
"yan-ZhiPu": {
"options": {
"baseURL": "https://open.bigmodel.cn/api/coding/paas/v4",
"apiKey": "{env:YAN_ZHIPU_API_KEY}"
},
"models": {
"GLM-4.5-Air": {
"name": "GLM-4.5-Air"
},
"GLM-4.7": {
"name": "GLM-4.7"
},
"GLM-5": {
"name": "GLM-5"
}
}
}
}
}
Loading…
Cancel
Save