fix: generator add reviosn

This commit is contained in:
shuai 2023-04-11 15:54:17 +08:00
parent 2a1367cb66
commit 5361f4e127
4 changed files with 11 additions and 5 deletions

View File

@ -328,6 +328,7 @@ export interface SiteSettings {
theme: AdminSettingsTheme;
site_seo: AdminSettingsSeo;
version: string;
revision: string;
}
export interface AdminSettingBranding {

View File

@ -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}`,
);
}
};

View File

@ -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<SiteInfoType>((set) => ({
@ -20,6 +21,7 @@ const siteInfo = create<SiteInfoType>((set) => ({
permalink: 1,
},
version: '',
revision: '',
update: (params) =>
set((_) => {
const o = { ..._.siteInfo, ...params };
@ -30,9 +32,9 @@ const siteInfo = create<SiteInfoType>((set) => ({
siteInfo: o,
};
}),
updateVersion: (ver) => {
updateVersion: (ver, revision) => {
set(() => {
return { version: ver };
return { version: ver, revision };
});
},
}));

View File

@ -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);