|
@@ -1,6 +1,7 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div
|
|
<div
|
|
|
v-if="!schema.hidden"
|
|
v-if="!schema.hidden"
|
|
|
|
|
+ v-bind="$attrs"
|
|
|
ref="nodeRef"
|
|
ref="nodeRef"
|
|
|
:style="getStyle"
|
|
:style="getStyle"
|
|
|
:class="schema.type === 'page' ? '' : 'ignore-click widget-node'"
|
|
:class="schema.type === 'page' ? '' : 'ignore-click widget-node'"
|
|
@@ -16,15 +17,19 @@
|
|
|
style="width: 100%; height: 100%"
|
|
style="width: 100%; height: 100%"
|
|
|
:style="{ 'pointer-events': schema.type === 'page' ? 'none' : '' }"
|
|
:style="{ 'pointer-events': schema.type === 'page' ? 'none' : '' }"
|
|
|
/>
|
|
/>
|
|
|
- <!-- 子节点 -->
|
|
|
|
|
- <NodeItem
|
|
|
|
|
- v-if="schema.children"
|
|
|
|
|
- v-for="(child, index) in children"
|
|
|
|
|
- :key="child.id"
|
|
|
|
|
- :zIndex="schema.children.length - Number(index)"
|
|
|
|
|
- :schema="child"
|
|
|
|
|
- :rootContainer="nodeRef!"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <div class="absolute left-0 top-0 w-full h-full" :style="layoutStyle">
|
|
|
|
|
+ <!-- 子节点 -->
|
|
|
|
|
+ <NodeItem
|
|
|
|
|
+ v-if="schema.children"
|
|
|
|
|
+ v-for="(child, index) in children"
|
|
|
|
|
+ :key="child.id"
|
|
|
|
|
+ :ignore-drag="ignoreChildrenDrag"
|
|
|
|
|
+ :zIndex="schema.children.length - Number(index)"
|
|
|
|
|
+ :schema="child"
|
|
|
|
|
+ :rootContainer="nodeRef!"
|
|
|
|
|
+ :style="childStyle"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
<!-- 右键菜单 -->
|
|
<!-- 右键菜单 -->
|
|
|
<ContentMenu
|
|
<ContentMenu
|
|
@@ -109,6 +114,12 @@ const widgetProps = computed(() => {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+// 忽略拖拽
|
|
|
|
|
+const ignoreChildrenDrag = computed(() => {
|
|
|
|
|
+ const { schema } = props
|
|
|
|
|
+ return schema.props?.layout === 'flex'
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
// 组件样式
|
|
// 组件样式
|
|
|
const getStyle = computed((): CSSProperties => {
|
|
const getStyle = computed((): CSSProperties => {
|
|
|
const { style = {}, schema } = props
|
|
const { style = {}, schema } = props
|
|
@@ -152,6 +163,55 @@ const getStyle = computed((): CSSProperties => {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 布局样式
|
|
|
|
|
+ */
|
|
|
|
|
+const layoutStyle = computed((): CSSProperties => {
|
|
|
|
|
+ const { schema } = props
|
|
|
|
|
+
|
|
|
|
|
+ if (schema.props?.layout === 'flex' && schema.props?.flex) {
|
|
|
|
|
+ const { flex } = schema.props
|
|
|
|
|
+ const directionMap = {
|
|
|
|
|
+ row: 'row',
|
|
|
|
|
+ column: 'column',
|
|
|
|
|
+ 'row-wrap': 'row',
|
|
|
|
|
+ 'column-wrap': 'column',
|
|
|
|
|
+ 'row-reverse': 'row-reverse',
|
|
|
|
|
+ 'column-reverse': 'column-reverse',
|
|
|
|
|
+ 'row-wrap-reverse': 'row-reverse',
|
|
|
|
|
+ 'column-wrap-reverse': 'column-reverse'
|
|
|
|
|
+ }
|
|
|
|
|
+ return {
|
|
|
|
|
+ display: 'flex',
|
|
|
|
|
+ flexDirection: directionMap?.[flex?.direction],
|
|
|
|
|
+ flexWrap: flex?.direction?.includes('wrap') ? 'wrap' : 'nowrap',
|
|
|
|
|
+ justifyContent: flex?.mainAxisAlign,
|
|
|
|
|
+ alignItems: flex?.crossAxisAlign,
|
|
|
|
|
+ alignContent: flex?.trackAxisAlign,
|
|
|
|
|
+ 'row-gap': flex?.rowGap ? `${flex.rowGap}px` : 0,
|
|
|
|
|
+ 'column-gap': flex?.columnGap ? `${flex.columnGap}px` : 0
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return {}
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 子元素样式
|
|
|
|
|
+ */
|
|
|
|
|
+const childStyle = computed((): CSSProperties => {
|
|
|
|
|
+ const { schema } = props
|
|
|
|
|
+ // flex布局,子元素移除transform,
|
|
|
|
|
+ if (schema.props?.layout === 'flex') {
|
|
|
|
|
+ return {
|
|
|
|
|
+ transform: 'none',
|
|
|
|
|
+ position: 'relative',
|
|
|
|
|
+ flexShrink: 0
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return {}
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
// 拖拽放置事件处理
|
|
// 拖拽放置事件处理
|
|
|
useDrop(nodeRef, {
|
|
useDrop(nodeRef, {
|
|
|
// 元素放置
|
|
// 元素放置
|