|
@@ -11,7 +11,6 @@
|
|
|
@contextmenu.stop="handleContextmenu"
|
|
@contextmenu.stop="handleContextmenu"
|
|
|
:ignore-drag="ignoreDrag && !schema.props?.flags?.includes('LV_OBJ_FLAG_IGNORE_LAYOUT')"
|
|
:ignore-drag="ignoreDrag && !schema.props?.flags?.includes('LV_OBJ_FLAG_IGNORE_LAYOUT')"
|
|
|
>
|
|
>
|
|
|
- <!-- 控件 -->
|
|
|
|
|
<component
|
|
<component
|
|
|
v-bind="widgetProps"
|
|
v-bind="widgetProps"
|
|
|
:is="widget"
|
|
:is="widget"
|
|
@@ -22,7 +21,6 @@
|
|
|
class="absolute left-0 top-0 w-full h-full"
|
|
class="absolute left-0 top-0 w-full h-full"
|
|
|
:style="{ ...layoutStyle, ...dropStyle }"
|
|
:style="{ ...layoutStyle, ...dropStyle }"
|
|
|
>
|
|
>
|
|
|
- <!-- 子节点 -->
|
|
|
|
|
<NodeItem
|
|
<NodeItem
|
|
|
v-for="(child, index) in children"
|
|
v-for="(child, index) in children"
|
|
|
:key="child.id"
|
|
:key="child.id"
|
|
@@ -34,7 +32,6 @@
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <!-- 右键菜单 -->
|
|
|
|
|
<ContextMenu
|
|
<ContextMenu
|
|
|
ref="contextMenuRef"
|
|
ref="contextMenuRef"
|
|
|
:id="schema.id"
|
|
:id="schema.id"
|
|
@@ -49,14 +46,14 @@ import type { Page } from '@/types/page'
|
|
|
import type { StageState } from './type'
|
|
import type { StageState } from './type'
|
|
|
import type { CSSProperties } from 'vue'
|
|
import type { CSSProperties } from 'vue'
|
|
|
|
|
|
|
|
-import { computed, ref, inject, watch, nextTick, onBeforeUnmount } from 'vue'
|
|
|
|
|
|
|
+import { computed, inject, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
|
|
import { useDrop, useMouse } from 'vue-hooks-plus'
|
|
import { useDrop, useMouse } from 'vue-hooks-plus'
|
|
|
import { createWidget } from '@/model'
|
|
import { createWidget } from '@/model'
|
|
|
import LvglWidgets from '@/lvgl-widgets'
|
|
import LvglWidgets from '@/lvgl-widgets'
|
|
|
import { useProjectStore } from '@/store/modules/project'
|
|
import { useProjectStore } from '@/store/modules/project'
|
|
|
import { useAppStore } from '@/store/modules/app'
|
|
import { useAppStore } from '@/store/modules/app'
|
|
|
import { useActionStore } from '@/store/modules/action'
|
|
import { useActionStore } from '@/store/modules/action'
|
|
|
-import { has, isEmpty, get } from 'lodash-es'
|
|
|
|
|
|
|
+import { get, has, isEmpty } from 'lodash-es'
|
|
|
|
|
|
|
|
import ContextMenu from './ContextMenu.vue'
|
|
import ContextMenu from './ContextMenu.vue'
|
|
|
import { getAddWidgetIndex, isDescendant } from '@/utils'
|
|
import { getAddWidgetIndex, isDescendant } from '@/utils'
|
|
@@ -70,33 +67,22 @@ const page = inject<Page>('page')
|
|
|
const pageState = inject<StageState>('state')
|
|
const pageState = inject<StageState>('state')
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
const props = defineProps<{
|
|
|
- // 父级容器 拖拽缩放设置
|
|
|
|
|
rootContainer: HTMLElement
|
|
rootContainer: HTMLElement
|
|
|
- // 传入节点模型数据
|
|
|
|
|
schema: BaseWidget | Page
|
|
schema: BaseWidget | Page
|
|
|
- // 传入样式 如页面样式
|
|
|
|
|
style?: CSSProperties
|
|
style?: CSSProperties
|
|
|
- // 层级
|
|
|
|
|
zIndex?: number
|
|
zIndex?: number
|
|
|
- // 是否可拖拽
|
|
|
|
|
ignoreDrag?: boolean
|
|
ignoreDrag?: boolean
|
|
|
}>()
|
|
}>()
|
|
|
|
|
|
|
|
const projectStore = useProjectStore()
|
|
const projectStore = useProjectStore()
|
|
|
const appStore = useAppStore()
|
|
const appStore = useAppStore()
|
|
|
const actionStore = useActionStore()
|
|
const actionStore = useActionStore()
|
|
|
-// 获取lvgl vue控件
|
|
|
|
|
|
|
+
|
|
|
const widget = computed(() => LvglWidgets[props.schema.type]?.component)
|
|
const widget = computed(() => LvglWidgets[props.schema.type]?.component)
|
|
|
-// 节点容器放置ref
|
|
|
|
|
const nodeRef = ref<HTMLDivElement>()
|
|
const nodeRef = ref<HTMLDivElement>()
|
|
|
-// 当前层级
|
|
|
|
|
const zIndex = ref(props.zIndex)
|
|
const zIndex = ref(props.zIndex)
|
|
|
-
|
|
|
|
|
-// 放置效果样式
|
|
|
|
|
const dropStyle = ref<CSSProperties>({})
|
|
const dropStyle = ref<CSSProperties>({})
|
|
|
|
|
|
|
|
-// 子节点
|
|
|
|
|
-// 默认为子节点 当子节点为可切换容器时 根据activeIndex展示下一级节点
|
|
|
|
|
const children = computed(() => {
|
|
const children = computed(() => {
|
|
|
const { schema } = props
|
|
const { schema } = props
|
|
|
|
|
|
|
@@ -105,7 +91,6 @@ const children = computed(() => {
|
|
|
: schema.children
|
|
: schema.children
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 控件属性
|
|
|
|
|
const widgetProps = computed(() => {
|
|
const widgetProps = computed(() => {
|
|
|
const { schema } = props
|
|
const { schema } = props
|
|
|
|
|
|
|
@@ -115,30 +100,30 @@ const widgetProps = computed(() => {
|
|
|
state: schema?.state,
|
|
state: schema?.state,
|
|
|
styles: schema?.style,
|
|
styles: schema?.style,
|
|
|
id: schema?.id,
|
|
id: schema?.id,
|
|
|
- // 处理可切换子节点容器属性
|
|
|
|
|
...(has(schema.props, 'activeIndex') && schema.children ? { children: schema.children } : {})
|
|
...(has(schema.props, 'activeIndex') && schema.children ? { children: schema.children } : {})
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 忽略拖拽
|
|
|
|
|
const ignoreChildrenDrag = computed(() => {
|
|
const ignoreChildrenDrag = computed(() => {
|
|
|
const { schema } = props
|
|
const { schema } = props
|
|
|
return schema.props?.layout === 'flex'
|
|
return schema.props?.layout === 'flex'
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 组件样式
|
|
|
|
|
|
|
+const shouldIgnoreLibraryDrop = computed(() => {
|
|
|
|
|
+ const { schema } = props
|
|
|
|
|
+ return appStore.libraryDragging && schema.type !== 'page' && !schema.children
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
const getStyle = computed((): CSSProperties => {
|
|
const getStyle = computed((): CSSProperties => {
|
|
|
const { style = {}, schema } = props
|
|
const { style = {}, schema } = props
|
|
|
|
|
|
|
|
const other: CSSProperties = {}
|
|
const other: CSSProperties = {}
|
|
|
- // 显示所有控件边框
|
|
|
|
|
if (pageState?.showBorder && schema.type !== 'page') {
|
|
if (pageState?.showBorder && schema.type !== 'page') {
|
|
|
other.border = '1px dashed #000'
|
|
other.border = '1px dashed #000'
|
|
|
other.transform = `translate(${schema.props.x - 1}px, ${schema.props.y - 1}px)`
|
|
other.transform = `translate(${schema.props.x - 1}px, ${schema.props.y - 1}px)`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
let rotate = ''
|
|
let rotate = ''
|
|
|
- // 存在旋转属性
|
|
|
|
|
if (schema.props?.rotation) {
|
|
if (schema.props?.rotation) {
|
|
|
rotate = `rotate(${schema.props.rotation}deg)`
|
|
rotate = `rotate(${schema.props.rotation}deg)`
|
|
|
if (schema.props?.pivot) {
|
|
if (schema.props?.pivot) {
|
|
@@ -151,14 +136,12 @@ const getStyle = computed((): CSSProperties => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
let scale = 1
|
|
let scale = 1
|
|
|
- // 存在缩放属性且打开
|
|
|
|
|
if (schema.props?.openScale) {
|
|
if (schema.props?.openScale) {
|
|
|
scale = (schema.props?.scale ?? 256) / 256
|
|
scale = (schema.props?.scale ?? 256) / 256
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- let parentStyle = klona(style)
|
|
|
|
|
|
|
+ const parentStyle = klona(style)
|
|
|
|
|
|
|
|
- // 忽略父级布局
|
|
|
|
|
if (schema.props.flags?.includes('LV_OBJ_FLAG_IGNORE_LAYOUT')) {
|
|
if (schema.props.flags?.includes('LV_OBJ_FLAG_IGNORE_LAYOUT')) {
|
|
|
delete parentStyle.position
|
|
delete parentStyle.position
|
|
|
delete parentStyle.transform
|
|
delete parentStyle.transform
|
|
@@ -169,18 +152,15 @@ const getStyle = computed((): CSSProperties => {
|
|
|
left: 0,
|
|
left: 0,
|
|
|
top: 0,
|
|
top: 0,
|
|
|
transform: `translate(${schema.props.x}px, ${schema.props.y}px) ${rotate}`,
|
|
transform: `translate(${schema.props.x}px, ${schema.props.y}px) ${rotate}`,
|
|
|
- width: schema.props?.width * scale + 'px',
|
|
|
|
|
- height: schema.props?.height * scale + 'px',
|
|
|
|
|
|
|
+ width: `${schema.props?.width * scale}px`,
|
|
|
|
|
+ height: `${schema.props?.height * scale}px`,
|
|
|
zIndex: zIndex.value,
|
|
zIndex: zIndex.value,
|
|
|
|
|
+ pointerEvents: shouldIgnoreLibraryDrop.value ? 'none' : undefined,
|
|
|
...parentStyle,
|
|
...parentStyle,
|
|
|
...other
|
|
...other
|
|
|
- // ...dropStyle.value
|
|
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
- * 布局样式
|
|
|
|
|
- */
|
|
|
|
|
const layoutStyle = ref<CSSProperties>({})
|
|
const layoutStyle = ref<CSSProperties>({})
|
|
|
watch(
|
|
watch(
|
|
|
() => props.schema.props,
|
|
() => props.schema.props,
|
|
@@ -215,7 +195,6 @@ watch(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 获取子节点容器样式
|
|
|
|
|
const getChildStyle = LvglWidgets[props.schema.type]?.getChildStyle
|
|
const getChildStyle = LvglWidgets[props.schema.type]?.getChildStyle
|
|
|
if (typeof getChildStyle === 'function') {
|
|
if (typeof getChildStyle === 'function') {
|
|
|
style = {
|
|
style = {
|
|
@@ -231,12 +210,8 @@ watch(
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
- * 子元素样式
|
|
|
|
|
- */
|
|
|
|
|
const childStyle = computed((): CSSProperties => {
|
|
const childStyle = computed((): CSSProperties => {
|
|
|
const { schema } = props
|
|
const { schema } = props
|
|
|
- // flex布局,子元素移除transform,
|
|
|
|
|
if (schema.props?.layout === 'flex') {
|
|
if (schema.props?.layout === 'flex') {
|
|
|
return {
|
|
return {
|
|
|
transform: 'none',
|
|
transform: 'none',
|
|
@@ -247,24 +222,37 @@ const childStyle = computed((): CSSProperties => {
|
|
|
return {}
|
|
return {}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 拖拽放置事件处理
|
|
|
|
|
|
|
+const getDropPosition = (event?: DragEvent) => {
|
|
|
|
|
+ const element = nodeRef.value
|
|
|
|
|
+ const rect = element?.getBoundingClientRect()
|
|
|
|
|
+ const logicalWidth = props.schema.props?.width ?? element?.offsetWidth ?? element?.clientWidth
|
|
|
|
|
+ const logicalHeight = props.schema.props?.height ?? element?.offsetHeight ?? element?.clientHeight
|
|
|
|
|
+ if (!rect || !logicalWidth || !logicalHeight || !event) {
|
|
|
|
|
+ return { x: 0, y: 0 }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const scaleX = rect.width / logicalWidth || 1
|
|
|
|
|
+ const scaleY = rect.height / logicalHeight || 1
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ x: Math.round((event.clientX - rect.left) / scaleX),
|
|
|
|
|
+ y: Math.round((event.clientY - rect.top) / scaleY)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
useDrop(nodeRef, {
|
|
useDrop(nodeRef, {
|
|
|
- // 元素放置
|
|
|
|
|
onDom: (content, event) => {
|
|
onDom: (content, event) => {
|
|
|
const { schema } = props
|
|
const { schema } = props
|
|
|
|
|
|
|
|
dropStyle.value = {}
|
|
dropStyle.value = {}
|
|
|
- event?.stopPropagation()
|
|
|
|
|
if (!content || !schema?.children) return
|
|
if (!content || !schema?.children) return
|
|
|
|
|
|
|
|
- // 创建控件
|
|
|
|
|
- const { offsetX = 0, offsetY = 0 } = event || {}
|
|
|
|
|
|
|
+ const { x, y } = getDropPosition(event)
|
|
|
const index = getAddWidgetIndex(page!, content?.key)
|
|
const index = getAddWidgetIndex(page!, content?.key)
|
|
|
const newWidget = createWidget(content, index, !!content?.id)
|
|
const newWidget = createWidget(content, index, !!content?.id)
|
|
|
- newWidget.props.x = offsetX
|
|
|
|
|
- newWidget.props.y = offsetY
|
|
|
|
|
|
|
+ newWidget.props.x = x
|
|
|
|
|
+ newWidget.props.y = y
|
|
|
|
|
|
|
|
- // 添加到前面
|
|
|
|
|
if (has(schema.props, 'activeIndex')) {
|
|
if (has(schema.props, 'activeIndex')) {
|
|
|
const parent = get(schema.children, schema.props.activeIndex)
|
|
const parent = get(schema.children, schema.props.activeIndex)
|
|
|
parent?.children?.push(newWidget)
|
|
parent?.children?.push(newWidget)
|
|
@@ -273,11 +261,11 @@ useDrop(nodeRef, {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
projectStore.setSelectWidgets([newWidget])
|
|
projectStore.setSelectWidgets([newWidget])
|
|
|
|
|
+ event?.stopPropagation()
|
|
|
},
|
|
},
|
|
|
onDragOver: () => {
|
|
onDragOver: () => {
|
|
|
if (props.schema.type !== 'page' && props.schema.children) {
|
|
if (props.schema.type !== 'page' && props.schema.children) {
|
|
|
dropStyle.value = {
|
|
dropStyle.value = {
|
|
|
- // 放置阴影效果
|
|
|
|
|
boxShadow: '0px 0px 10px #00fcfc'
|
|
boxShadow: '0px 0px 10px #00fcfc'
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -287,9 +275,7 @@ useDrop(nodeRef, {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 监听鼠标位置
|
|
|
|
|
const nodeState = useMouse(nodeRef)
|
|
const nodeState = useMouse(nodeRef)
|
|
|
-// 可放置标识
|
|
|
|
|
let dropFlag = false
|
|
let dropFlag = false
|
|
|
let offsetX = 0
|
|
let offsetX = 0
|
|
|
let offsetY = 0
|
|
let offsetY = 0
|
|
@@ -329,12 +315,9 @@ watch(nodeState, (state) => {
|
|
|
if (schema?.children && schema.type !== 'page') {
|
|
if (schema?.children && schema.type !== 'page') {
|
|
|
const { elementW, elementH, elementX, elementY, clientX, clientY } = state
|
|
const { elementW, elementH, elementX, elementY, clientX, clientY } = state
|
|
|
|
|
|
|
|
- // 停止拖拽且允许放置时剪切到容器内
|
|
|
|
|
if (dropFlag && !appStore.draging) {
|
|
if (dropFlag && !appStore.draging) {
|
|
|
dropFlag = false
|
|
dropFlag = false
|
|
|
clearDropMouseupListener()
|
|
clearDropMouseupListener()
|
|
|
- // 放置到容器内
|
|
|
|
|
- // 获取在容器的真实位置
|
|
|
|
|
const scale = elementW / schema.props.width
|
|
const scale = elementW / schema.props.width
|
|
|
const x = elementX / scale - offsetX
|
|
const x = elementX / scale - offsetX
|
|
|
const y = elementY / scale - offsetY
|
|
const y = elementY / scale - offsetY
|
|
@@ -343,9 +326,7 @@ watch(nodeState, (state) => {
|
|
|
projectStore.activeWidgets[0].props.y = y
|
|
projectStore.activeWidgets[0].props.y = y
|
|
|
|
|
|
|
|
const node = klona(projectStore.activeWidgets[0])
|
|
const node = klona(projectStore.activeWidgets[0])
|
|
|
- // 删除原来的节点
|
|
|
|
|
actionStore.onDeleteById(node.id)
|
|
actionStore.onDeleteById(node.id)
|
|
|
- // 添加到前面
|
|
|
|
|
if (has(schema.props, 'activeIndex')) {
|
|
if (has(schema.props, 'activeIndex')) {
|
|
|
const parent = get(schema.children, schema.props.activeIndex)
|
|
const parent = get(schema.children, schema.props.activeIndex)
|
|
|
parent?.children?.push(node)
|
|
parent?.children?.push(node)
|
|
@@ -354,12 +335,7 @@ watch(nodeState, (state) => {
|
|
|
}
|
|
}
|
|
|
projectStore.activeWidgets = [node]
|
|
projectStore.activeWidgets = [node]
|
|
|
}
|
|
}
|
|
|
- // 鼠标在节点内部
|
|
|
|
|
- // 处于节点拖拽状态
|
|
|
|
|
- // 当前选中节点只有一个
|
|
|
|
|
- // 且非自身节点
|
|
|
|
|
- // 非自身后代节点
|
|
|
|
|
- // 非页面节点
|
|
|
|
|
|
|
+
|
|
|
if (
|
|
if (
|
|
|
elementX > 0 &&
|
|
elementX > 0 &&
|
|
|
elementX < elementW &&
|
|
elementX < elementW &&
|
|
@@ -371,11 +347,9 @@ watch(nodeState, (state) => {
|
|
|
!isDescendant(schema, projectStore.activeWidgets[0].id) &&
|
|
!isDescendant(schema, projectStore.activeWidgets[0].id) &&
|
|
|
schema.type !== 'page'
|
|
schema.type !== 'page'
|
|
|
) {
|
|
) {
|
|
|
- // 获取当前鼠标位置全部控件节点元素
|
|
|
|
|
const elements = document
|
|
const elements = document
|
|
|
.elementsFromPoint(clientX, clientY)
|
|
.elementsFromPoint(clientX, clientY)
|
|
|
?.filter((el) => el.className?.includes?.('widget-node'))
|
|
?.filter((el) => el.className?.includes?.('widget-node'))
|
|
|
- // 获取第一个元素不是自身的元素
|
|
|
|
|
const targetEl = elements.find((el) => {
|
|
const targetEl = elements.find((el) => {
|
|
|
const id = el.attributes.getNamedItem('widget-id')?.value
|
|
const id = el.attributes.getNamedItem('widget-id')?.value
|
|
|
return id !== projectStore.activeWidget?.id
|
|
return id !== projectStore.activeWidget?.id
|
|
@@ -383,9 +357,7 @@ watch(nodeState, (state) => {
|
|
|
const targetId = targetEl?.attributes.getNamedItem('widget-id')?.value
|
|
const targetId = targetEl?.attributes.getNamedItem('widget-id')?.value
|
|
|
|
|
|
|
|
if (targetId === schema.id) {
|
|
if (targetId === schema.id) {
|
|
|
- // 最上层的容器
|
|
|
|
|
dropStyle.value = {
|
|
dropStyle.value = {
|
|
|
- // 放置阴影效果
|
|
|
|
|
boxShadow: '0px 0px 10px #00fcfc'
|
|
boxShadow: '0px 0px 10px #00fcfc'
|
|
|
}
|
|
}
|
|
|
dropFlag = true
|
|
dropFlag = true
|
|
@@ -393,23 +365,19 @@ watch(nodeState, (state) => {
|
|
|
} else if (!isEmpty(dropStyle.value)) {
|
|
} else if (!isEmpty(dropStyle.value)) {
|
|
|
dropFlag = false
|
|
dropFlag = false
|
|
|
clearDropMouseupListener()
|
|
clearDropMouseupListener()
|
|
|
- // 容器外
|
|
|
|
|
dropStyle.value = {}
|
|
dropStyle.value = {}
|
|
|
}
|
|
}
|
|
|
} else if (!isEmpty(dropStyle.value)) {
|
|
} else if (!isEmpty(dropStyle.value)) {
|
|
|
dropFlag = false
|
|
dropFlag = false
|
|
|
clearDropMouseupListener()
|
|
clearDropMouseupListener()
|
|
|
- // 容器外
|
|
|
|
|
dropStyle.value = {}
|
|
dropStyle.value = {}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 选择节点
|
|
|
|
|
const handleSelect = (e: MouseEvent) => {
|
|
const handleSelect = (e: MouseEvent) => {
|
|
|
if (props.schema.type !== 'page') {
|
|
if (props.schema.type !== 'page') {
|
|
|
e.stopPropagation()
|
|
e.stopPropagation()
|
|
|
- // 判断当前是否按住ctrl
|
|
|
|
|
if (e.ctrlKey) {
|
|
if (e.ctrlKey) {
|
|
|
projectStore.activeWidgets.push(props.schema as BaseWidget)
|
|
projectStore.activeWidgets.push(props.schema as BaseWidget)
|
|
|
} else {
|
|
} else {
|
|
@@ -418,11 +386,9 @@ const handleSelect = (e: MouseEvent) => {
|
|
|
} else {
|
|
} else {
|
|
|
projectStore.setSelectWidgets([])
|
|
projectStore.setSelectWidgets([])
|
|
|
}
|
|
}
|
|
|
- // 关闭右键菜单
|
|
|
|
|
contextMenuRef.value?.handleClose()
|
|
contextMenuRef.value?.handleClose()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/******************************右键菜单*********************************/
|
|
|
|
|
const position = ref({
|
|
const position = ref({
|
|
|
top: 0,
|
|
top: 0,
|
|
|
left: 0,
|
|
left: 0,
|
|
@@ -436,7 +402,6 @@ const triggerRef = ref({
|
|
|
getBoundingClientRect: () => position.value
|
|
getBoundingClientRect: () => position.value
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 处理右键菜单
|
|
|
|
|
const handleContextmenu = (event: MouseEvent) => {
|
|
const handleContextmenu = (event: MouseEvent) => {
|
|
|
const { clientX, clientY } = event
|
|
const { clientX, clientY } = event
|
|
|
position.value = DOMRect.fromRect({
|
|
position.value = DOMRect.fromRect({
|
|
@@ -446,10 +411,8 @@ const handleContextmenu = (event: MouseEvent) => {
|
|
|
event.preventDefault()
|
|
event.preventDefault()
|
|
|
contextMenuRef.value?.handleOpen()
|
|
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)) {
|
|
|
if (props.schema.type !== 'page') {
|
|
if (props.schema.type !== 'page') {
|
|
|
- // 判断当前是否按住ctrl
|
|
|
|
|
if (event.ctrlKey) {
|
|
if (event.ctrlKey) {
|
|
|
projectStore.activeWidgets.push(props.schema as BaseWidget)
|
|
projectStore.activeWidgets.push(props.schema as BaseWidget)
|
|
|
} else {
|
|
} else {
|