feat(auth): 添加账户锁定功能及自动解锁机制 feat(user): 在用户模型中添加lockedUntil字段 feat(api): 实现账户锁定逻辑和剩余尝试次数提示 perf(3d): 优化3D场景状态管理性能 perf(floorplan): 优化平面图状态管理性能 chore(deps): 添加zustand依赖 chore(config): 更新安全配置锁定时间为3分钟 docs: 更新部分组件注释 style: 调整登录页面样式
45 lines
1.1 KiB
React
45 lines
1.1 KiB
React
/**
|
|
* Zustand Store 初始化组件
|
|
* 确保所有必要的 Store 在应用渲染前完成初始化
|
|
*/
|
|
|
|
import { useEffect, useState } from 'react';
|
|
import { useAuthStore } from '../stores/authStore';
|
|
import { useConfigStore } from '../stores/configStore';
|
|
import Spin from 'antd/es/spin';
|
|
|
|
const AuthInitializer = ({ children }) => {
|
|
const [allInitialized, setAllInitialized] = useState(false);
|
|
|
|
const { initialize: initializeAuth, initialized: authInitialized } = useAuthStore();
|
|
const { loadConfig, loading: configLoading } = useConfigStore();
|
|
|
|
useEffect(() => {
|
|
const initStores = async () => {
|
|
await initializeAuth();
|
|
await loadConfig();
|
|
};
|
|
|
|
initStores().then(() => {
|
|
setAllInitialized(true);
|
|
});
|
|
}, [initializeAuth, loadConfig]);
|
|
|
|
if (!allInitialized) {
|
|
return (
|
|
<div style={{
|
|
display: 'flex',
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
height: '100vh'
|
|
}}>
|
|
<Spin size="large" />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return children;
|
|
};
|
|
|
|
export default AuthInitializer;
|