|
@@ -60,6 +60,8 @@ import { useAppStore } from '@/store/modules/app'
|
|
|
|
|
|
|
|
import type { StageState } from './type'
|
|
import type { StageState } from './type'
|
|
|
import { has } from 'lodash-es'
|
|
import { has } from 'lodash-es'
|
|
|
|
|
+import { Page } from '@/types/page'
|
|
|
|
|
+import { BaseWidget } from '@/types/baseWidget'
|
|
|
|
|
|
|
|
defineProps<{
|
|
defineProps<{
|
|
|
// 父级容器 拖拽缩放设置
|
|
// 父级容器 拖拽缩放设置
|
|
@@ -157,6 +159,13 @@ const individualGroupableProps = (element: HTMLElement | SVGElement | null | und
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 获取缩放值
|
|
|
|
|
+const getScale = (widget: Page | BaseWidget) => {
|
|
|
|
|
+ if (!widget.props?.openScale) return 1
|
|
|
|
|
+
|
|
|
|
|
+ return (widget.props?.scale ?? 256) / 256
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 拖拽开始
|
|
// 拖拽开始
|
|
|
const onDragStart = (e) => {
|
|
const onDragStart = (e) => {
|
|
|
zIndex.value = e.target.style.zIndex
|
|
zIndex.value = e.target.style.zIndex
|
|
@@ -188,8 +197,9 @@ const onResize = (e) => {
|
|
|
const onResizeEnd = (e) => {
|
|
const onResizeEnd = (e) => {
|
|
|
const id = e.target.attributes['widget-id']?.value
|
|
const id = e.target.attributes['widget-id']?.value
|
|
|
if (e.lastEvent && id && projectStore.activeWidgetMap[id]) {
|
|
if (e.lastEvent && id && projectStore.activeWidgetMap[id]) {
|
|
|
- projectStore.activeWidgetMap[id].props.width = Math.round(e.lastEvent.width)
|
|
|
|
|
- projectStore.activeWidgetMap[id].props.height = Math.round(e.lastEvent.height)
|
|
|
|
|
|
|
+ const scale = getScale(projectStore.activeWidgetMap[id])
|
|
|
|
|
+ projectStore.activeWidgetMap[id].props.width = Math.round(e.lastEvent.width / scale)
|
|
|
|
|
+ projectStore.activeWidgetMap[id].props.height = Math.round(e.lastEvent.height / scale)
|
|
|
// 带可选固定高度控件
|
|
// 带可选固定高度控件
|
|
|
if (has(projectStore.activeWidgetMap[id].props, 'fixedHeight')) {
|
|
if (has(projectStore.activeWidgetMap[id].props, 'fixedHeight')) {
|
|
|
projectStore.activeWidgetMap[id].props.fixedHeight = true
|
|
projectStore.activeWidgetMap[id].props.fixedHeight = true
|
|
@@ -234,8 +244,9 @@ const onResizeGroupEnd = ({ events }) => {
|
|
|
events.forEach((ev) => {
|
|
events.forEach((ev) => {
|
|
|
const id = ev.target.attributes['widget-id']?.value
|
|
const id = ev.target.attributes['widget-id']?.value
|
|
|
if (ev.lastEvent && id && projectStore.activeWidgetMap[id]) {
|
|
if (ev.lastEvent && id && projectStore.activeWidgetMap[id]) {
|
|
|
- projectStore.activeWidgetMap[id].props.width = Math.round(ev.lastEvent.width)
|
|
|
|
|
- projectStore.activeWidgetMap[id].props.height = Math.round(ev.lastEvent.height)
|
|
|
|
|
|
|
+ const scale = getScale(projectStore.activeWidgetMap[id])
|
|
|
|
|
+ projectStore.activeWidgetMap[id].props.width = Math.round(ev.lastEvent.width / scale)
|
|
|
|
|
+ projectStore.activeWidgetMap[id].props.height = Math.round(ev.lastEvent.height / scale)
|
|
|
// 带可选固定高度控件
|
|
// 带可选固定高度控件
|
|
|
if (has(projectStore.activeWidgetMap[id].props, 'fixedHeight')) {
|
|
if (has(projectStore.activeWidgetMap[id].props, 'fixedHeight')) {
|
|
|
projectStore.activeWidgetMap[id].props.fixedHeight = true
|
|
projectStore.activeWidgetMap[id].props.fixedHeight = true
|