fix(vue-runtime-help): handle remove when root is not initialized

When root is empty but RemoveData carries app config, update root instead of throwing.
This commit is contained in:
roymondchen 2026-06-26 19:51:44 +08:00
parent 7bbb1f24c0
commit af197363cf
2 changed files with 9 additions and 3 deletions

View File

@ -1,5 +1,5 @@
{
"version": "2.0.3",
"version": "2.0.4",
"name": "@tmagic/vue-runtime-help",
"type": "module",
"sideEffects": false,

View File

@ -138,8 +138,14 @@ export const useEditorDsl = (app = inject<TMagicApp>('app'), runtimeApi: Runtime
}
},
remove: ({ id, parentId }: RemoveData) => {
if (!root.value) throw new Error('error');
remove: ({ id, parentId, root: appConfig }: RemoveData) => {
if (!root.value) {
if (appConfig) {
updateRoot(appConfig);
return;
}
throw new Error('error');
}
const node = getNodePath(id, [root.value]).pop();
if (!node) throw new Error('未找到目标元素');