From 32098b69ac36f1dc03ad25ebd9f219adc67b5447 Mon Sep 17 00:00:00 2001 From: "weicw1996@qq.com" Date: Mon, 14 Sep 2026 19:01:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(hjc-web):=20=E4=BF=AE=E5=A4=8D=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=90=8E=E7=99=BB=E5=BD=95=E6=80=81=E4=B8=A2=E4=B8=80?= =?UTF-8?q?=E5=8D=8A=EF=BC=8C=E4=BB=A5=E5=8F=8A=E9=A1=B6=E6=A0=8F=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E5=90=8D=E5=8F=96=E9=94=99=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - useHjcAuth:登录用户信息补持久化到 hjc_user cookie。原先用 useState,只活在内存与 本次 SSR payload 里,刷新后归 null,顶栏企业名退化成占位的「企业」,登录态看着像丢了 一半;H5 端把用户信息存本地存储,PC 端用同名 cookie 对齐。它**只用于展示**,鉴权一律 以 JWT 为准(后端不读用户信息)。顺带抽出 setCredentials() 统一写入 token + 展示信息。 - HjcUserBar:loggedIn 改 computed —— 原来 ref(isLoggedIn()) 只在挂载那一刻求值一次, 之后别处清凭据(401 处理、另一页签退出)本组件不跟着变;企业名改取 username 而非 nickname —— 核心实例建号时会把 nickname 无条件覆盖成打码手机号,拿它当企业名是错的, username 才是「企业名称(登录账号)」。 - login:验证码图 object-cover 改 object-contain,避免被裁掉。 - tender/orders:改用 useRequestFetch()。SSR 期间裸 $fetch 不会把浏览器 Cookie 转发给 站内 /api 代理,代理会变成匿名调用并返回 code=401,从而被 401 分支误判为「凭据失效」 ——刷新页面等于把用户登出。 --- app/components/HjcUserBar.vue | 18 ++++++++++++++-- app/composables/useHjcAuth.ts | 39 +++++++++++++++++++++++++++++------ app/pages/login.vue | 2 +- app/pages/tender/orders.vue | 15 +++++++++++++- 4 files changed, 64 insertions(+), 10 deletions(-) diff --git a/app/components/HjcUserBar.vue b/app/components/HjcUserBar.vue index 5ae2533..b302800 100644 --- a/app/components/HjcUserBar.vue +++ b/app/components/HjcUserBar.vue @@ -1,7 +1,7 @@