()
| 13 | } |
| 14 | |
| 15 | export function getFrontendLayoutConfig(): string { |
| 16 | let layoutConfig: string = ""; |
| 17 | if (storage.fileExists(LAYOUT_CONFIG_NAME)) { |
| 18 | layoutConfig = storage.readFile(LAYOUT_CONFIG_NAME); |
| 19 | } |
| 20 | if (layoutConfig) { |
| 21 | if (GlobalVariable.get("versionChange")) { |
| 22 | const latestLayoutConfig = getDefaultFrontendLayoutConfig(); |
| 23 | const currentLayoutConfig = JSON.parse(layoutConfig) as IPageLayoutConfig[]; |
| 24 | for (const page of latestLayoutConfig) { |
| 25 | if (!currentLayoutConfig.find((item) => item.page === page.page)) { |
| 26 | currentLayoutConfig.push(page); |
| 27 | } |
| 28 | } |
| 29 | GlobalVariable.set("versionChange", null); |
| 30 | setFrontendLayoutConfig(currentLayoutConfig); |
| 31 | return JSON.stringify(currentLayoutConfig); |
| 32 | } |
| 33 | return layoutConfig as string; |
| 34 | } else { |
| 35 | return JSON.stringify(getDefaultFrontendLayoutConfig()); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | export function setFrontendLayoutConfig(config: IPageLayoutConfig[]) { |
| 40 | storage.writeFile(LAYOUT_CONFIG_NAME, JSON.stringify(config, null, 2)); |
no test coverage detected