From a7cff0df66fd3870a0a365584a5fcb284ef2fa11 Mon Sep 17 00:00:00 2001 From: lencx Date: Fri, 6 Jan 2023 10:45:05 +0800 Subject: [PATCH] fix: build error --- src/layout/index.tsx | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/layout/index.tsx b/src/layout/index.tsx index 99f70d4..2def6af 100644 --- a/src/layout/index.tsx +++ b/src/layout/index.tsx @@ -5,29 +5,35 @@ import { useNavigate, useLocation } from 'react-router-dom'; import { getName, getVersion } from '@tauri-apps/api/app'; import { invoke } from '@tauri-apps/api'; +import useInit from '@/hooks/useInit'; import Routes, { menuItems } from '@/routes'; import './index.scss'; const { Content, Footer, Sider } = Layout; -const appName = await getName(); -const appVersion = await getVersion(); -const appTheme = await invoke("get_theme"); - export default function ChatLayout() { const [collapsed, setCollapsed] = useState(false); + const [appInfo, setAppInfo] = useState>({}); const location = useLocation(); const go = useNavigate(); + useInit(async () => { + setAppInfo({ + appName: await getName(), + appVersion: await getVersion(), + appTheme: await invoke("get_theme"), + }); + }) + const checkAppUpdate = async () => { - await invoke('run_check_update', { silent: false }); + await invoke('run_check_update', { silent: false }); } return ( - + setCollapsed(value)} @@ -43,9 +49,9 @@ export default function ChatLayout() { >
- {appName} + {appInfo.appName} - {appVersion} + {appInfo.appVersion} @@ -55,7 +61,7 @@ export default function ChatLayout() {