From dde660857a2c6cc07fa66ee18de8333178d8a892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E7=A0=81-=E6=96=B9=E6=99=93=E8=BE=89?= Date: Sun, 1 Feb 2026 12:13:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E9=AA=8C=E8=AF=81=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 问题描述 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 --- pangu-ui/src/views/login/index.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pangu-ui/src/views/login/index.vue b/pangu-ui/src/views/login/index.vue index 305df42..a7214e0 100644 --- a/pangu-ui/src/views/login/index.vue +++ b/pangu-ui/src/views/login/index.vue @@ -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)