修改前端的验证码和登录相关的接口

This commit is contained in:
2025-07-12 21:33:22 +08:00
parent 59b4a5e8cf
commit 0a2091adbb
7 changed files with 25 additions and 34 deletions

View File

@ -47,16 +47,16 @@ public class CaptchaController
@GetMapping("/captchaImage")
public AjaxResult<Captcha> getCode(HttpServletResponse response) throws IOException
{
AjaxResult<Captcha> ajax = AjaxResult.success();
Captcha captcha = new Captcha();
AjaxResult<Captcha> 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;
}
}

View File

@ -56,14 +56,14 @@ public class SysLoginController
* @return 结果
*/
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody)
public AjaxResult<String> login(@RequestBody LoginBody loginBody)
{
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
return AjaxResult.success(token);
return AjaxResult.success("操作成功",token);
}
/**

View File

@ -70,7 +70,7 @@ public class AjaxResult<T>
*/
public static <T> AjaxResult<T> success()
{
return AjaxResult.success("操作成功");
return AjaxResult.success("操作成功",null);
}
/**
@ -83,17 +83,6 @@ public class AjaxResult<T>
return AjaxResult.success("操作成功", data);
}
/**
* 返回成功消息
*
* @param msg 返回内容
* @return 成功消息
*/
public static <T> AjaxResult<T> success(String msg)
{
return AjaxResult.success(msg, null);
}
/**
* 返回成功消息
*

View File

@ -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'])
}

View File

@ -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
}
})
},

View File

@ -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
}
})
},

View File

@ -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 // 端口