+
+
+
+ 自适应画布区域
+
+
{{ $t('panel.canvas_size') }}
-
+
*
-
+
@@ -140,7 +146,6 @@ export default {
...this.canvasStyleData,
scale: this.scale
})
- this.$nextTick(() => (eventBus.$emit('resizing', '')))
}, 1000)
},
@@ -320,4 +325,17 @@ export default {
background-color: #ffffff!important;
}
+ >>>.el-switch__core{
+ width:30px!important;
+ height:15px;
+ /*color:#409EFF;*/
+ }
+ /*设置圆*/
+ >>>.el-switch__core::after{
+ width:14px;
+ height:14px;
+ margin-top:-1px;
+ margin-bottom: 2px;
+ }
+
diff --git a/frontend/src/components/canvas/utils/calculateComponentPositonAndSize.js b/frontend/src/components/canvas/utils/calculateComponentPositonAndSize.js
index a0541f2f7c..7e4effc74b 100644
--- a/frontend/src/components/canvas/utils/calculateComponentPositonAndSize.js
+++ b/frontend/src/components/canvas/utils/calculateComponentPositonAndSize.js
@@ -2,272 +2,272 @@
import { calculateRotatedPointCoordinate, getCenterPoint } from './translate'
const funcs = {
- lt: calculateLeftTop,
- t: calculateTop,
- rt: calculateRightTop,
- r: calculateRight,
- rb: calculateRightBottom,
- b: calculateBottom,
- lb: calculateLeftBottom,
- l: calculateLeft,
+ lt: calculateLeftTop,
+ t: calculateTop,
+ rt: calculateRightTop,
+ r: calculateRight,
+ rb: calculateRightBottom,
+ b: calculateBottom,
+ lb: calculateLeftBottom,
+ l: calculateLeft
}
function calculateLeftTop(style, curPositon, proportion, needLockProportion, pointInfo) {
- const { symmetricPoint } = pointInfo
- let newCenterPoint = getCenterPoint(curPositon, symmetricPoint)
- let newTopLeftPoint = calculateRotatedPointCoordinate(curPositon, newCenterPoint, -style.rotate)
- let newBottomRightPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
-
- let newWidth = newBottomRightPoint.x - newTopLeftPoint.x
- let newHeight = newBottomRightPoint.y - newTopLeftPoint.y
+ const { symmetricPoint } = pointInfo
+ let newCenterPoint = getCenterPoint(curPositon, symmetricPoint)
+ let newTopLeftPoint = calculateRotatedPointCoordinate(curPositon, newCenterPoint, -style.rotate)
+ let newBottomRightPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
- if (needLockProportion) {
- if (newWidth / newHeight > proportion) {
- newTopLeftPoint.x += Math.abs(newWidth - newHeight * proportion)
- newWidth = newHeight * proportion
- } else {
- newTopLeftPoint.y += Math.abs(newHeight - newWidth / proportion)
- newHeight = newWidth / proportion
- }
+ let newWidth = newBottomRightPoint.x - newTopLeftPoint.x
+ let newHeight = newBottomRightPoint.y - newTopLeftPoint.y
- // 由于现在求的未旋转前的坐标是以没按比例缩减宽高前的坐标来计算的
- // 所以缩减宽高后,需要按照原来的中心点旋转回去,获得缩减宽高并旋转后对应的坐标
- // 然后以这个坐标和对称点获得新的中心点,并重新计算未旋转前的坐标
- const rotatedTopLeftPoint = calculateRotatedPointCoordinate(newTopLeftPoint, newCenterPoint, style.rotate)
- newCenterPoint = getCenterPoint(rotatedTopLeftPoint, symmetricPoint)
- newTopLeftPoint = calculateRotatedPointCoordinate(rotatedTopLeftPoint, newCenterPoint, -style.rotate)
- newBottomRightPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
-
- newWidth = newBottomRightPoint.x - newTopLeftPoint.x
- newHeight = newBottomRightPoint.y - newTopLeftPoint.y
+ if (needLockProportion) {
+ if (newWidth / newHeight > proportion) {
+ newTopLeftPoint.x += Math.abs(newWidth - newHeight * proportion)
+ newWidth = newHeight * proportion
+ } else {
+ newTopLeftPoint.y += Math.abs(newHeight - newWidth / proportion)
+ newHeight = newWidth / proportion
}
- if (newWidth > 0 && newHeight > 0) {
- style.width = Math.round(newWidth)
- style.height = Math.round(newHeight)
- style.left = Math.round(newTopLeftPoint.x)
- style.top = Math.round(newTopLeftPoint.y)
- }
+ // 由于现在求的未旋转前的坐标是以没按比例缩减宽高前的坐标来计算的
+ // 所以缩减宽高后,需要按照原来的中心点旋转回去,获得缩减宽高并旋转后对应的坐标
+ // 然后以这个坐标和对称点获得新的中心点,并重新计算未旋转前的坐标
+ const rotatedTopLeftPoint = calculateRotatedPointCoordinate(newTopLeftPoint, newCenterPoint, style.rotate)
+ newCenterPoint = getCenterPoint(rotatedTopLeftPoint, symmetricPoint)
+ newTopLeftPoint = calculateRotatedPointCoordinate(rotatedTopLeftPoint, newCenterPoint, -style.rotate)
+ newBottomRightPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
+
+ newWidth = newBottomRightPoint.x - newTopLeftPoint.x
+ newHeight = newBottomRightPoint.y - newTopLeftPoint.y
+ }
+
+ if (newWidth > 0 && newHeight > 0) {
+ style.width = Math.round(newWidth)
+ style.height = Math.round(newHeight)
+ style.left = Math.round(newTopLeftPoint.x)
+ style.top = Math.round(newTopLeftPoint.y)
+ }
}
function calculateRightTop(style, curPositon, proportion, needLockProportion, pointInfo) {
- const { symmetricPoint } = pointInfo
- let newCenterPoint = getCenterPoint(curPositon, symmetricPoint)
- let newTopRightPoint = calculateRotatedPointCoordinate(curPositon, newCenterPoint, -style.rotate)
- let newBottomLeftPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
-
- let newWidth = newTopRightPoint.x - newBottomLeftPoint.x
- let newHeight = newBottomLeftPoint.y - newTopRightPoint.y
+ const { symmetricPoint } = pointInfo
+ let newCenterPoint = getCenterPoint(curPositon, symmetricPoint)
+ let newTopRightPoint = calculateRotatedPointCoordinate(curPositon, newCenterPoint, -style.rotate)
+ let newBottomLeftPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
- if (needLockProportion) {
- if (newWidth / newHeight > proportion) {
- newTopRightPoint.x -= Math.abs(newWidth - newHeight * proportion)
- newWidth = newHeight * proportion
- } else {
- newTopRightPoint.y += Math.abs(newHeight - newWidth / proportion)
- newHeight = newWidth / proportion
- }
+ let newWidth = newTopRightPoint.x - newBottomLeftPoint.x
+ let newHeight = newBottomLeftPoint.y - newTopRightPoint.y
- const rotatedTopRightPoint = calculateRotatedPointCoordinate(newTopRightPoint, newCenterPoint, style.rotate)
- newCenterPoint = getCenterPoint(rotatedTopRightPoint, symmetricPoint)
- newTopRightPoint = calculateRotatedPointCoordinate(rotatedTopRightPoint, newCenterPoint, -style.rotate)
- newBottomLeftPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
-
- newWidth = newTopRightPoint.x - newBottomLeftPoint.x
- newHeight = newBottomLeftPoint.y - newTopRightPoint.y
- }
-
- if (newWidth > 0 && newHeight > 0) {
- style.width = Math.round(newWidth)
- style.height = Math.round(newHeight)
- style.left = Math.round(newBottomLeftPoint.x)
- style.top = Math.round(newTopRightPoint.y)
+ if (needLockProportion) {
+ if (newWidth / newHeight > proportion) {
+ newTopRightPoint.x -= Math.abs(newWidth - newHeight * proportion)
+ newWidth = newHeight * proportion
+ } else {
+ newTopRightPoint.y += Math.abs(newHeight - newWidth / proportion)
+ newHeight = newWidth / proportion
}
+
+ const rotatedTopRightPoint = calculateRotatedPointCoordinate(newTopRightPoint, newCenterPoint, style.rotate)
+ newCenterPoint = getCenterPoint(rotatedTopRightPoint, symmetricPoint)
+ newTopRightPoint = calculateRotatedPointCoordinate(rotatedTopRightPoint, newCenterPoint, -style.rotate)
+ newBottomLeftPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
+
+ newWidth = newTopRightPoint.x - newBottomLeftPoint.x
+ newHeight = newBottomLeftPoint.y - newTopRightPoint.y
+ }
+
+ if (newWidth > 0 && newHeight > 0) {
+ style.width = Math.round(newWidth)
+ style.height = Math.round(newHeight)
+ style.left = Math.round(newBottomLeftPoint.x)
+ style.top = Math.round(newTopRightPoint.y)
+ }
}
-
+
function calculateRightBottom(style, curPositon, proportion, needLockProportion, pointInfo) {
- const { symmetricPoint } = pointInfo
- let newCenterPoint = getCenterPoint(curPositon, symmetricPoint)
- let newTopLeftPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
- let newBottomRightPoint = calculateRotatedPointCoordinate(curPositon, newCenterPoint, -style.rotate)
-
- let newWidth = newBottomRightPoint.x - newTopLeftPoint.x
- let newHeight = newBottomRightPoint.y - newTopLeftPoint.y
+ const { symmetricPoint } = pointInfo
+ let newCenterPoint = getCenterPoint(curPositon, symmetricPoint)
+ let newTopLeftPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
+ let newBottomRightPoint = calculateRotatedPointCoordinate(curPositon, newCenterPoint, -style.rotate)
- if (needLockProportion) {
- if (newWidth / newHeight > proportion) {
- newBottomRightPoint.x -= Math.abs(newWidth - newHeight * proportion)
- newWidth = newHeight * proportion
- } else {
- newBottomRightPoint.y -= Math.abs(newHeight - newWidth / proportion)
- newHeight = newWidth / proportion
- }
+ let newWidth = newBottomRightPoint.x - newTopLeftPoint.x
+ let newHeight = newBottomRightPoint.y - newTopLeftPoint.y
- const rotatedBottomRightPoint = calculateRotatedPointCoordinate(newBottomRightPoint, newCenterPoint, style.rotate)
- newCenterPoint = getCenterPoint(rotatedBottomRightPoint, symmetricPoint)
- newTopLeftPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
- newBottomRightPoint = calculateRotatedPointCoordinate(rotatedBottomRightPoint, newCenterPoint, -style.rotate)
-
- newWidth = newBottomRightPoint.x - newTopLeftPoint.x
- newHeight = newBottomRightPoint.y - newTopLeftPoint.y
+ if (needLockProportion) {
+ if (newWidth / newHeight > proportion) {
+ newBottomRightPoint.x -= Math.abs(newWidth - newHeight * proportion)
+ newWidth = newHeight * proportion
+ } else {
+ newBottomRightPoint.y -= Math.abs(newHeight - newWidth / proportion)
+ newHeight = newWidth / proportion
}
- if (newWidth > 0 && newHeight > 0) {
- style.width = Math.round(newWidth)
- style.height = Math.round(newHeight)
- style.left = Math.round(newTopLeftPoint.x)
- style.top = Math.round(newTopLeftPoint.y)
- }
+ const rotatedBottomRightPoint = calculateRotatedPointCoordinate(newBottomRightPoint, newCenterPoint, style.rotate)
+ newCenterPoint = getCenterPoint(rotatedBottomRightPoint, symmetricPoint)
+ newTopLeftPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
+ newBottomRightPoint = calculateRotatedPointCoordinate(rotatedBottomRightPoint, newCenterPoint, -style.rotate)
+
+ newWidth = newBottomRightPoint.x - newTopLeftPoint.x
+ newHeight = newBottomRightPoint.y - newTopLeftPoint.y
+ }
+
+ if (newWidth > 0 && newHeight > 0) {
+ style.width = Math.round(newWidth)
+ style.height = Math.round(newHeight)
+ style.left = Math.round(newTopLeftPoint.x)
+ style.top = Math.round(newTopLeftPoint.y)
+ }
}
-
+
function calculateLeftBottom(style, curPositon, proportion, needLockProportion, pointInfo) {
- const { symmetricPoint } = pointInfo
- let newCenterPoint = getCenterPoint(curPositon, symmetricPoint)
- let newTopRightPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
- let newBottomLeftPoint = calculateRotatedPointCoordinate(curPositon, newCenterPoint, -style.rotate)
+ const { symmetricPoint } = pointInfo
+ let newCenterPoint = getCenterPoint(curPositon, symmetricPoint)
+ let newTopRightPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
+ let newBottomLeftPoint = calculateRotatedPointCoordinate(curPositon, newCenterPoint, -style.rotate)
- let newWidth = newTopRightPoint.x - newBottomLeftPoint.x
- let newHeight = newBottomLeftPoint.y - newTopRightPoint.y
+ let newWidth = newTopRightPoint.x - newBottomLeftPoint.x
+ let newHeight = newBottomLeftPoint.y - newTopRightPoint.y
- if (needLockProportion) {
- if (newWidth / newHeight > proportion) {
- newBottomLeftPoint.x += Math.abs(newWidth - newHeight * proportion)
- newWidth = newHeight * proportion
- } else {
- newBottomLeftPoint.y -= Math.abs(newHeight - newWidth / proportion)
- newHeight = newWidth / proportion
- }
-
- const rotatedBottomLeftPoint = calculateRotatedPointCoordinate(newBottomLeftPoint, newCenterPoint, style.rotate)
- newCenterPoint = getCenterPoint(rotatedBottomLeftPoint, symmetricPoint)
- newTopRightPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
- newBottomLeftPoint = calculateRotatedPointCoordinate(rotatedBottomLeftPoint, newCenterPoint, -style.rotate)
-
- newWidth = newTopRightPoint.x - newBottomLeftPoint.x
- newHeight = newBottomLeftPoint.y - newTopRightPoint.y
+ if (needLockProportion) {
+ if (newWidth / newHeight > proportion) {
+ newBottomLeftPoint.x += Math.abs(newWidth - newHeight * proportion)
+ newWidth = newHeight * proportion
+ } else {
+ newBottomLeftPoint.y -= Math.abs(newHeight - newWidth / proportion)
+ newHeight = newWidth / proportion
}
- if (newWidth > 0 && newHeight > 0) {
- style.width = Math.round(newWidth)
- style.height = Math.round(newHeight)
- style.left = Math.round(newBottomLeftPoint.x)
- style.top = Math.round(newTopRightPoint.y)
- }
+ const rotatedBottomLeftPoint = calculateRotatedPointCoordinate(newBottomLeftPoint, newCenterPoint, style.rotate)
+ newCenterPoint = getCenterPoint(rotatedBottomLeftPoint, symmetricPoint)
+ newTopRightPoint = calculateRotatedPointCoordinate(symmetricPoint, newCenterPoint, -style.rotate)
+ newBottomLeftPoint = calculateRotatedPointCoordinate(rotatedBottomLeftPoint, newCenterPoint, -style.rotate)
+
+ newWidth = newTopRightPoint.x - newBottomLeftPoint.x
+ newHeight = newBottomLeftPoint.y - newTopRightPoint.y
+ }
+
+ if (newWidth > 0 && newHeight > 0) {
+ style.width = Math.round(newWidth)
+ style.height = Math.round(newHeight)
+ style.left = Math.round(newBottomLeftPoint.x)
+ style.top = Math.round(newTopRightPoint.y)
+ }
}
function calculateTop(style, curPositon, proportion, needLockProportion, pointInfo) {
- const { symmetricPoint, curPoint } = pointInfo
- let rotatedcurPositon = calculateRotatedPointCoordinate(curPositon, curPoint, -style.rotate)
- let rotatedTopMiddlePoint = calculateRotatedPointCoordinate({
- x: curPoint.x,
- y: rotatedcurPositon.y,
- }, curPoint, style.rotate)
-
- // 勾股定理
- let newHeight = Math.sqrt((rotatedTopMiddlePoint.x - symmetricPoint.x) ** 2 + (rotatedTopMiddlePoint.y - symmetricPoint.y) ** 2)
-
- if (newHeight > 0) {
- const newCenter = {
- x: rotatedTopMiddlePoint.x - (rotatedTopMiddlePoint.x - symmetricPoint.x) / 2,
- y: rotatedTopMiddlePoint.y + (symmetricPoint.y - rotatedTopMiddlePoint.y) / 2,
- }
+ const { symmetricPoint, curPoint } = pointInfo
+ const rotatedcurPositon = calculateRotatedPointCoordinate(curPositon, curPoint, -style.rotate)
+ const rotatedTopMiddlePoint = calculateRotatedPointCoordinate({
+ x: curPoint.x,
+ y: rotatedcurPositon.y
+ }, curPoint, style.rotate)
- let width = style.width
- // 因为调整的是高度 所以只需根据锁定的比例调整宽度即可
- if (needLockProportion) {
- width = newHeight * proportion
- }
-
- style.width = width
- style.height = Math.round(newHeight)
- style.top = Math.round(newCenter.y - (newHeight / 2))
- style.left = Math.round(newCenter.x - (style.width / 2))
+ // 勾股定理
+ const newHeight = Math.sqrt((rotatedTopMiddlePoint.x - symmetricPoint.x) ** 2 + (rotatedTopMiddlePoint.y - symmetricPoint.y) ** 2)
+
+ if (newHeight > 0) {
+ const newCenter = {
+ x: rotatedTopMiddlePoint.x - (rotatedTopMiddlePoint.x - symmetricPoint.x) / 2,
+ y: rotatedTopMiddlePoint.y + (symmetricPoint.y - rotatedTopMiddlePoint.y) / 2
}
+
+ let width = style.width
+ // 因为调整的是高度 所以只需根据锁定的比例调整宽度即可
+ if (needLockProportion) {
+ width = newHeight * proportion
+ }
+
+ style.width = width
+ style.height = Math.round(newHeight)
+ style.top = Math.round(newCenter.y - (newHeight / 2))
+ style.left = Math.round(newCenter.x - (style.width / 2))
+ }
}
-
+
function calculateRight(style, curPositon, proportion, needLockProportion, pointInfo) {
- const { symmetricPoint, curPoint } = pointInfo
- const rotatedcurPositon = calculateRotatedPointCoordinate(curPositon, curPoint, -style.rotate)
- const rotatedRightMiddlePoint = calculateRotatedPointCoordinate({
- x: rotatedcurPositon.x,
- y: curPoint.y,
- }, curPoint, style.rotate)
-
- let newWidth = Math.sqrt((rotatedRightMiddlePoint.x - symmetricPoint.x) ** 2 + (rotatedRightMiddlePoint.y - symmetricPoint.y) ** 2)
- if (newWidth > 0) {
- const newCenter = {
- x: rotatedRightMiddlePoint.x - (rotatedRightMiddlePoint.x - symmetricPoint.x) / 2,
- y: rotatedRightMiddlePoint.y + (symmetricPoint.y - rotatedRightMiddlePoint.y) / 2,
- }
+ const { symmetricPoint, curPoint } = pointInfo
+ const rotatedcurPositon = calculateRotatedPointCoordinate(curPositon, curPoint, -style.rotate)
+ const rotatedRightMiddlePoint = calculateRotatedPointCoordinate({
+ x: rotatedcurPositon.x,
+ y: curPoint.y
+ }, curPoint, style.rotate)
- let height = style.height
- // 因为调整的是宽度 所以只需根据锁定的比例调整高度即可
- if (needLockProportion) {
- height = newWidth / proportion
- }
-
- style.height = height
- style.width = Math.round(newWidth)
- style.top = Math.round(newCenter.y - (style.height / 2))
- style.left = Math.round(newCenter.x - (newWidth / 2))
+ const newWidth = Math.sqrt((rotatedRightMiddlePoint.x - symmetricPoint.x) ** 2 + (rotatedRightMiddlePoint.y - symmetricPoint.y) ** 2)
+ if (newWidth > 0) {
+ const newCenter = {
+ x: rotatedRightMiddlePoint.x - (rotatedRightMiddlePoint.x - symmetricPoint.x) / 2,
+ y: rotatedRightMiddlePoint.y + (symmetricPoint.y - rotatedRightMiddlePoint.y) / 2
}
+
+ let height = style.height
+ // 因为调整的是宽度 所以只需根据锁定的比例调整高度即可
+ if (needLockProportion) {
+ height = newWidth / proportion
+ }
+
+ style.height = height
+ style.width = Math.round(newWidth)
+ style.top = Math.round(newCenter.y - (style.height / 2))
+ style.left = Math.round(newCenter.x - (newWidth / 2))
+ }
}
-
+
function calculateBottom(style, curPositon, proportion, needLockProportion, pointInfo) {
- const { symmetricPoint, curPoint } = pointInfo
- const rotatedcurPositon = calculateRotatedPointCoordinate(curPositon, curPoint, -style.rotate)
- const rotatedBottomMiddlePoint = calculateRotatedPointCoordinate({
- x: curPoint.x,
- y: rotatedcurPositon.y,
- }, curPoint, style.rotate)
-
- const newHeight = Math.sqrt((rotatedBottomMiddlePoint.x - symmetricPoint.x) ** 2 + (rotatedBottomMiddlePoint.y - symmetricPoint.y) ** 2)
- if (newHeight > 0) {
- const newCenter = {
- x: rotatedBottomMiddlePoint.x - (rotatedBottomMiddlePoint.x - symmetricPoint.x) / 2,
- y: rotatedBottomMiddlePoint.y + (symmetricPoint.y - rotatedBottomMiddlePoint.y) / 2,
- }
+ const { symmetricPoint, curPoint } = pointInfo
+ const rotatedcurPositon = calculateRotatedPointCoordinate(curPositon, curPoint, -style.rotate)
+ const rotatedBottomMiddlePoint = calculateRotatedPointCoordinate({
+ x: curPoint.x,
+ y: rotatedcurPositon.y
+ }, curPoint, style.rotate)
- let width = style.width
- // 因为调整的是高度 所以只需根据锁定的比例调整宽度即可
- if (needLockProportion) {
- width = newHeight * proportion
- }
-
- style.width = width
- style.height = Math.round(newHeight)
- style.top = Math.round(newCenter.y - (newHeight / 2))
- style.left = Math.round(newCenter.x - (style.width / 2))
+ const newHeight = Math.sqrt((rotatedBottomMiddlePoint.x - symmetricPoint.x) ** 2 + (rotatedBottomMiddlePoint.y - symmetricPoint.y) ** 2)
+ if (newHeight > 0) {
+ const newCenter = {
+ x: rotatedBottomMiddlePoint.x - (rotatedBottomMiddlePoint.x - symmetricPoint.x) / 2,
+ y: rotatedBottomMiddlePoint.y + (symmetricPoint.y - rotatedBottomMiddlePoint.y) / 2
}
+
+ let width = style.width
+ // 因为调整的是高度 所以只需根据锁定的比例调整宽度即可
+ if (needLockProportion) {
+ width = newHeight * proportion
+ }
+
+ style.width = width
+ style.height = Math.round(newHeight)
+ style.top = Math.round(newCenter.y - (newHeight / 2))
+ style.left = Math.round(newCenter.x - (style.width / 2))
+ }
}
-
+
function calculateLeft(style, curPositon, proportion, needLockProportion, pointInfo) {
- const { symmetricPoint, curPoint } = pointInfo
- const rotatedcurPositon = calculateRotatedPointCoordinate(curPositon, curPoint, -style.rotate)
- const rotatedLeftMiddlePoint = calculateRotatedPointCoordinate({
- x: rotatedcurPositon.x,
- y: curPoint.y,
- }, curPoint, style.rotate)
-
- const newWidth = Math.sqrt((rotatedLeftMiddlePoint.x - symmetricPoint.x) ** 2 + (rotatedLeftMiddlePoint.y - symmetricPoint.y) ** 2)
- if (newWidth > 0) {
- const newCenter = {
- x: rotatedLeftMiddlePoint.x - (rotatedLeftMiddlePoint.x - symmetricPoint.x) / 2,
- y: rotatedLeftMiddlePoint.y + (symmetricPoint.y - rotatedLeftMiddlePoint.y) / 2,
- }
-
- let height = style.height
- if (needLockProportion) {
- height = newWidth / proportion
- }
-
- style.height = height
- style.width = Math.round(newWidth)
- style.top = Math.round(newCenter.y - (style.height / 2))
- style.left = Math.round(newCenter.x - (newWidth / 2))
+ const { symmetricPoint, curPoint } = pointInfo
+ const rotatedcurPositon = calculateRotatedPointCoordinate(curPositon, curPoint, -style.rotate)
+ const rotatedLeftMiddlePoint = calculateRotatedPointCoordinate({
+ x: rotatedcurPositon.x,
+ y: curPoint.y
+ }, curPoint, style.rotate)
+
+ const newWidth = Math.sqrt((rotatedLeftMiddlePoint.x - symmetricPoint.x) ** 2 + (rotatedLeftMiddlePoint.y - symmetricPoint.y) ** 2)
+ if (newWidth > 0) {
+ const newCenter = {
+ x: rotatedLeftMiddlePoint.x - (rotatedLeftMiddlePoint.x - symmetricPoint.x) / 2,
+ y: rotatedLeftMiddlePoint.y + (symmetricPoint.y - rotatedLeftMiddlePoint.y) / 2
}
+
+ let height = style.height
+ if (needLockProportion) {
+ height = newWidth / proportion
+ }
+
+ style.height = height
+ style.width = Math.round(newWidth)
+ style.top = Math.round(newCenter.y - (style.height / 2))
+ style.left = Math.round(newCenter.x - (newWidth / 2))
+ }
}
export default function calculateComponentPositonAndSize(name, style, curPositon, proportion, needLockProportion, pointInfo) {
- funcs[name](style, curPositon, proportion, needLockProportion, pointInfo)
-}
\ No newline at end of file
+ funcs[name](style, curPositon, proportion, needLockProportion, pointInfo)
+}
diff --git a/frontend/src/components/canvas/utils/translate.js b/frontend/src/components/canvas/utils/translate.js
index 157a8d0d4c..24787269ae 100644
--- a/frontend/src/components/canvas/utils/translate.js
+++ b/frontend/src/components/canvas/utils/translate.js
@@ -126,6 +126,30 @@ export function changeStyleWithScale(value) {
return value * parseInt(store.state.canvasStyleData.scale) / 100
}
-export function changeStyleWithScaleIn(value, scale) {
- return value * parseInt(scale) / 100
+// 自适应宽高
+export function changeStyleWithScaleHeightInAuto(value) {
+ const scale = store.state.canvasStyleData.scaleHeight ? store.state.canvasStyleData.scaleHeight : 100
+ const result = value * scale / 100
+ console.log('heightInAuto=>' + scale + ';' + result)
+ return result
+}
+
+// 自适应宽高
+export function changeStyleWithScaleWidthInAuto(value) {
+ const scale = store.state.canvasStyleData.scaleWidth ? store.state.canvasStyleData.scaleWidth : 100
+ const result = value * scale / 100
+ console.log('widthInAuto=>' + scale + ';' + result)
+ return result
+}
+
+export function getOriginStyleHeight(value) {
+ const scale = store.state.canvasStyleData.scaleHeight ? store.state.canvasStyleData.scaleHeight : 100
+ const result = value / (scale / 100)
+ return result
+}
+
+export function getOriginStyleWidth(value) {
+ const scale = store.state.canvasStyleData.scaleWidth ? store.state.canvasStyleData.scaleWidth : 100
+ const result = value / (scale / 100)
+ return result
}
diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js
index dcde8db87d..e626257d9a 100644
--- a/frontend/src/store/index.js
+++ b/frontend/src/store/index.js
@@ -42,6 +42,7 @@ const data = {
canvasStyleData: DEFAULT_COMMON_CANVAS_STYLE, // 页面全局数据 //扩展公共样式 公共的仪表板样式,用来实时响应样式的变化
componentData: [], // 画布组件数据
curComponent: null,
+ curCanvasScale: null,
curComponentIndex: null,
// 点击画布时是否点中组件,主要用于取消选中组件用。
// 如果没点中组件,并且在画布空白处弹起鼠标,则取消当前组件的选中状态
@@ -75,11 +76,16 @@ const data = {
state.curComponentIndex = index
},
- setShapeStyle({ curComponent }, { top, left, width, height, rotate }) {
- if (top) curComponent.style.top = top
- if (left) curComponent.style.left = left
- if (width) curComponent.style.width = width
- if (height) curComponent.style.height = height
+ setCurCanvasScale(state, curCanvasScale) {
+ debugger
+ state.curCanvasScale = curCanvasScale
+ },
+
+ setShapeStyle({ curComponent, canvasStyleData, curCanvasScale }, { top, left, width, height, rotate }) {
+ if (top) curComponent.style.top = parseInt(canvasStyleData.selfAdaption ? (top * 100 / curCanvasScale.scaleHeight) : top)
+ if (left) curComponent.style.left = parseInt(canvasStyleData.selfAdaption ? (left * 100 / curCanvasScale.scaleWidth) : left)
+ if (width) curComponent.style.width = parseInt(canvasStyleData.selfAdaption ? (width * 100 / curCanvasScale.scaleWidth) : width)
+ if (height) curComponent.style.height = parseInt(canvasStyleData.selfAdaption ? (height * 100 / curCanvasScale.scaleHeight) : height)
if (rotate) curComponent.style.rotate = rotate
},
diff --git a/frontend/src/views/panel/edit/index.vue b/frontend/src/views/panel/edit/index.vue
index b2a3865b97..9f0641d617 100644
--- a/frontend/src/views/panel/edit/index.vue
+++ b/frontend/src/views/panel/edit/index.vue
@@ -57,7 +57,7 @@
-
+
-
+
@@ -147,6 +148,7 @@ import { findOne } from '@/api/panel/panel'
import PreviewFullScreen from '@/components/canvas/components/Editor/PreviewFullScreen'
import Preview from '@/components/canvas/components/Editor/Preview'
import AttrList from '@/components/canvas/components/AttrList.vue'
+import elementResizeDetectorMaker from 'element-resize-detector'
// 引入样式
import '@/components/canvas/assets/iconfont/iconfont.css'
@@ -187,7 +189,21 @@ export default {
subjectVisible: false,
previewVisible: false,
componentStyleShow: true,
- aidedButtonActive: false
+ aidedButtonActive: false,
+ timer: null,
+ needToChange: [
+ 'top',
+ 'left',
+ 'width',
+ 'height',
+ 'fontSize',
+ 'borderWidth'
+ ],
+ scale: '100',
+ outStyle: {
+ width: null,
+ height: null
+ }
}
},
@@ -238,6 +254,15 @@ export default {
bus.$on('previewFullScreenClose', () => {
this.previewVisible = false
})
+ const _this = this
+ const erd = elementResizeDetectorMaker()
+ // 监听div变动事件
+ erd.listenTo(document.getElementById('canvasInfo-main'), element => {
+ _this.$nextTick(() => {
+ debugger
+ _this.restore()
+ })
+ })
},
beforeDestroy() {
const elx = this.$refs.rightPanel
@@ -410,8 +435,24 @@ export default {
},
changeAidedDesign() {
this.aidedButtonActive = !this.aidedButtonActive
+ },
+ getOriginStyle(value) {
+ const scale = this.canvasStyleData.scale
+ const result = value / (parseInt(scale) / 100)
+ return result
+ },
+ restore() {
+ debugger
+ if (document.getElementById('canvasInfo')) {
+ this.$nextTick(() => {
+ const canvasHeight = document.getElementById('canvasInfo').offsetHeight
+ const canvasWidth = document.getElementById('canvasInfo').offsetWidth
+ this.outStyle.height = canvasHeight
+ this.outStyle.width = canvasWidth
+ console.log(canvasHeight + '--' + canvasWidth)
+ })
+ }
}
-
}
}
@@ -419,9 +460,9 @@ export default {