1
0
mirror of synced 2026-03-23 02:58:34 +08:00

feat(editor): 创建新组件时的顺序 (#316)

* feat(editor): 创建新组件时的顺序

点击面板组件创建新组件时,默认按照当所选组件(非容器)后面的顺序

* feat(editor): 追加vue2 runtime的修改
This commit is contained in:
i33
2022-08-30 12:45:51 +08:00
committed by GitHub
parent d3342a04c9
commit 6c0b92e808
3 changed files with 21 additions and 4 deletions

View File

@@ -71,7 +71,13 @@ export default defineComponent({
if (!selectedId.value) throw new Error('error');
const parent = getNodePath(parentId, [root.value]).pop();
if (!parent) throw new Error('未找到父节点');
parent.items?.push(config);
if (parent.id !== selectedId.value) {
const index = parent.items?.findIndex((child: MNode) => child.id === selectedId.value);
parent.items?.splice(index + 1, 0, config);
} else {
// 新增节点添加到配置中
parent.items?.push(config);
}
},
update({ config, parentId }: UpdateData) {

View File

@@ -71,7 +71,13 @@ export default defineComponent({
if (!selectedId.value) throw new Error('error');
const parent = getNodePath(parentId, [root.value]).pop();
if (!parent) throw new Error('未找到父节点');
parent.items?.push(config);
if (parent.id !== selectedId.value) {
const index = parent.items?.findIndex((child: MNode) => child.id === selectedId.value);
parent.items?.splice(index + 1, 0, config);
} else {
// 新增节点添加到配置中
parent.items?.push(config);
}
},
update({ config, parentId }: UpdateData) {