From 748ff23ede97970422a7070f081dad8e89a5b27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Fri, 16 Aug 2024 18:01:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=83=AD=E5=8C=BA=E7=B1=BB=E5=9E=8B=E7=9A=84=E6=8B=96=E6=8B=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model-image/model-image-style.vue | 4 +- .../model-lines/model-lines-style.vue | 5 +- .../model-text/model-text-style.vue | 6 +- .../model-custom/components/index.scss | 231 ++++++ .../model-custom/components/index.ts | 90 +++ .../model-custom/components/index.vue | 668 ++++++++++-------- .../model-custom/model-custom-content.vue | 8 +- src/utils/index.ts | 17 + 8 files changed, 726 insertions(+), 303 deletions(-) create mode 100644 src/components/model-custom/components/index.scss diff --git a/src/components/common/custom-module/model-image/model-image-style.vue b/src/components/common/custom-module/model-image/model-image-style.vue index 261eb3b4..19009184 100644 --- a/src/components/common/custom-module/model-image/model-image-style.vue +++ b/src/components/common/custom-module/model-image/model-image-style.vue @@ -109,7 +109,9 @@ watch( diy_data.value.location.x = location_compute(width, val.location.x, 390); diy_data.value.location.y = location_compute(height, val.location.y, center_height.value); - diy_data.value.location.staging_y = diy_data.value.location.y; + diy_data.value.location.record_x = location_compute(width, val.location.record_x, 390); + diy_data.value.location.record_y = location_compute(height, val.location.record_y, center_height.value); + diy_data.value.location.staging_y = location_compute(height, val.location.staging_y, center_height.value); form.value.com_width = width; form.value.com_height = height; diff --git a/src/components/common/custom-module/model-lines/model-lines-style.vue b/src/components/common/custom-module/model-lines/model-lines-style.vue index d996539c..2de993e0 100644 --- a/src/components/common/custom-module/model-lines/model-lines-style.vue +++ b/src/components/common/custom-module/model-lines/model-lines-style.vue @@ -69,7 +69,10 @@ watch(diy_data, (val) => { diy_data.value.location.x = location_compute(width, val.location.x, 390); diy_data.value.location.y = location_compute(height, val.location.y, center_height.value); - diy_data.value.location.staging_y = diy_data.value.location.y; + + diy_data.value.location.record_x = location_compute(width, val.location.record_x, 390); + diy_data.value.location.record_y = location_compute(height, val.location.record_y, center_height.value); + diy_data.value.location.staging_y = location_compute(height, val.location.staging_y, center_height.value); form.value.com_width = width; form.value.com_height = height; diff --git a/src/components/common/custom-module/model-text/model-text-style.vue b/src/components/common/custom-module/model-text/model-text-style.vue index cf294565..d641a026 100644 --- a/src/components/common/custom-module/model-text/model-text-style.vue +++ b/src/components/common/custom-module/model-text/model-text-style.vue @@ -110,7 +110,7 @@ diff --git a/src/components/model-custom/model-custom-content.vue b/src/components/model-custom/model-custom-content.vue index 34759589..b6cdd945 100644 --- a/src/components/model-custom/model-custom-content.vue +++ b/src/components/model-custom/model-custom-content.vue @@ -26,7 +26,9 @@ @@ -63,6 +65,8 @@ const diy_data = ref({ location: { x: 0, y: 0, + record_x: 0, + record_y: 0, staging_y: 0, }, com_data: {}, @@ -71,6 +75,8 @@ const key = ref(''); const dragkey = ref(''); const right_update = (item: any) => { + console.log(item, '122545'); + diy_data.value = item; // 生成随机id key.value = Math.random().toString(36).substring(2); diff --git a/src/utils/index.ts b/src/utils/index.ts index 4338315e..8f8ef5b0 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -232,4 +232,21 @@ export const location_compute = (size: number, location: number, container_size: } else { return location; } +} +// 判断两个矩形是否有交集或者被包裹 +export const isRectangleIntersecting = (rect1: react1, rect2: react1) => { + // 矩形的格式为 { x, y, width, height } + const { x: x1, y: y1, width: w1, height: h1 } = rect1; + const { x: x2, y: y2, width: w2, height: h2 } = rect2; + + // 检查是否有交集 + if ((x1 < x2 + w2 && x1 + w1 > x2) && (y1 < y2 + h2 && y1 + h1 > y2)) { + return true; // 有交集 + } + + // 检查是否一个包含另一个 + if (x1 >= x2 && y1 >= y2 && x1 + w1 <= x2 + w2 && y1 + h1 <= y2 + h2) { + return true; // rect1完全包含rect2 + } + return false; // 无交集 } \ No newline at end of file