Commit 6eb1ba95 by Apple\Apple

馃悰fix(HeaderBar): Prevent flicker when unauthenticated users click Console link

Previously, when an unauthenticated user clicked the "Console" navigation
link, the application would first attempt to navigate to '/console'.
This would then trigger a redirect to '/login', causing a brief flicker
between the two pages.

This commit modifies the `renderNavLinks` function in `HeaderBar.js`
to proactively check the user's authentication status. If the user is
not logged in and clicks the "Console" link, the navigation target
is directly set to '/login', avoiding the intermediate redirect and
eliminating the flickering effect.
parent 83ea1b2f
...@@ -192,10 +192,16 @@ const HeaderBar = () => { ...@@ -192,10 +192,16 @@ const HeaderBar = () => {
</a> </a>
); );
} }
let targetPath = link.to;
if (link.itemKey === 'console' && !userState.user) {
targetPath = '/login';
}
return ( return (
<Link <Link
key={link.itemKey} key={link.itemKey}
to={link.to} to={targetPath}
className={commonLinkClasses} className={commonLinkClasses}
onClick={() => handleNavLinkClick(link.itemKey)} onClick={() => handleNavLinkClick(link.itemKey)}
> >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment