修复初始化逻辑

This commit is contained in:
whyour 2022-09-23 00:17:53 +08:00
parent f2fea47336
commit 98c2a37ab6

View File

@ -41,6 +41,7 @@ export default function () {
const ws = useRef<any>(null);
const [socketMessage, setSocketMessage] = useState<any>();
const [collapsed, setCollapsed] = useState(false);
const [initLoading, setInitLoading] = useState<boolean>(true);
const {
enable: enableDarkMode,
disable: disableDarkMode,
@ -64,7 +65,6 @@ export default function () {
setSystemInfo(data);
if (!data.isInitialized) {
history.push('/initialization');
setLoading(false);
} else {
getUser();
}
@ -72,7 +72,8 @@ export default function () {
})
.catch((error) => {
console.log(error);
});
})
.finally(() => setInitLoading(false));
};
const getUser = (needLoading = true) => {
@ -192,6 +193,10 @@ export default function () {
};
}, []);
if (initLoading) {
return <PageLoading />;
}
if (['/login', '/initialization', '/error'].includes(location.pathname)) {
document.title = `${
(config.documentTitleMap as any)[location.pathname]