管理后台的 uniapp 验证码,增加开关

This commit is contained in:
YunaiV 2022-09-04 17:44:26 +08:00
parent a484cd5193
commit 9715087b54
6 changed files with 23 additions and 16 deletions

View File

@ -13,7 +13,7 @@
<name>${project.artifactId}</name> <name>${project.artifactId}</name>
<description>验证码拓展 <description>验证码拓展
1. 基于 aj-captcha 实现图形验证码文档https://ajcaptcha.beliefteam.cn/captcha-doc/ 1. 基于 aj-captcha 实现滑块验证码文档https://ajcaptcha.beliefteam.cn/captcha-doc/
</description> </description>
<dependencies> <dependencies>
@ -25,8 +25,8 @@
<!-- DB 相关 --> <!-- DB 相关 -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>cn.iocoder.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId> <artifactId>yudao-spring-boot-starter-redis</artifactId>
</dependency> </dependency>
<!-- 验证码相关 --> <!-- 验证码相关 -->

View File

@ -1,6 +1,6 @@
/** /**
* 验证码拓展 * 验证码拓展
* 1. 基于 aj-captcha 实现图形验证码文档https://ajcaptcha.beliefteam.cn/captcha-doc/ * 1. 基于 aj-captcha 实现滑块验证码文档https://ajcaptcha.beliefteam.cn/captcha-doc/
* *
* @author 星语 * @author 星语
*/ */

View File

@ -72,11 +72,6 @@
<artifactId>yudao-spring-boot-starter-redis</artifactId> <artifactId>yudao-spring-boot-starter-redis</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-captcha</artifactId>
</dependency>
<!-- Job 定时任务相关 --> <!-- Job 定时任务相关 -->
<dependency> <dependency>
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>
@ -102,6 +97,11 @@
<artifactId>yudao-spring-boot-starter-excel</artifactId> <artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-captcha</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -33,6 +33,8 @@ public class AuthLoginReqVO {
@Length(min = 4, max = 16, message = "密码长度为 4-16 位") @Length(min = 4, max = 16, message = "密码长度为 4-16 位")
private String password; private String password;
// ========== 图片验证码相关 ==========
@ApiModelProperty(value = "验证码", required = true, @ApiModelProperty(value = "验证码", required = true,
example = "PfcH6mgr8tpXuMWFjvW6YVaqrswIuwmWI5dsVZSg7sGpWtDCUbHuDEXl3cFB1+VvCC/rAkSwK8Fad52FSuncVg==", example = "PfcH6mgr8tpXuMWFjvW6YVaqrswIuwmWI5dsVZSg7sGpWtDCUbHuDEXl3cFB1+VvCC/rAkSwK8Fad52FSuncVg==",
notes = "验证码开启时,需要传递") notes = "验证码开启时,需要传递")

View File

@ -2,7 +2,7 @@
module.exports = { module.exports = {
// baseUrl: 'http://localhost:8080', // baseUrl: 'http://localhost:8080',
baseUrl: 'http://localhost:48080', baseUrl: 'http://localhost:48080',
baseApi: 'admin-api', baseApi: '/admin-api',
// 应用信息 // 应用信息
appInfo: { appInfo: {
// 应用名称 // 应用名称

View File

@ -39,7 +39,7 @@
}, },
data() { data() {
return { return {
captchaEnabled: true, captchaEnabled: true, // TODO
globalConfig: getApp().globalData.config, globalConfig: getApp().globalData.config,
loginForm: { loginForm: {
username: "admin", username: "admin",
@ -66,14 +66,19 @@
} else if (this.loginForm.password === "") { } else if (this.loginForm.password === "") {
this.$modal.msgError("请输入您的密码") this.$modal.msgError("请输入您的密码")
} else { } else {
this.$modal.loading("登录中,请耐心等待...") //
// if (this.captchaEnabled) {
this.$refs.verify.show() this.$refs.verify.show()
} else { //
await this.pwdLogin({})
}
} }
}, },
// //
async pwdLogin(params) { async pwdLogin(captchaParams) {
this.loginForm.captchaVerification = params.captchaVerification this.$modal.loading("登录中,请耐心等待...")
//
this.loginForm.captchaVerification = captchaParams.captchaVerification
this.$store.dispatch('Login', this.loginForm).then(() => { this.$store.dispatch('Login', this.loginForm).then(() => {
this.$modal.closeLoading() this.$modal.closeLoading()
this.loginSuccess() this.loginSuccess()