fix(editor): 删除组件后,组件树不更新

This commit is contained in:
roymondchen 2022-05-06 20:16:52 +08:00 committed by jia000
parent 29e31e9cad
commit bcbd1f5d37
3 changed files with 16 additions and 1 deletions

View File

@ -76,7 +76,7 @@ export default defineComponent({
{ {
type: 'button', type: 'button',
text: '新增', text: '新增',
display: () => node.value?.items?.length > 0, display: () => node.value?.items,
items: getSubMenuData.value, items: getSubMenuData.value,
}, },
{ {

View File

@ -193,6 +193,12 @@ export default defineComponent({
() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value, () => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value,
); );
editorService?.on('remove', () => {
setTimeout(() => {
tree.value?.getNode(editorService.get('node').id)?.updateChildren();
}, 0);
});
return { return {
tree, tree,
menu, menu,

View File

@ -191,6 +191,9 @@ class Editor extends BaseService {
} else { } else {
historyService.empty(); historyService.empty();
} }
this.emit('select', node);
return node!; return node!;
} }
@ -291,6 +294,8 @@ class Editor extends BaseService {
stage?.select(newNode.id); stage?.select(newNode.id);
this.emit('add', newNode);
return newNode; return newNode;
} }
@ -331,6 +336,8 @@ class Editor extends BaseService {
this.addModifiedNodeId(parent.id); this.addModifiedNodeId(parent.id);
this.pushHistoryState(); this.pushHistoryState();
this.emit('remove', node);
return node; return node;
} }
@ -392,6 +399,8 @@ class Editor extends BaseService {
this.addModifiedNodeId(newConfig.id); this.addModifiedNodeId(newConfig.id);
this.pushHistoryState(); this.pushHistoryState();
this.emit('update', newConfig);
return newConfig; return newConfig;
} }