From 605cd12a6ee9de4bd16dec4d2550fd1dcb09acb2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 6 Sep 2026 15:40:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AC=AC1=E7=AB=A0=E5=90=84?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E9=A1=B5=E4=B9=8B=E9=97=B4=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E4=BC=9A=E5=B8=A6=E5=87=BA=E4=B8=8A=E4=B8=80=E4=B8=AA=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E6=8A=A5=E9=94=99=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 现象:在注册页填错邀请码提交后(正确显示"邀请码错误,请重新输入"),点击"已有账号?登录" 切到登录页,登录表单顶部会原样带出这条"邀请码错误"提示——用户在登录页什么都还没做,却先看到 一句跟登录毫不相关的报错。反过来,登录密码错误后点"马上注册"也会把"账号或密码错误"带到刚打开 的注册页。 根因:errorText/errorLevel 是 tinode-web.jsx 顶层的一份全局共享状态,不跟当前显示哪个 sidepanel 绑定。Login 组件自己的"切换企业"链接会在跳转前先调用一次 onError() 清空,说明 之前已经意识到这个状态会带着走,但企业码/登录/注册/忘记密码等页面之间的其它跳转都没有做 同样的处理——其中 Register 等好几个视图目前甚至没有拿到 onError 这个 prop,需要在各处 分别补,比较分散。 修复:在 AuthOnboardingView(chapterOneViews 统一走的入口组件)里加一个以 view 为依赖的 useEffect,view 变化时统一调用 onError() 清空全局报错状态,一次性覆盖企业码/登录/注册/ 忘记密码等视图之间的所有切换路径(含浏览器前进后退),不用逐个跳转调用点分别处理。 验证:注册页提交错误邀请码复现"邀请码错误,请重新输入"后点击"登录",确认登录页不再带出 该提示;反向验证登录页密码错误后点击"马上注册",确认注册页同样不再带出"账号或密码错误"。 注:umd/index.dev.js 本轮未随此提交一起提交——auth-onboarding-view.jsx 不是按路由懒加载的 独立 chunk,此刻工作区里另有并行 agent 正在改 contact-management-view.jsx / call-panel.jsx 且未提交,重新构建的 index.dev.js 会把它们尚未提交的改动一起编译进同一个产物文件,为避免把 不相关改动混进这次提交,本次只提交源码,构建产物留给后续统一重新构建的提交处理。 Co-Authored-By: Claude Sonnet 5 --- src/views/auth-onboarding-view.jsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/views/auth-onboarding-view.jsx b/src/views/auth-onboarding-view.jsx index ec758925..6f117850 100644 --- a/src/views/auth-onboarding-view.jsx +++ b/src/views/auth-onboarding-view.jsx @@ -825,6 +825,26 @@ export default function AuthOnboardingView({ onLoginRequest, onPersistenceChange, onImRegisterRequest, onError }) { const tenantName = sessionStorage.getItem('im-tenant-name') || ''; + + // errorText/errorLevel is one flat, top-level (tinode-web.jsx) piece of state shared by every + // view in the whole app -- it's never tied to which sidepanel is showing. Login is the only view + // here that already clears it on its own (its "切换企业" link calls onError() before navigating), + // because it was written knowing it can carry a leftover error INTO the tenant screen. Every other + // transition between these auth views was still missing that: submit a bad invite code on + // Register (errorText='邀请码错误,请重新输入', view stays 'register', shown correctly), then just + // click "已有账号?登录" -- Login mounts and, since it renders the exact same errorText/errorLevel + // props, shows that same registration error as if it were a login failure, with zero user action + // on this new page. Same the other way: a stale "账号或密码错误" from Login is still sitting there + // to greet a fresh Register visit. Fixing every call site that navigates between these views + // (TenantEntry/Login/Register/... several of which don't even receive onError as a prop today) + // would be a lot of scattered one-off edits for the same bug; clearing it centrally whenever the + // resolved `view` itself changes covers all of them (button clicks and browser back/forward alike) + // from the one place they all already funnel through. + React.useEffect(() => { + if (onError) onError(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [view]); + switch (view) { case 'tenant': return {})} />; case 'login': return