mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-31 14:09:42 +07:00
🐛 fix: slove when logout always show loading (#10284)
fix: slove when logout always show loading
This commit is contained in:
@@ -36,27 +36,9 @@ const RootLayout = (props: { locale: Locales }) => {
|
||||
);
|
||||
};
|
||||
|
||||
// Hydration gate loader - waits for client state to be ready before rendering
|
||||
// Hydration gate loader -always return true to bypass hydration gate
|
||||
const hydrationGateLoader: LoaderFunction = () => {
|
||||
const { isAppHydrated } = useGlobalStore.getState();
|
||||
|
||||
// 如果状态已经就绪,直接放行
|
||||
if (isAppHydrated) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 否则,返回一个 Promise,"暂停" 渲染
|
||||
return new Promise((resolve) => {
|
||||
console.log('[HydrationGate] Waiting for client state...');
|
||||
// 订阅 useGlobalStore 的变化
|
||||
const unsubscribe = useGlobalStore.subscribe((state) => {
|
||||
if (state.isAppHydrated) {
|
||||
console.log('[HydrationGate] Client state ready. Gate opened!');
|
||||
unsubscribe(); // 清理订阅
|
||||
resolve(null); // Promise 完成,门卫放行
|
||||
}
|
||||
});
|
||||
});
|
||||
return true
|
||||
};
|
||||
|
||||
// Create desktop router configuration
|
||||
|
||||
@@ -34,27 +34,9 @@ const RootLayout = (props: { locale: Locales }) => (
|
||||
</>
|
||||
);
|
||||
|
||||
// Hydration gate loader - waits for client state to be ready before rendering
|
||||
// Hydration gate loader -always return true to bypass hydration gate
|
||||
const hydrationGateLoader: LoaderFunction = () => {
|
||||
const { isAppHydrated } = useGlobalStore.getState();
|
||||
|
||||
// 如果状态已经就绪,直接放行
|
||||
if (isAppHydrated) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 否则,返回一个 Promise,"暂停" 渲染
|
||||
return new Promise((resolve) => {
|
||||
console.log('[HydrationGate] Waiting for client state...');
|
||||
// 订阅 useGlobalStore 的变化
|
||||
const unsubscribe = useGlobalStore.subscribe((state) => {
|
||||
if (state.isAppHydrated) {
|
||||
console.log('[HydrationGate] Client state ready. Gate opened!');
|
||||
unsubscribe(); // 清理订阅
|
||||
resolve(null); // Promise 完成,门卫放行
|
||||
}
|
||||
});
|
||||
});
|
||||
return true
|
||||
};
|
||||
|
||||
// Create mobile router configuration
|
||||
|
||||
Reference in New Issue
Block a user