feat(vue-components): page-fragment-container编辑器中不去除内部组件id,不然会导致无法从app中获取dsl

This commit is contained in:
roymondchen 2025-07-17 14:09:11 +08:00
parent bf9fad18b6
commit 34bc223f02
2 changed files with 6 additions and 17 deletions

View File

@ -1,5 +1,5 @@
{
"version": "0.2.1",
"version": "0.2.2",
"name": "@tmagic/vue-page-fragment-container",
"type": "module",
"main": "src/index.ts",

View File

@ -14,14 +14,7 @@
<script lang="ts">
import { computed, defineComponent, type PropType, provide } from 'vue-demi';
import {
cloneDeep,
type Id,
type MComponent,
NodeType,
PAGE_FRAGMENT_CONTAINER_ID_KEY,
traverseNode,
} from '@tmagic/core';
import { type Id, type MComponent, NodeType, PAGE_FRAGMENT_CONTAINER_ID_KEY } from '@tmagic/core';
import { registerNodeHooks, useApp, useComponent, useDsl } from '@tmagic/vue-runtime-help';
export default defineComponent({
@ -50,19 +43,15 @@ export default defineComponent({
const containerComponent = useComponent({ componentType: 'container', app });
if (!props.config.id) {
throw new Error('page-fragment-container must have id');
}
const { pageConfig: fragment } = useDsl(app, props.config.id);
const containerConfig = computed(() => {
if (!fragment.value) return { items: [], id: '', type: NodeType.CONTAINER };
if (app?.platform === 'editor') {
const fragmentConfigWithoutId = cloneDeep(fragment.value);
traverseNode(fragmentConfigWithoutId, (node) => {
node.id = '';
});
return fragmentConfigWithoutId;
}
return fragment.value;
});