Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
maintain_service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘帅
maintain_service
Commits
c60793a8
Commit
c60793a8
authored
Sep 22, 2025
by
刘帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.用户登录输入密码进行规则校验
parent
ec98a0ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
login.vue
maintain-ui/src/views/login.vue
+26
-0
No files found.
maintain-ui/src/views/login.vue
View file @
c60793a8
...
...
@@ -19,6 +19,7 @@
auto-complete=
"off"
placeholder=
"密码"
@
keyup.enter.native=
"handleLogin"
@
input=
"checkPasswordStrength"
>
<svg-icon
slot=
"prefix"
icon-class=
"password"
class=
"el-input__icon input-icon"
/>
</el-input>
...
...
@@ -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
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment