From 0a2091adbbdf1abafa595fd5b0208ae4d985bf09 Mon Sep 17 00:00:00 2001 From: xuemingqiang Date: Sat, 12 Jul 2025 21:33:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=89=8D=E7=AB=AF=E7=9A=84?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E5=92=8C=E7=99=BB=E5=BD=95=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/common/CaptchaController.java | 17 +++++++++-------- .../controller/system/SysLoginController.java | 4 ++-- .../ruoyi/common/core/domain/AjaxResult.java | 13 +------------ ruoyi-ui/src/store/modules/user.js | 13 +++++++------ ruoyi-ui/src/views/login.vue | 6 +++--- ruoyi-ui/src/views/register.vue | 4 ++-- ruoyi-ui/vue.config.js | 2 +- 7 files changed, 25 insertions(+), 34 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java index 2e72d1cb..4185bc6b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java @@ -47,16 +47,16 @@ public class CaptchaController @GetMapping("/captchaImage") public AjaxResult getCode(HttpServletResponse response) throws IOException { + AjaxResult ajax = AjaxResult.success(); Captcha captcha = new Captcha(); - AjaxResult ajax = AjaxResult.success(captcha); boolean captchaEnabled = configService.selectCaptchaEnabled(); - if (!captchaEnabled) - { - - captcha.setCaptchaEnabled(captchaEnabled); - - return ajax; - } + captcha.setCaptchaEnabled(captchaEnabled); +// if (captchaEnabled) +// { +// +// }else { +// captcha.setCaptchaEnabled(captchaEnabled); +// } // 保存验证码信息 String uuid = IdUtils.simpleUUID(); @@ -94,6 +94,7 @@ public class CaptchaController captcha.setUuid(uuid); captcha.setImg(Base64.encode(os.toByteArray())); + ajax.setData(captcha); return ajax; } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index e101bef5..75bfbb66 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -56,14 +56,14 @@ public class SysLoginController * @return 结果 */ @PostMapping("/login") - public AjaxResult login(@RequestBody LoginBody loginBody) + public AjaxResult login(@RequestBody LoginBody loginBody) { // 生成令牌 String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), loginBody.getUuid()); - return AjaxResult.success(token); + return AjaxResult.success("操作成功",token); } /** diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java index c939f936..20d5f17e 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java @@ -70,7 +70,7 @@ public class AjaxResult */ public static AjaxResult success() { - return AjaxResult.success("操作成功"); + return AjaxResult.success("操作成功",null); } /** @@ -83,17 +83,6 @@ public class AjaxResult return AjaxResult.success("操作成功", data); } - /** - * 返回成功消息 - * - * @param msg 返回内容 - * @return 成功消息 - */ - public static AjaxResult success(String msg) - { - return AjaxResult.success(msg, null); - } - /** * 返回成功消息 * diff --git a/ruoyi-ui/src/store/modules/user.js b/ruoyi-ui/src/store/modules/user.js index 83a7d625..0fab31a0 100644 --- a/ruoyi-ui/src/store/modules/user.js +++ b/ruoyi-ui/src/store/modules/user.js @@ -49,8 +49,9 @@ const user = { const uuid = userInfo.uuid return new Promise((resolve, reject) => { login(username, password, code, uuid).then(res => { - setToken(res.token) - commit('SET_TOKEN', res.token) + console.log('登录接口返回的数据'+res.data) + setToken(res.data) + commit('SET_TOKEN', res.data) resolve() }).catch(error => { reject(error) @@ -62,14 +63,14 @@ const user = { GetInfo({ commit, state }) { return new Promise((resolve, reject) => { getInfo().then(res => { - const user = res.user + const user = res.data.user let avatar = user.avatar || "" if (!isHttp(avatar)) { avatar = (isEmpty(avatar)) ? defAva : process.env.VUE_APP_BASE_API + avatar } - if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组 - commit('SET_ROLES', res.roles) - commit('SET_PERMISSIONS', res.permissions) + if (res.data.roles && res.data.roles.length > 0) { // 验证返回的roles是否是一个非空数组 + commit('SET_ROLES', res.data.roles) + commit('SET_PERMISSIONS', res.data.permissions) } else { commit('SET_ROLES', ['ROLE_DEFAULT']) } diff --git a/ruoyi-ui/src/views/login.vue b/ruoyi-ui/src/views/login.vue index f979f68b..00182f1a 100644 --- a/ruoyi-ui/src/views/login.vue +++ b/ruoyi-ui/src/views/login.vue @@ -111,10 +111,10 @@ export default { methods: { getCode() { getCodeImg().then(res => { - this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled + this.captchaEnabled = res.data.captchaEnabled === undefined ? true : res.data.captchaEnabled if (this.captchaEnabled) { - this.codeUrl = "data:image/gif;base64," + res.img - this.loginForm.uuid = res.uuid + this.codeUrl = "data:image/gif;base64," + res.data.img + this.loginForm.uuid = res.data.uuid } }) }, diff --git a/ruoyi-ui/src/views/register.vue b/ruoyi-ui/src/views/register.vue index f1e4ea05..44e35872 100644 --- a/ruoyi-ui/src/views/register.vue +++ b/ruoyi-ui/src/views/register.vue @@ -117,8 +117,8 @@ export default { getCodeImg().then(res => { this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled if (this.captchaEnabled) { - this.codeUrl = "data:image/gif;base64," + res.img - this.registerForm.uuid = res.uuid + this.codeUrl = "data:image/gif;base64," + res.data.img + this.registerForm.uuid = res.data.uuid } }) }, diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index a6bfb3b8..6e19d097 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -9,7 +9,7 @@ const CompressionPlugin = require('compression-webpack-plugin') const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题 -const baseUrl = 'http://localhost:8080' // 后端接口 +const baseUrl = 'http://localhost:8081' // 后端接口 const port = process.env.port || process.env.npm_config_port || 80 // 端口