From a726818c17174774147bc085e687537cbb7ccee5 Mon Sep 17 00:00:00 2001 From: "Apple\\Apple" Date: Tue, 20 May 2025 02:23:06 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9Bfix(HeaderBar):=20Prevent=20flicker?= =?UTF-8?q?=20when=20unauthenticated=20users=20click=20Console=20link?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- web/src/components/HeaderBar.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/src/components/HeaderBar.js b/web/src/components/HeaderBar.js index 7bf31748..57d42a75 100644 --- a/web/src/components/HeaderBar.js +++ b/web/src/components/HeaderBar.js @@ -192,10 +192,16 @@ const HeaderBar = () => { ); } + + let targetPath = link.to; + if (link.itemKey === 'console' && !userState.user) { + targetPath = '/login'; + } + return ( handleNavLinkClick(link.itemKey)} >