|
@@ -32,8 +32,9 @@
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<!-- 右键菜单 -->
|
|
<!-- 右键菜单 -->
|
|
|
- <ContentMenu
|
|
|
|
|
- ref="contentMenuRef"
|
|
|
|
|
|
|
+ <ContextMenu
|
|
|
|
|
+ ref="contextMenuRef"
|
|
|
|
|
+ :id="schema.id"
|
|
|
:virtualRef="triggerRef"
|
|
:virtualRef="triggerRef"
|
|
|
:widgetType="schema.type === 'page' ? 'page' : 'widget'"
|
|
:widgetType="schema.type === 'page' ? 'page' : 'widget'"
|
|
|
/>
|
|
/>
|
|
@@ -54,7 +55,7 @@ import { useAppStore } from '@/store/modules/app'
|
|
|
import { useActionStore } from '@/store/modules/action'
|
|
import { useActionStore } from '@/store/modules/action'
|
|
|
import { has, isEmpty } from 'lodash-es'
|
|
import { has, isEmpty } from 'lodash-es'
|
|
|
|
|
|
|
|
-import ContentMenu from './ContentMenu.vue'
|
|
|
|
|
|
|
+import ContextMenu from './ContextMenu.vue'
|
|
|
import { getAddWidgetIndex, isDescendant } from '@/utils'
|
|
import { getAddWidgetIndex, isDescendant } from '@/utils'
|
|
|
import { klona } from 'klona'
|
|
import { klona } from 'klona'
|
|
|
|
|
|
|
@@ -183,6 +184,7 @@ const layoutStyle = computed((): CSSProperties => {
|
|
|
}
|
|
}
|
|
|
return {
|
|
return {
|
|
|
display: 'flex',
|
|
display: 'flex',
|
|
|
|
|
+ overflow: 'hidden',
|
|
|
flexDirection: directionMap?.[flex?.direction],
|
|
flexDirection: directionMap?.[flex?.direction],
|
|
|
flexWrap: flex?.direction?.includes('wrap') ? 'wrap' : 'nowrap',
|
|
flexWrap: flex?.direction?.includes('wrap') ? 'wrap' : 'nowrap',
|
|
|
justifyContent: flex?.mainAxisAlign,
|
|
justifyContent: flex?.mainAxisAlign,
|
|
@@ -224,16 +226,16 @@ useDrop(nodeRef, {
|
|
|
|
|
|
|
|
// 创建控件
|
|
// 创建控件
|
|
|
const { offsetX = 0, offsetY = 0 } = event || {}
|
|
const { offsetX = 0, offsetY = 0 } = event || {}
|
|
|
- const index = getAddWidgetIndex(page!, content.key)
|
|
|
|
|
- const newWidget = createWidget(content, index)
|
|
|
|
|
|
|
+ const index = getAddWidgetIndex(page!, content?.key)
|
|
|
|
|
+ const newWidget = createWidget(content, index, !!content?.id)
|
|
|
newWidget.props.x = offsetX
|
|
newWidget.props.x = offsetX
|
|
|
newWidget.props.y = offsetY
|
|
newWidget.props.y = offsetY
|
|
|
|
|
|
|
|
// 添加到前面
|
|
// 添加到前面
|
|
|
if (has(schema.props, 'activeIndex')) {
|
|
if (has(schema.props, 'activeIndex')) {
|
|
|
- schema.children[schema.props.activeIndex].children?.unshift(newWidget)
|
|
|
|
|
|
|
+ schema.children[schema.props.activeIndex].children?.push(newWidget)
|
|
|
} else {
|
|
} else {
|
|
|
- schema.children?.unshift(newWidget)
|
|
|
|
|
|
|
+ schema.children?.push(newWidget)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
projectStore.setSelectWidgets([newWidget])
|
|
projectStore.setSelectWidgets([newWidget])
|
|
@@ -280,9 +282,9 @@ watch(nodeState, (state) => {
|
|
|
actionStore.onDeleteById(node.id)
|
|
actionStore.onDeleteById(node.id)
|
|
|
// 添加到前面
|
|
// 添加到前面
|
|
|
if (has(schema.props, 'activeIndex')) {
|
|
if (has(schema.props, 'activeIndex')) {
|
|
|
- schema.children[schema.props.activeIndex].children?.unshift(node)
|
|
|
|
|
|
|
+ schema.children[schema.props.activeIndex].children?.push(node)
|
|
|
} else {
|
|
} else {
|
|
|
- schema.children?.unshift(node)
|
|
|
|
|
|
|
+ schema.children?.push(node)
|
|
|
}
|
|
}
|
|
|
projectStore.activeWidgets = [node]
|
|
projectStore.activeWidgets = [node]
|
|
|
}
|
|
}
|
|
@@ -356,7 +358,7 @@ const handleSelect = (e: MouseEvent) => {
|
|
|
projectStore.setSelectWidgets([])
|
|
projectStore.setSelectWidgets([])
|
|
|
}
|
|
}
|
|
|
// 关闭右键菜单
|
|
// 关闭右键菜单
|
|
|
- contentMenuRef.value?.handleClose()
|
|
|
|
|
|
|
+ contextMenuRef.value?.handleClose()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/******************************右键菜单*********************************/
|
|
/******************************右键菜单*********************************/
|
|
@@ -367,7 +369,7 @@ const position = ref({
|
|
|
right: 0
|
|
right: 0
|
|
|
} as DOMRect)
|
|
} as DOMRect)
|
|
|
|
|
|
|
|
-const contentMenuRef = ref<InstanceType<typeof ContentMenu>>()
|
|
|
|
|
|
|
+const contextMenuRef = ref<InstanceType<typeof ContextMenu>>()
|
|
|
|
|
|
|
|
const triggerRef = ref({
|
|
const triggerRef = ref({
|
|
|
getBoundingClientRect: () => position.value
|
|
getBoundingClientRect: () => position.value
|
|
@@ -381,8 +383,7 @@ const handleContextmenu = (event: MouseEvent) => {
|
|
|
y: clientY
|
|
y: clientY
|
|
|
})
|
|
})
|
|
|
event.preventDefault()
|
|
event.preventDefault()
|
|
|
- contentMenuRef.value?.handleOpen()
|
|
|
|
|
- // todo 关闭其他菜单
|
|
|
|
|
|
|
+ contextMenuRef.value?.handleOpen()
|
|
|
|
|
|
|
|
// 没选中当前节点时 右键选中节点
|
|
// 没选中当前节点时 右键选中节点
|
|
|
if (!projectStore.activeWidgets.map((item) => item.id).includes(props.schema.id)) {
|
|
if (!projectStore.activeWidgets.map((item) => item.id).includes(props.schema.id)) {
|