Commit f13ba138 authored by 郭志伟's avatar 郭志伟

fix: 调试问题

parent cc729e48
......@@ -21,7 +21,10 @@ export default class EditorModule implements Module<EditorState, RootState> {
actions: ActionTree<EditorState, RootState> = {
async getPageDate({ commit }, condition) {
const [res] = await api.getPageById(condition);
const { page, ...rest } = res as PageInfo;
let { page, ...rest } = res as PageInfo;
if (!page) {
page = "[]";
}
commit(SET_PAGE_INFO, { ...rest, page: JSON.parse(page as string) });
}
};
......@@ -31,29 +34,23 @@ export default class EditorModule implements Module<EditorState, RootState> {
state.pageInfo = data;
},
[UPDATE_PAGE_INFO](state, { containerIndex, childIndex, data }) {
if (state.pageInfo && state.pageInfo.page) {
const page = (state.pageInfo.page as Page).elements;
if (childIndex || childIndex === 0) {
const page = (state.pageInfo.page as Page).elements || [];
if ((childIndex || childIndex === 0) && page[containerIndex].child) {
page[containerIndex].child.splice(childIndex, 1, data);
} else {
page.splice(containerIndex, 1, data);
}
}
},
[SET_PAGE_DATA](state, data) {
state.pageInfo.page = data;
},
[SET_PAGE_ELEMENTS](state, data) {
if (state.pageInfo && state.pageInfo.page) {
if (data) { (state.pageInfo.page as Page).elements = data; }
}
},
[SET_ELEMENT_POINT](state, { id, data }) {
if (state.pageInfo && state.pageInfo.page) {
const elements = (state.pageInfo.page as Page).elements;
const element = elements.find(ele => ele.id === id);
if (element && data) { element.point = data; }
}
},
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment