refactor(auth): centralize login status sync
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
* + AuthStatusChecker(启动时一次:派发 AuthInit)
|
||||
* + OAuthSessionSync (持续监听 NextAuth session → auth machine)
|
||||
* + UserAuthSync (auth 登录态恢复后 hydrate user machine)
|
||||
* + ChatAuthSync (持续监听 auth loginStatus → chat machine)
|
||||
*
|
||||
* 它们始终挂载,保证各页面直接 `use*State()` / `use*Dispatch()` 即可,
|
||||
* 无需在每个页面单独包裹。
|
||||
@@ -18,6 +19,7 @@ import type { ReactNode } from "react";
|
||||
import { AuthProvider } from "@/stores/auth/auth-context";
|
||||
import { AuthStatusChecker } from "@/stores/auth/auth-status-checker";
|
||||
import { OAuthSessionSync } from "@/stores/auth/oauth-session-sync";
|
||||
import { ChatAuthSync } from "@/stores/chat/chat-auth-sync";
|
||||
import { ChatProvider } from "@/stores/chat/chat-context";
|
||||
import { SidebarProvider } from "@/stores/sidebar/sidebar-context";
|
||||
import { UserAuthSync } from "@/stores/user/user-auth-sync";
|
||||
@@ -39,6 +41,7 @@ export function RootProviders({ children }: RootProvidersProps) {
|
||||
<UserAuthSync />
|
||||
<SidebarProvider>
|
||||
<ChatProvider>
|
||||
<ChatAuthSync />
|
||||
{children}
|
||||
<div id="toast-portal" />
|
||||
</ChatProvider>
|
||||
|
||||
Reference in New Issue
Block a user