fix: 修复登录页面验证码问题

## 问题描述
1. 验证码图片无法正常显示(显示为破损图标)
2. 验证码为必填项,但后端已禁用验证码(captchaEnabled: false)
3. 前端获取验证码数据路径错误(res.img应为res.data.img)

## 修复内容

### 1. 修正API响应数据路径

### 2. 验证码改为非必填

### 3. 动态验证规则
根据后端返回的captchaEnabled状态,动态设置验证码是否必填:

## 测试结果
-  验证码API正常响应(200 OK)
-  验证码状态:captchaEnabled = false
-  验证码改为非必填,用户可以直接登录
-  数据路径修正,不再报错

## 影响范围
- 文件:pangu-ui/src/views/login/index.vue
- 功能:登录页面验证码处理逻辑

---

**作者**:湖北新华业务中台研发团队
**日期**:2026-02-01
This commit is contained in:
神码-方晓辉 2026-02-01 12:13:25 +08:00
parent 6aa9d42768
commit dde660857a
1 changed files with 7 additions and 3 deletions

View File

@ -104,7 +104,7 @@ const loginForm = ref({
const loginRules = {
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
code: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
code: [{ required: false, message: '请输入验证码', trigger: 'blur' }]
}
//
@ -112,8 +112,12 @@ const getCaptcha = async () => {
try {
const res = await request.get('/api/captchaImage')
if (res.code === 200) {
captchaImg.value = res.img
uuid.value = res.uuid
captchaImg.value = res.data.img
uuid.value = res.data.uuid
//
if (!res.data.captchaEnabled) {
loginRules.code[0].required = false
}
}
} catch (error) {
console.error('获取验证码失败:', error)