From 5361f4e12710b9057e537aed08f1c62025761f47 Mon Sep 17 00:00:00 2001 From: shuai Date: Tue, 11 Apr 2023 15:54:17 +0800 Subject: [PATCH] fix: generator add reviosn --- ui/src/common/interface.ts | 1 + ui/src/components/PageTags/index.tsx | 3 ++- ui/src/stores/siteInfo.ts | 8 +++++--- ui/src/utils/guard.ts | 4 +++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ui/src/common/interface.ts b/ui/src/common/interface.ts index cb6b63e3..640efcaa 100644 --- a/ui/src/common/interface.ts +++ b/ui/src/common/interface.ts @@ -328,6 +328,7 @@ export interface SiteSettings { theme: AdminSettingsTheme; site_seo: AdminSettingsSeo; version: string; + revision: string; } export interface AdminSettingBranding { diff --git a/ui/src/components/PageTags/index.tsx b/ui/src/components/PageTags/index.tsx index 4f663ac1..bd6d02a4 100644 --- a/ui/src/components/PageTags/index.tsx +++ b/ui/src/components/PageTags/index.tsx @@ -11,6 +11,7 @@ const Index: FC = () => { (state) => state.items, ); const appVersion = siteInfoStore((_) => _.version); + const hashVersion = siteInfoStore((_) => _.revision); const setAppGenerator = () => { if (!appVersion) { return; @@ -19,7 +20,7 @@ const Index: FC = () => { if (generatorMetaNode) { generatorMetaNode.setAttribute( 'content', - `Answer ${appVersion} - https://github.com/answerdev/answer`, + `Answer ${appVersion} - https://github.com/answerdev/answer version ${hashVersion}`, ); } }; diff --git a/ui/src/stores/siteInfo.ts b/ui/src/stores/siteInfo.ts index 26c5321b..1072501a 100644 --- a/ui/src/stores/siteInfo.ts +++ b/ui/src/stores/siteInfo.ts @@ -6,8 +6,9 @@ import { DEFAULT_SITE_NAME } from '@/common/constants'; interface SiteInfoType { siteInfo: AdminSettingsGeneral; version: string; + revision: string; update: (params: AdminSettingsGeneral) => void; - updateVersion: (ver: string) => void; + updateVersion: (ver: string, revision: string) => void; } const siteInfo = create((set) => ({ @@ -20,6 +21,7 @@ const siteInfo = create((set) => ({ permalink: 1, }, version: '', + revision: '', update: (params) => set((_) => { const o = { ..._.siteInfo, ...params }; @@ -30,9 +32,9 @@ const siteInfo = create((set) => ({ siteInfo: o, }; }), - updateVersion: (ver) => { + updateVersion: (ver, revision) => { set(() => { - return { version: ver }; + return { version: ver, revision }; }); }, })); diff --git a/ui/src/utils/guard.ts b/ui/src/utils/guard.ts index 5ff081af..fee55094 100644 --- a/ui/src/utils/guard.ts +++ b/ui/src/utils/guard.ts @@ -302,7 +302,9 @@ export const initAppSettingsStore = async () => { const appSettings = await getAppSettings(); if (appSettings) { siteInfoStore.getState().update(appSettings.general); - siteInfoStore.getState().updateVersion(appSettings.version); + siteInfoStore + .getState() + .updateVersion(appSettings.version, appSettings.revision); interfaceStore.getState().update(appSettings.interface); brandingStore.getState().update(appSettings.branding); loginSettingStore.getState().update(appSettings.login);