Skip to content

Commit

Permalink
refactor(ui): 通过解析dsl渲染的组件,渲染时往config中加入IS_DSL_NODE_KEY,用于识别是系统渲染的
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen committed Aug 1, 2024
1 parent 59f0527 commit c8d6a4f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
5 changes: 5 additions & 0 deletions packages/schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,8 @@ export interface DisplayCondItem {
export interface DisplayCond {
cond: DisplayCondItem[];
}

export interface UiComponentProps<T extends MNode = MNode> {
config: T;
model?: any;
}
18 changes: 6 additions & 12 deletions packages/ui/src/container/src/Container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
:id="item.id"
:class="`${item.className || ''}`"
:style="app?.transformStyle(item.style || {})"
:config="item"
:config="{ ...item, [IS_DSL_NODE_KEY]: true }"
></component>
</template>
</slot>
Expand All @@ -19,19 +19,13 @@
<script lang="ts" setup>
import { computed } from 'vue';
import type { MContainer } from '@tmagic/schema';
import { toLine } from '@tmagic/utils';
import type { MContainer, UiComponentProps } from '@tmagic/schema';
import { IS_DSL_NODE_KEY, toLine } from '@tmagic/utils';
import { useApp } from '@tmagic/vue-runtime-help';
const props = withDefaults(
defineProps<{
config: MContainer;
model?: any;
}>(),
{
model: () => ({}),
},
);
const props = withDefaults(defineProps<UiComponentProps<MContainer>>(), {
model: () => ({}),
});
const { style, display, app } = useApp({
config: props.config,
Expand Down
3 changes: 2 additions & 1 deletion packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ export const replaceChildNode = (newNode: MNode, data?: MNode[], parentId?: Id)
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 = (
compile: (value: any) => any,
Expand Down

0 comments on commit c8d6a4f

Please sign in to comment.