fix: avoid the entire app layout re render on route change

This commit is contained in:
Louis 2025-09-18 18:44:21 +07:00
parent be83395f69
commit 5f6a68d844
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2

View File

@ -192,17 +192,16 @@ const LogsLayout = () => {
}
function RootLayout() {
const pathname = useRouterState({
select: (state) => state.location.pathname,
})
const isLocalAPIServerLogsRoute = useMemo(
() =>
const getInitialLayoutType = () => {
const pathname = window.location.pathname
return (
pathname === route.localApiServerlogs ||
pathname === route.systemMonitor ||
pathname === route.appLogs,
[pathname]
)
pathname === route.appLogs
)
}
const IS_LOGS_ROUTE = getInitialLayoutType()
return (
<Fragment>
<ServiceHubProvider>
@ -214,7 +213,7 @@ function RootLayout() {
<AuthProvider>
<DataProvider />
<GlobalEventHandler />
{isLocalAPIServerLogsRoute ? <LogsLayout /> : <AppLayout />}
{IS_LOGS_ROUTE ? <LogsLayout /> : <AppLayout />}
</AuthProvider>
</ExtensionProvider>
{/* {isLocalAPIServerLogsRoute ? <LogsLayout /> : <AppLayout />} */}