From 11d94ae8c3c8175e440354c618e9146f9339e3aa Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Sat, 10 May 2025 18:31:10 +0800 Subject: [PATCH] feat: show version in sidebar --- web/src/app/home/components/home-sidebar/HomeSidebar.tsx | 5 ++++- web/src/app/infra/http/HttpClient.ts | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/web/src/app/home/components/home-sidebar/HomeSidebar.tsx b/web/src/app/home/components/home-sidebar/HomeSidebar.tsx index 848813c0..eeccc239 100644 --- a/web/src/app/home/components/home-sidebar/HomeSidebar.tsx +++ b/web/src/app/home/components/home-sidebar/HomeSidebar.tsx @@ -9,6 +9,7 @@ import { import { useRouter, usePathname } from 'next/navigation'; import { sidebarConfigList } from '@/app/home/components/home-sidebar/sidbarConfigList'; import langbotIcon from '@/app/assets/langbot-logo.webp'; +import { httpClient } from '@/app/infra/http/HttpClient'; // TODO 侧边导航栏要加动画 export default function HomeSidebar({ @@ -90,7 +91,9 @@ export default function HomeSidebar({ {/* 文字 */}
LangBot
-
v4.0.0
+
+ {httpClient.systemInfo?.version} +
{/* 菜单列表,后期可升级成配置驱动 */} diff --git a/web/src/app/infra/http/HttpClient.ts b/web/src/app/infra/http/HttpClient.ts index a7afe733..5d5606b5 100644 --- a/web/src/app/infra/http/HttpClient.ts +++ b/web/src/app/infra/http/HttpClient.ts @@ -54,6 +54,7 @@ class HttpClient { private disableToken: boolean = false; // 暂不需要SSR // private ssrInstance: AxiosInstance | null = null + public systemInfo: ApiRespSystemInfo | null = null; constructor(baseURL?: string, disableToken?: boolean) { this.instance = axios.create({ @@ -65,6 +66,12 @@ class HttpClient { }); this.disableToken = disableToken || false; this.initInterceptors(); + + if (this.systemInfo === null) { + this.getSystemInfo().then((res) => { + this.systemInfo = res; + }); + } } // 兜底URL,如果使用未配置会走到这里