🐛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:
@@ -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)}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user