Commit 9715087b54437a68e1a3c78d268a832ec92ecd81

Authored by YunaiV
1 parent a484cd51

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

yudao-framework/yudao-spring-boot-starter-captcha/pom.xml
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 13
14 <name>${project.artifactId}</name> 14 <name>${project.artifactId}</name>
15 <description>验证码拓展 15 <description>验证码拓展
16 - 1. 基于 aj-captcha 实现图形验证码,文档:https://ajcaptcha.beliefteam.cn/captcha-doc/ 16 + 1. 基于 aj-captcha 实现滑块验证码,文档:https://ajcaptcha.beliefteam.cn/captcha-doc/
17 </description> 17 </description>
18 18
19 <dependencies> 19 <dependencies>
@@ -25,8 +25,8 @@ @@ -25,8 +25,8 @@
25 25
26 <!-- DB 相关 --> 26 <!-- DB 相关 -->
27 <dependency> 27 <dependency>
28 - <groupId>org.springframework.boot</groupId>  
29 - <artifactId>spring-boot-starter-data-redis</artifactId> 28 + <groupId>cn.iocoder.boot</groupId>
  29 + <artifactId>yudao-spring-boot-starter-redis</artifactId>
30 </dependency> 30 </dependency>
31 31
32 <!-- 验证码相关 --> 32 <!-- 验证码相关 -->
yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/package-info.java
1 /** 1 /**
2 * 验证码拓展 2 * 验证码拓展
3 - * 1. 基于 aj-captcha 实现图形验证码,文档:https://ajcaptcha.beliefteam.cn/captcha-doc/ 3 + * 1. 基于 aj-captcha 实现滑块验证码,文档:https://ajcaptcha.beliefteam.cn/captcha-doc/
4 * 4 *
5 * @author 星语 5 * @author 星语
6 */ 6 */
yudao-module-system/yudao-module-system-biz/pom.xml
@@ -72,11 +72,6 @@ @@ -72,11 +72,6 @@
72 <artifactId>yudao-spring-boot-starter-redis</artifactId> 72 <artifactId>yudao-spring-boot-starter-redis</artifactId>
73 </dependency> 73 </dependency>
74 74
75 - <dependency>  
76 - <groupId>cn.iocoder.boot</groupId>  
77 - <artifactId>yudao-spring-boot-starter-captcha</artifactId>  
78 - </dependency>  
79 -  
80 <!-- Job 定时任务相关 --> 75 <!-- Job 定时任务相关 -->
81 <dependency> 76 <dependency>
82 <groupId>cn.iocoder.boot</groupId> 77 <groupId>cn.iocoder.boot</groupId>
@@ -102,6 +97,11 @@ @@ -102,6 +97,11 @@
102 <artifactId>yudao-spring-boot-starter-excel</artifactId> 97 <artifactId>yudao-spring-boot-starter-excel</artifactId>
103 </dependency> 98 </dependency>
104 99
  100 + <dependency>
  101 + <groupId>cn.iocoder.boot</groupId>
  102 + <artifactId>yudao-spring-boot-starter-captcha</artifactId>
  103 + </dependency>
  104 +
105 </dependencies> 105 </dependencies>
106 106
107 </project> 107 </project>
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthLoginReqVO.java
@@ -33,6 +33,8 @@ public class AuthLoginReqVO { @@ -33,6 +33,8 @@ public class AuthLoginReqVO {
33 @Length(min = 4, max = 16, message = "密码长度为 4-16 位") 33 @Length(min = 4, max = 16, message = "密码长度为 4-16 位")
34 private String password; 34 private String password;
35 35
  36 + // ========== 图片验证码相关 ==========
  37 +
36 @ApiModelProperty(value = "验证码", required = true, 38 @ApiModelProperty(value = "验证码", required = true,
37 example = "PfcH6mgr8tpXuMWFjvW6YVaqrswIuwmWI5dsVZSg7sGpWtDCUbHuDEXl3cFB1+VvCC/rAkSwK8Fad52FSuncVg==", 39 example = "PfcH6mgr8tpXuMWFjvW6YVaqrswIuwmWI5dsVZSg7sGpWtDCUbHuDEXl3cFB1+VvCC/rAkSwK8Fad52FSuncVg==",
38 notes = "验证码开启时,需要传递") 40 notes = "验证码开启时,需要传递")
yudao-ui-admin-uniapp/config.js
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 module.exports = { 2 module.exports = {
3 // baseUrl: 'http://localhost:8080', 3 // baseUrl: 'http://localhost:8080',
4 baseUrl: 'http://localhost:48080', 4 baseUrl: 'http://localhost:48080',
5 - baseApi: 'admin-api', 5 + baseApi: '/admin-api',
6 // 应用信息 6 // 应用信息
7 appInfo: { 7 appInfo: {
8 // 应用名称 8 // 应用名称
yudao-ui-admin-uniapp/pages/login.vue
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
39 }, 39 },
40 data() { 40 data() {
41 return { 41 return {
42 - captchaEnabled: true, 42 + captchaEnabled: true, // 验证码开关 TODO 芋艿:需要抽到配置里
43 globalConfig: getApp().globalData.config, 43 globalConfig: getApp().globalData.config,
44 loginForm: { 44 loginForm: {
45 username: "admin", 45 username: "admin",
@@ -66,14 +66,19 @@ @@ -66,14 +66,19 @@
66 } else if (this.loginForm.password === "") { 66 } else if (this.loginForm.password === "") {
67 this.$modal.msgError("请输入您的密码") 67 this.$modal.msgError("请输入您的密码")
68 } else { 68 } else {
69 - this.$modal.loading("登录中,请耐心等待...")  
70 - // 显示验证码  
71 - this.$refs.verify.show() 69 + // 显示验证码
  70 + if (this.captchaEnabled) {
  71 + this.$refs.verify.show()
  72 + } else { // 直接登录
  73 + await this.pwdLogin({})
  74 + }
72 } 75 }
73 }, 76 },
74 // 密码登录 77 // 密码登录
75 - async pwdLogin(params) {  
76 - this.loginForm.captchaVerification = params.captchaVerification 78 + async pwdLogin(captchaParams) {
  79 + this.$modal.loading("登录中,请耐心等待...")
  80 + // 执行登录
  81 + this.loginForm.captchaVerification = captchaParams.captchaVerification
77 this.$store.dispatch('Login', this.loginForm).then(() => { 82 this.$store.dispatch('Login', this.loginForm).then(() => {
78 this.$modal.closeLoading() 83 this.$modal.closeLoading()
79 this.loginSuccess() 84 this.loginSuccess()