17 lines
421 B
TypeScript
17 lines
421 B
TypeScript
import React, { useEffect } from 'react';
|
|
import { useAuthStore } from '@/store/authStore';
|
|
|
|
interface AuthProviderProps {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
|
|
const initAuth = useAuthStore(state => state.initAuth);
|
|
|
|
useEffect(() => {
|
|
// 在应用启动时初始化认证状态
|
|
initAuth();
|
|
}, [initAuth]);
|
|
|
|
return <>{children}</>;
|
|
}; |