From 52ec2c0f36d1111978cf92a808dc970c54648fa8 Mon Sep 17 00:00:00 2001 From: Hermes CI Fix Date: Tue, 11 Aug 2026 11:32:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=99=BB=E5=BD=95=E9=A1=B5entity=5Fid?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E5=8F=96login=E5=93=8D=E5=BA=94=E9=A1=B6?= =?UTF-8?q?=E5=B1=82=E5=AD=97=E6=AE=B5=20=E2=80=94=20user=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E6=97=A0entity=5Fid=E5=AF=BC=E8=87=B4cma=5Fentity=5Fi?= =?UTF-8?q?d=E6=81=92=E4=B8=BA1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - login响应结构: {token, entity_id, entity_name, entity_short_name, user:{...}} - 原代码读 res.user?.entity_id ?? 1 → 登录博海(2)却存1 → 页面显式传参1与token绑定2不一致 → get_entity_id返回403 - 改为 res.entity_id / res.entity_short_name(与MainLayout切换器存储逻辑一致) --- frontend/src/views/Login.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/Login.vue b/frontend/src/views/Login.vue index e7de1dc6..0c888c11 100644 --- a/frontend/src/views/Login.vue +++ b/frontend/src/views/Login.vue @@ -60,8 +60,8 @@ async function handleLogin() { const res: any = await authApi.login({ ...form, entity_id: Number(form.entity_id) }) localStorage.setItem('cma_token', res.token) localStorage.setItem('cma_user', JSON.stringify(res.user)) - localStorage.setItem('cma_entity_id', String(res.user?.entity_id ?? 1)) - localStorage.setItem('cma_entity_name', res.user?.entity_short_name || res.user?.entity_name || '') + localStorage.setItem('cma_entity_id', String(res.entity_id ?? res.user?.entity_id ?? 1)) + localStorage.setItem('cma_entity_name', res.entity_short_name || res.entity_name || '') router.push('/dashboard') } catch (e: any) { ElMessage.error(e?.response?.data?.detail || '登录失败')