mirror of
https://github.com/MCSManager/MCSManager.git
synced 2024-11-27 06:59:54 +08:00
Feat: layout version update func
This commit is contained in:
parent
858763c2c3
commit
85365557ce
@ -2,6 +2,7 @@ import { v4 } from "uuid";
|
||||
import { IPageLayoutConfig } from "../../../../common/global";
|
||||
import { $t as t } from "../i18n";
|
||||
import storage from "../common/system_storage";
|
||||
import { GlobalVariable } from "common";
|
||||
|
||||
const LAYOUT_CONFIG_NAME = "layout.json";
|
||||
|
||||
@ -15,6 +16,18 @@ export function getFrontendLayoutConfig(): string {
|
||||
layoutConfig = storage.readFile(LAYOUT_CONFIG_NAME);
|
||||
}
|
||||
if (layoutConfig) {
|
||||
if (GlobalVariable.get("versionChange")) {
|
||||
const latestLayoutConfig = getDefaultFrontendLayoutConfig();
|
||||
const currentLayoutConfig = JSON.parse(layoutConfig) as IPageLayoutConfig[];
|
||||
for (const page of latestLayoutConfig) {
|
||||
if (!currentLayoutConfig.find((item) => item.page === page.page)) {
|
||||
currentLayoutConfig.push(page);
|
||||
}
|
||||
}
|
||||
GlobalVariable.set("versionChange", null);
|
||||
setFrontendLayoutConfig(currentLayoutConfig);
|
||||
return JSON.stringify(currentLayoutConfig);
|
||||
}
|
||||
return layoutConfig as string;
|
||||
} else {
|
||||
return JSON.stringify(getDefaultFrontendLayoutConfig());
|
||||
|
@ -32,7 +32,7 @@ export function initVersionManager() {
|
||||
if (currentVersion && storage.fileExists(VERSION_LOG_TEXT_NAME)) {
|
||||
const LastLaunchedVersion = storage.readFile(VERSION_LOG_TEXT_NAME);
|
||||
if (LastLaunchedVersion && LastLaunchedVersion != currentVersion) {
|
||||
logger.info(`Version changed from ${LastLaunchedVersion} to ${currentVersion}`);
|
||||
logger.warn(`Version changed from ${LastLaunchedVersion} to ${currentVersion}`);
|
||||
GlobalVariable.set("versionChange", currentVersion);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user