refactor: add AppRouter to make sure useUserStore run under trpc provider
This commit is contained in:
parent
62cc934035
commit
2c5ff71725
@ -31,14 +31,29 @@ declare module '@tanstack/react-router' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AppRouter: React.FC = React.memo(() => {
|
||||||
|
const { info: userInfo } = useUserStore();
|
||||||
|
|
||||||
|
useInjectWebsiteScript();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BrowserRouter>
|
||||||
|
{/* Compatible with old routes */}
|
||||||
|
<TooltipProvider delayDuration={0}>
|
||||||
|
<RouterProvider router={router} context={{ userInfo }} />
|
||||||
|
</TooltipProvider>
|
||||||
|
|
||||||
|
<Toaster />
|
||||||
|
</BrowserRouter>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
AppRouter.displayName = 'AppRouter';
|
||||||
|
|
||||||
export const App: React.FC = React.memo(() => {
|
export const App: React.FC = React.memo(() => {
|
||||||
const rootRef = useRef<HTMLDivElement | null>(null);
|
const rootRef = useRef<HTMLDivElement | null>(null);
|
||||||
const colorScheme = useColorSchema();
|
const colorScheme = useColorSchema();
|
||||||
const algorithm =
|
const algorithm =
|
||||||
colorScheme === 'dark' ? theme.darkAlgorithm : theme.defaultAlgorithm;
|
colorScheme === 'dark' ? theme.darkAlgorithm : theme.defaultAlgorithm;
|
||||||
const { info: userInfo } = useUserStore();
|
|
||||||
|
|
||||||
useInjectWebsiteScript();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={rootRef} className="App">
|
<div ref={rootRef} className="App">
|
||||||
@ -49,14 +64,7 @@ export const App: React.FC = React.memo(() => {
|
|||||||
getPopupContainer={() => rootRef.current!}
|
getPopupContainer={() => rootRef.current!}
|
||||||
>
|
>
|
||||||
<TokenLoginContainer>
|
<TokenLoginContainer>
|
||||||
{/* Compatible with old routes */}
|
<AppRouter />
|
||||||
<BrowserRouter>
|
|
||||||
<TooltipProvider delayDuration={0}>
|
|
||||||
<RouterProvider router={router} context={{ userInfo }} />
|
|
||||||
</TooltipProvider>
|
|
||||||
|
|
||||||
<Toaster />
|
|
||||||
</BrowserRouter>
|
|
||||||
</TokenLoginContainer>
|
</TokenLoginContainer>
|
||||||
</ConfigProvider>
|
</ConfigProvider>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
|
@ -10,7 +10,7 @@ export const useSettingsStore = create<SettingsState>()(
|
|||||||
persist(
|
persist(
|
||||||
() =>
|
() =>
|
||||||
({
|
({
|
||||||
colorScheme: 'light' as const,
|
colorScheme: 'dark' as const,
|
||||||
}) as SettingsState,
|
}) as SettingsState,
|
||||||
{
|
{
|
||||||
name: 'settings',
|
name: 'settings',
|
||||||
|
Loading…
Reference in New Issue
Block a user