Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
有来技术
vue3-element-admin
提交
0bb7cf39
V
vue3-element-admin
项目概览
有来技术
/
vue3-element-admin
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue3-element-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0bb7cf39
编写于
3月 25, 2023
作者:
H
haoxr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 登录校验失败重新获取验证码
上级
ab872ba2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
45 addition
and
24 deletion
+45
-24
src/views/login/index.vue
src/views/login/index.vue
+45
-24
未找到文件。
src/views/login/index.vue
浏览文件 @
0bb7cf39
...
...
@@ -105,6 +105,26 @@ import { LoginData } from '@/api/auth/types';
const
userStore
=
useUserStore
();
const
route
=
useRoute
();
/**
* 按钮loading
*/
const
loading
=
ref
(
false
);
/**
* 是否大写锁定
*/
const
isCapslock
=
ref
(
false
);
/**
* 密码是否可见
*/
const
passwordVisible
=
ref
(
false
);
/**
* 验证码图片Base64字符串
*/
const
captchaBase64
=
ref
();
/**
* 登录表单引用
*/
const
loginFormRef
=
ref
(
ElForm
);
const
loginData
=
ref
<
LoginData
>
({
...
...
@@ -114,16 +134,14 @@ const loginData = ref<LoginData>({
const
loginRules
=
{
username
:
[{
required
:
true
,
trigger
:
'
blur
'
}],
password
:
[{
required
:
true
,
trigger
:
'
blur
'
,
validator
:
validatePassword
}],
password
:
[{
required
:
true
,
trigger
:
'
blur
'
,
validator
:
passwordValidator
}],
verifyCode
:
[{
required
:
true
,
trigger
:
'
blur
'
}]
};
const
passwordVisible
=
ref
(
false
);
const
captchaBase64
=
ref
();
const
loading
=
ref
(
false
);
function
validatePassword
(
rule
:
any
,
value
:
any
,
callback
:
any
)
{
/**
* 密码校验器
*/
function
passwordValidator
(
rule
:
any
,
value
:
any
,
callback
:
any
)
{
if
(
value
.
length
<
6
)
{
callback
(
new
Error
(
'
The password can not be less than 6 digits
'
));
}
else
{
...
...
@@ -131,16 +149,16 @@ function validatePassword(rule: any, value: any, callback: any) {
}
}
/
/ 是否大写锁定
const
isCapslock
=
ref
(
false
);
/
**
* 检查输入大小写状态
*/
function
checkCapslock
(
e
:
any
)
{
const
{
key
}
=
e
;
isCapslock
.
value
=
key
&&
key
.
length
===
1
&&
key
>=
'
A
'
&&
key
<=
'
Z
'
;
}
/**
* 验证码
*
获取
验证码
*/
function
getCaptcha
()
{
getCaptchaApi
().
then
(({
data
})
=>
{
...
...
@@ -176,9 +194,12 @@ function handleLogin() {
router
.
push
({
path
:
redirect
,
query
:
otherQueryParams
});
})
.
catch
(()
=>
{
// 验证失败,重新生成验证码
getCaptcha
();
})
.
finally
(()
=>
{
loading
.
value
=
false
;
getCaptcha
();
});
}
});
...
...
@@ -190,18 +211,6 @@ onMounted(() => {
</
script
>
<
style
lang=
"scss"
scoped
>
.captcha
{
position
:
absolute
;
right
:
0
;
top
:
0
;
img
{
height
:
48px
;
width
:
120px
;
cursor
:
pointer
;
}
}
.login-container
{
min-height
:
100%
;
width
:
100%
;
...
...
@@ -214,6 +223,18 @@ onMounted(() => {
padding
:
160px
35px
0
;
margin
:
0
auto
;
overflow
:
hidden
;
.captcha
{
position
:
absolute
;
right
:
0
;
top
:
0
;
img
{
height
:
48px
;
width
:
120px
;
cursor
:
pointer
;
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录