mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
refactor(ui): 通过解析dsl渲染的组件,渲染时往config中加入IS_DSL_NODE_KEY,用于识别是系统渲染的
This commit is contained in:
parent
59f05270ae
commit
c8d6a4f4d1
@ -297,3 +297,8 @@ export interface DisplayCondItem {
|
|||||||
export interface DisplayCond {
|
export interface DisplayCond {
|
||||||
cond: DisplayCondItem[];
|
cond: DisplayCondItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface UiComponentProps<T extends MNode = MNode> {
|
||||||
|
config: T;
|
||||||
|
model?: any;
|
||||||
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
:id="item.id"
|
:id="item.id"
|
||||||
:class="`${item.className || ''}`"
|
:class="`${item.className || ''}`"
|
||||||
:style="app?.transformStyle(item.style || {})"
|
:style="app?.transformStyle(item.style || {})"
|
||||||
:config="item"
|
:config="{ ...item, [IS_DSL_NODE_KEY]: true }"
|
||||||
></component>
|
></component>
|
||||||
</template>
|
</template>
|
||||||
</slot>
|
</slot>
|
||||||
@ -19,19 +19,13 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
|
||||||
import type { MContainer } from '@tmagic/schema';
|
import type { MContainer, UiComponentProps } from '@tmagic/schema';
|
||||||
import { toLine } from '@tmagic/utils';
|
import { IS_DSL_NODE_KEY, toLine } from '@tmagic/utils';
|
||||||
import { useApp } from '@tmagic/vue-runtime-help';
|
import { useApp } from '@tmagic/vue-runtime-help';
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(defineProps<UiComponentProps<MContainer>>(), {
|
||||||
defineProps<{
|
model: () => ({}),
|
||||||
config: MContainer;
|
});
|
||||||
model?: any;
|
|
||||||
}>(),
|
|
||||||
{
|
|
||||||
model: () => ({}),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const { style, display, app } = useApp({
|
const { style, display, app } = useApp({
|
||||||
config: props.config,
|
config: props.config,
|
||||||
|
@ -249,7 +249,8 @@ export const replaceChildNode = (newNode: MNode, data?: MNode[], parentId?: Id)
|
|||||||
parent.items.splice(index, 1, newNode);
|
parent.items.splice(index, 1, newNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DSL_NODE_KEY_COPY_PREFIX = '__magic__';
|
export const DSL_NODE_KEY_COPY_PREFIX = '__tmagic__';
|
||||||
|
export const IS_DSL_NODE_KEY = '__tmagic__dslNode';
|
||||||
|
|
||||||
export const compiledNode = (
|
export const compiledNode = (
|
||||||
compile: (value: any) => any,
|
compile: (value: any) => any,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user