| | |
| | | class="layout-glassDetail"
|
| | | :style="rectStyle(glassDetail, layoutIndex)"
|
| | | @contextmenu.prevent="handleRectRightClick(layoutIndex, rectIndex)"
|
| | | @mousedown="handleRectDragStart(layoutIndex, rectIndex)"
|
| | | @mousemove="handleRectDragging"
|
| | | @mouseup="handleRectDragEnd"
|
| | | @mouseleave="handleRectDragEnd"
|
| | | @click="handleRectClick(layoutIndex, rectIndex)"
|
| | | >
|
| | | <div class="glassDetail-content">
|
| | |
| | | const rectClass = ref('layout-glassDetail');
|
| | | const selectedLayoutIndex = ref(0);
|
| | | const currentRect = ref(null);
|
| | | const dragging = ref(false);
|
| | | const dragStartPos = ref({ x: 0, y: 0 });
|
| | | const dragRect = ref(null);
|
| | | // const dragging = ref(false);
|
| | | // const dragStartPos = ref({ x: 0, y: 0 });
|
| | | // const dragRect = ref(null);
|
| | | const showJiaHao = ref(false);
|
| | | const showProcessId = ref(false);
|
| | | const themeColor = ref(null);
|
| | |
| | |
|
| | | //点击小片
|
| | | const handleRectClick = (layoutIndex, rectIndex) => {
|
| | | if (dragging.value) {
|
| | | return;
|
| | | }
|
| | | // if (dragging.value) {
|
| | | // return;
|
| | | // }
|
| | |
|
| | | focusIndex.value = { layoutIndex, rectIndex };
|
| | | emit('rectClicked', layoutIndex, rectIndex);
|
| | |
| | | };
|
| | |
|
| | | //小片鼠标按下事件
|
| | | const handleRectDragStart = (layoutIndex, rectIndex) => {
|
| | | const layout = layouts.value[layoutIndex];
|
| | | const glassDetail = layout.glassDetails[rectIndex];
|
| | | if (glassDetail.isRemain) return;
|
| | | // const handleRectDragStart = (layoutIndex, rectIndex) => {
|
| | | // const layout = layouts.value[layoutIndex];
|
| | | // const glassDetail = layout.glassDetails[rectIndex];
|
| | | // if (glassDetail.isRemain) return;
|
| | | //
|
| | | // dragRect.value = { layoutIndex, rectIndex };
|
| | | // dragStartPos.value = {
|
| | | // x: event.clientX,
|
| | | // y: event.clientY
|
| | | // };
|
| | | // };
|
| | |
|
| | | dragRect.value = { layoutIndex, rectIndex };
|
| | | dragStartPos.value = {
|
| | | x: event.clientX,
|
| | | y: event.clientY
|
| | | };
|
| | | };
|
| | | // //小片鼠标移动事件
|
| | | // const handleRectDragging = (event) => {
|
| | | // if (!dragRect.value) return;
|
| | | //
|
| | | // // 如果还没确认是拖拽,则先判断是否达到拖拽阈值(例如5像素)
|
| | | // if (!dragging.value) {
|
| | | // const deltaX = event.clientX - dragStartPos.value.x;
|
| | | // const deltaY = event.clientY - dragStartPos.value.y;
|
| | | // const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
| | | //
|
| | | // // 如果移动距离小于阈值,则认为是点击而非拖拽
|
| | | // if (distance < 5) {
|
| | | // return;
|
| | | // }
|
| | | //
|
| | | // // 达到阈值,确认是拖拽操作
|
| | | // dragging.value = true;
|
| | | // }
|
| | | //
|
| | | // const layoutIndex = dragRect.value.layoutIndex;
|
| | | // const rectIndex = dragRect.value.rectIndex;
|
| | | // const layout = layouts.value[layoutIndex];
|
| | | // const glassDetail = layout.glassDetails[rectIndex];
|
| | | //
|
| | | // // 保存原始坐标用于计算偏移量
|
| | | // const originalX = glassDetail.x;
|
| | | // const originalY = glassDetail.y;
|
| | | //
|
| | | // const scale = Math.min(
|
| | | // (props.gw - 100) / layout.width,
|
| | | // (props.gh - 100) / layout.height
|
| | | // );
|
| | | //
|
| | | // const deltaX = event.clientX - dragStartPos.value.x;
|
| | | // const deltaY = event.clientY - dragStartPos.value.y;
|
| | | //
|
| | | // const newRect = { ...glassDetail };
|
| | | // newRect.x += deltaX / scale;
|
| | | // newRect.y += deltaY / scale;
|
| | | //
|
| | | // const otherRects = layout.glassDetails.filter(r => !r.isRemain && r !== glassDetail);
|
| | | // let isValidMove = true;
|
| | | //
|
| | | // otherRects.forEach(otherRect => {
|
| | | // if (checkOverlap(newRect, otherRect)) {
|
| | | // isValidMove = false;
|
| | | // }
|
| | | // });
|
| | | //
|
| | | // if (newRect.x < 0 || newRect.y < 0 ||
|
| | | // newRect.x + newRect.width > layout.width ||
|
| | | // newRect.y + newRect.height > layout.height) {
|
| | | // isValidMove = false;
|
| | | // }
|
| | | //
|
| | | // if (isValidMove) {
|
| | | // glassDetail.x = newRect.x;
|
| | | // glassDetail.y = newRect.y;
|
| | | //
|
| | | // // 更新glassPoint坐标
|
| | | // if (glassDetail.glassPoint && Array.isArray(glassDetail.glassPoint)) {
|
| | | // const offsetX = glassDetail.x - originalX;
|
| | | // const offsetY = glassDetail.y - originalY;
|
| | | //
|
| | | // glassDetail.glassPoint.forEach(point => {
|
| | | // point.X += offsetX;
|
| | | // point.Y += offsetY;
|
| | | // // 添加精度控制
|
| | | // point.X = parseFloat(point.X.toFixed(2));
|
| | | // point.Y = parseFloat(point.Y.toFixed(2));
|
| | | // });
|
| | | // }
|
| | | //
|
| | | // dragStartPos.value = {
|
| | | // x: event.clientX,
|
| | | // y: event.clientY
|
| | | // };
|
| | | // adjustGrayRectangles(layoutIndex);
|
| | | // }
|
| | | // };
|
| | |
|
| | | //小片鼠标移动事件
|
| | | const handleRectDragging = (event) => {
|
| | | if (!dragRect.value) return;
|
| | |
|
| | | // 如果还没确认是拖拽,则先判断是否达到拖拽阈值(例如5像素)
|
| | | if (!dragging.value) {
|
| | | const deltaX = event.clientX - dragStartPos.value.x;
|
| | | const deltaY = event.clientY - dragStartPos.value.y;
|
| | | const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
| | |
|
| | | // 如果移动距离小于阈值,则认为是点击而非拖拽
|
| | | if (distance < 5) {
|
| | | return;
|
| | | }
|
| | |
|
| | | // 达到阈值,确认是拖拽操作
|
| | | dragging.value = true;
|
| | | }
|
| | |
|
| | | const layoutIndex = dragRect.value.layoutIndex;
|
| | | const rectIndex = dragRect.value.rectIndex;
|
| | | const layout = layouts.value[layoutIndex];
|
| | | const glassDetail = layout.glassDetails[rectIndex];
|
| | |
|
| | | // 保存原始坐标用于计算偏移量
|
| | | const originalX = glassDetail.x;
|
| | | const originalY = glassDetail.y;
|
| | |
|
| | | const scale = Math.min(
|
| | | (props.gw - 100) / layout.width,
|
| | | (props.gh - 100) / layout.height
|
| | | );
|
| | |
|
| | | const deltaX = event.clientX - dragStartPos.value.x;
|
| | | const deltaY = event.clientY - dragStartPos.value.y;
|
| | |
|
| | | const newRect = { ...glassDetail };
|
| | | newRect.x += deltaX / scale;
|
| | | newRect.y += deltaY / scale;
|
| | |
|
| | | const otherRects = layout.glassDetails.filter(r => !r.isRemain && r !== glassDetail);
|
| | | let isValidMove = true;
|
| | |
|
| | | otherRects.forEach(otherRect => {
|
| | | if (checkOverlap(newRect, otherRect)) {
|
| | | isValidMove = false;
|
| | | }
|
| | | });
|
| | |
|
| | | if (newRect.x < 0 || newRect.y < 0 ||
|
| | | newRect.x + newRect.width > layout.width ||
|
| | | newRect.y + newRect.height > layout.height) {
|
| | | isValidMove = false;
|
| | | }
|
| | |
|
| | | if (isValidMove) {
|
| | | glassDetail.x = newRect.x;
|
| | | glassDetail.y = newRect.y;
|
| | |
|
| | | // 更新glassPoint坐标
|
| | | if (glassDetail.glassPoint && Array.isArray(glassDetail.glassPoint)) {
|
| | | const offsetX = glassDetail.x - originalX;
|
| | | const offsetY = glassDetail.y - originalY;
|
| | |
|
| | | glassDetail.glassPoint.forEach(point => {
|
| | | point.X += offsetX;
|
| | | point.Y += offsetY;
|
| | | // 添加精度控制
|
| | | point.X = parseFloat(point.X.toFixed(2));
|
| | | point.Y = parseFloat(point.Y.toFixed(2));
|
| | | });
|
| | | }
|
| | |
|
| | | dragStartPos.value = {
|
| | | x: event.clientX,
|
| | | y: event.clientY
|
| | | };
|
| | | adjustGrayRectangles(layoutIndex);
|
| | | }
|
| | | };
|
| | |
|
| | | //小片鼠标松开事件
|
| | | const handleRectDragEnd = () => {
|
| | | dragging.value = false;
|
| | | dragRect.value = null;
|
| | | dragStartPos.value = { x: 0, y: 0 };
|
| | | if (dragRect.value) {
|
| | | const layoutIndex = dragRect.value.layoutIndex;
|
| | | const rectIndex = dragRect.value.rectIndex;
|
| | | const glassDetail = layouts.value[layoutIndex].glassDetails[rectIndex];
|
| | | const layout = layouts.value[layoutIndex];
|
| | | const scale = Math.min(
|
| | | (props.gw - 100) / layout.width,
|
| | | (props.gh - 100) / layout.height
|
| | | );
|
| | |
|
| | | glassDetail.x = parseFloat(glassDetail.x.toFixed(2));
|
| | | glassDetail.y = parseFloat(glassDetail.y.toFixed(2));
|
| | | adjustAlignmentPosition(layoutIndex, rectIndex);
|
| | | }
|
| | |
|
| | | dragging.value = false;
|
| | | dragRect.value = null;
|
| | | };
|
| | | // //小片鼠标松开事件
|
| | | // const handleRectDragEnd = () => {
|
| | | // dragging.value = false;
|
| | | // dragRect.value = null;
|
| | | // dragStartPos.value = { x: 0, y: 0 };
|
| | | // if (dragRect.value) {
|
| | | // const layoutIndex = dragRect.value.layoutIndex;
|
| | | // const rectIndex = dragRect.value.rectIndex;
|
| | | // const glassDetail = layouts.value[layoutIndex].glassDetails[rectIndex];
|
| | | // const layout = layouts.value[layoutIndex];
|
| | | // const scale = Math.min(
|
| | | // (props.gw - 100) / layout.width,
|
| | | // (props.gh - 100) / layout.height
|
| | | // );
|
| | | //
|
| | | // glassDetail.x = parseFloat(glassDetail.x.toFixed(2));
|
| | | // glassDetail.y = parseFloat(glassDetail.y.toFixed(2));
|
| | | // adjustAlignmentPosition(layoutIndex, rectIndex);
|
| | | // }
|
| | | //
|
| | | // dragging.value = false;
|
| | | // dragRect.value = null;
|
| | | // };
|
| | |
|
| | | const adjustAlignmentPosition = (layoutIndex, rectIndex) => {
|
| | | const layout = layouts.value[layoutIndex];
|