🐛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.
This commit is contained in:
Apple\Apple
2025-05-20 02:23:06 +08:00
parent 26c3da3548
commit a726818c17

View File

@@ -192,10 +192,16 @@ const HeaderBar = () => {
</a>
);
}
let targetPath = link.to;
if (link.itemKey === 'console' && !userState.user) {
targetPath = '/login';
}
return (
<Link
key={link.itemKey}
to={link.to}
to={targetPath}
className={commonLinkClasses}
onClick={() => handleNavLinkClick(link.itemKey)}
>