Initial commit: GovAI 政务AI平台

This commit is contained in:
freedakgmail
2026-06-15 23:48:37 +08:00
commit 0f490f72a9
245 changed files with 51669 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
"use client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useRef, useEffect } from "react";
import { useAuthStore } from "@/stores/auth";
import { TooltipProvider } from "@/components/ui/tooltip";
function AuthLoader({ children }: { children: React.ReactNode }) {
const fetchUser = useAuthStore((s) => s.fetchUser);
const isLoading = useAuthStore((s) => s.isLoading);
useEffect(() => {
fetchUser();
}, [fetchUser]);
if (isLoading) {
return (
<div className="flex h-screen items-center justify-center">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary" />
</div>
);
}
return <>{children}</>;
}
const createQueryClient = () =>
new QueryClient({
defaultOptions: {
queries: {
staleTime: 5 * 60 * 1000,
gcTime: 10 * 60 * 1000,
refetchOnWindowFocus: false,
retry: 1,
refetchOnMount: false,
},
},
});
export function Providers({ children }: { children: React.ReactNode }) {
const queryClientRef = useRef<QueryClient>(null);
if (!queryClientRef.current) {
queryClientRef.current = createQueryClient();
}
return (
<QueryClientProvider client={queryClientRef.current}>
<TooltipProvider>
<AuthLoader>{children}</AuthLoader>
</TooltipProvider>
</QueryClientProvider>
);
}