diff --git a/chat2db-client/src/layouts/GlobalLayout/index.tsx b/chat2db-client/src/layouts/GlobalLayout/index.tsx index 65d9aed54..d14ce7a37 100644 --- a/chat2db-client/src/layouts/GlobalLayout/index.tsx +++ b/chat2db-client/src/layouts/GlobalLayout/index.tsx @@ -1,4 +1,4 @@ -import React, { useLayoutEffect, useState } from 'react'; +import React, { useEffect, useLayoutEffect, useState } from 'react'; import usePollRequestService, { ServiceStatus } from '@/hooks/usePollRequestService'; import i18n, { isEn } from '@/i18n'; import { Button, ConfigProvider, Spin, Tooltip } from 'antd'; @@ -14,7 +14,7 @@ import { GithubOutlined, SyncOutlined, WechatOutlined } from '@ant-design/icons' import { ThemeType } from '@/constants'; import GlobalComponent from '../init/GlobalComponent'; import styles from './index.less'; -import { useUserStore } from '@/store/user' +import { useUserStore, queryCurUser } from '@/store/user' const GlobalLayout = () => { const [appTheme, setAppTheme] = useTheme(); @@ -40,6 +40,12 @@ const GlobalLayout = () => { monitorOsTheme(); }, []); + useEffect(() => { + if(serviceStatus === ServiceStatus.SUCCESS){ + queryCurUser(); + } + }, [serviceStatus]); + // 监听系统(OS)主题变化 const monitorOsTheme = () => { function change(e: any) { diff --git a/chat2db-client/src/layouts/init/init.ts b/chat2db-client/src/layouts/init/init.ts index 4599213f6..5d26280a5 100644 --- a/chat2db-client/src/layouts/init/init.ts +++ b/chat2db-client/src/layouts/init/init.ts @@ -1,5 +1,4 @@ import { clearOlderLocalStorage } from '@/utils'; -import initLoginInfo from './initLoginInfo'; import initIndexedDB from './initIndexedDB'; import registerElectronApi from './registerElectronApi'; import registerMessage from './registerMessage'; @@ -9,7 +8,6 @@ import { LangType } from '@/constants'; const init = () => { clearOlderLocalStorage(); - initLoginInfo(); initLang(); initIndexedDB(); diff --git a/chat2db-client/src/layouts/init/initLoginInfo.tsx b/chat2db-client/src/layouts/init/initLoginInfo.tsx deleted file mode 100644 index 9148da44a..000000000 --- a/chat2db-client/src/layouts/init/initLoginInfo.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { queryCurUser } from '@/store/user' - -/** 初始化登陆的信息 */ -const initLoginInfo = () => { - queryCurUser(); -}; - -export default initLoginInfo;