diff --git a/components.d.ts b/components.d.ts index 1296c7c..3d39c3a 100644 --- a/components.d.ts +++ b/components.d.ts @@ -1,38 +1,38 @@ // generated by unplugin-vue-components // We suggest you to commit this file into source control // Read more: https://github.com/vuejs/core/pull/3399 -import '@vue/runtime-core'; +import '@vue/runtime-core' -export {}; +export {} declare module '@vue/runtime-core' { export interface GlobalComponents { - ElAside: typeof import('element-plus/es')['ElAside']; - ElButton: typeof import('element-plus/es')['ElButton']; - ElCol: typeof import('element-plus/es')['ElCol']; - ElCollapse: typeof import('element-plus/es')['ElCollapse']; - ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']; - ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']; - ElContainer: typeof import('element-plus/es')['ElContainer']; - ElDialog: typeof import('element-plus/es')['ElDialog']; - ElDropdown: typeof import('element-plus/es')['ElDropdown']; - ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']; - ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']; - ElHeader: typeof import('element-plus/es')['ElHeader']; - ElIcon: typeof import('element-plus/es')['ElIcon']; - ElMain: typeof import('element-plus/es')['ElMain']; - ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm']; - ElPopover: typeof import('element-plus/es')['ElPopover']; - ElRow: typeof import('element-plus/es')['ElRow']; - ElTabPane: typeof import('element-plus/es')['ElTabPane']; - ElTabs: typeof import('element-plus/es')['ElTabs']; - ElTag: typeof import('element-plus/es')['ElTag']; - ElTooltip: typeof import('element-plus/es')['ElTooltip']; - ElTree: typeof import('element-plus/es')['ElTree']; - RouterLink: typeof import('vue-router')['RouterLink']; - RouterView: typeof import('vue-router')['RouterView']; + ElAside: typeof import('element-plus/es')['ElAside'] + ElButton: typeof import('element-plus/es')['ElButton'] + ElCol: typeof import('element-plus/es')['ElCol'] + ElCollapse: typeof import('element-plus/es')['ElCollapse'] + ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem'] + ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider'] + ElContainer: typeof import('element-plus/es')['ElContainer'] + ElDialog: typeof import('element-plus/es')['ElDialog'] + ElDropdown: typeof import('element-plus/es')['ElDropdown'] + ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] + ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu'] + ElHeader: typeof import('element-plus/es')['ElHeader'] + ElIcon: typeof import('element-plus/es')['ElIcon'] + ElMain: typeof import('element-plus/es')['ElMain'] + ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm'] + ElPopover: typeof import('element-plus/es')['ElPopover'] + ElRow: typeof import('element-plus/es')['ElRow'] + ElTabPane: typeof import('element-plus/es')['ElTabPane'] + ElTabs: typeof import('element-plus/es')['ElTabs'] + ElTag: typeof import('element-plus/es')['ElTag'] + ElTooltip: typeof import('element-plus/es')['ElTooltip'] + ElTree: typeof import('element-plus/es')['ElTree'] + RouterLink: typeof import('vue-router')['RouterLink'] + RouterView: typeof import('vue-router')['RouterView'] } export interface ComponentCustomProperties { - vInfiniteScroll: typeof import('element-plus/es')['ElInfiniteScroll']; + vInfiniteScroll: typeof import('element-plus/es')['ElInfiniteScroll'] } } diff --git a/src/App.vue b/src/App.vue index 19b6741..4de252c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -9,16 +9,16 @@ diff --git a/src/visual-editor/hooks/useVisualData.ts b/src/visual-editor/hooks/useVisualData.ts index f5f3724..77a9e51 100644 --- a/src/visual-editor/hooks/useVisualData.ts +++ b/src/visual-editor/hooks/useVisualData.ts @@ -99,16 +99,26 @@ export const initVisualData = () => { (url) => setCurrentPage(url), ); + watch( + () => state.jsonData, + () => { + state.currentPage = state.jsonData.pages[route.path]; + }, + ); + // 更新page const updatePage = ({ newPath = '', oldPath, page }) => { - console.log(state.jsonData.pages[oldPath], page); + // console.log(state.jsonData.pages[oldPath], page.pages['/']); if (newPath && newPath != oldPath) { page.path = newPath; // 如果传了新的路径,则认为是修改页面路由 - state.jsonData.pages[getPrefixPath(newPath)] = { ...state.jsonData.pages[oldPath], ...page }; + state.jsonData.pages[getPrefixPath(newPath)] = { + ...state.jsonData.pages[oldPath], + ...page.pages[newPath], + }; deletePage(oldPath, getPrefixPath(newPath)); } else { - Object.assign(state.jsonData.pages[oldPath], page); + Object.assign(state.jsonData.pages[oldPath], page.pages[oldPath]); } }; // 添加page @@ -220,6 +230,10 @@ export const initVisualData = () => { state.jsonData = typeof jsonData === 'string' ? JSON.parse(jsonData) : jsonData; }; + const saveChanges = () => { + sessionStorage.setItem(localKey, JSON.stringify(state.jsonData)); + }; + return { visualConfig, jsonData: readonly(state.jsonData), // 保护JSONData避免直接修改 @@ -238,6 +252,7 @@ export const initVisualData = () => { incrementPage, deletePage, updatePageBlock, + saveChanges, }; };