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 1/4] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=96=B0?=
=?UTF-8?q?=E5=A2=9E=E7=83=AD=E5=8C=BA=E7=B1=BB=E5=9E=8B=E7=9A=84=E6=8B=96?=
=?UTF-8?q?=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
From dbea7082f5ac51e9c45835370b454adb3732afbe 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:12:17 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../model-custom/components/index.ts | 80 -------------------
.../model-custom/components/index.vue | 3 +-
.../model-custom/model-custom-content.vue | 2 -
src/utils/index.ts | 17 ----
4 files changed, 2 insertions(+), 100 deletions(-)
diff --git a/src/components/model-custom/components/index.ts b/src/components/model-custom/components/index.ts
index 7a0738f0..529c579e 100644
--- a/src/components/model-custom/components/index.ts
+++ b/src/components/model-custom/components/index.ts
@@ -34,84 +34,4 @@ interface react1 {
y: number;
width: number;
height: number;
-}
-// 文本的默认值
-const text_com_data = {
- com_width: 150,
- com_height: 17,
- staging_height: 17,
- text_title: '文本',
- data_source_id: '',
- data_source_list: {},
- text_link: {},
- text_color: '#000',
- text_weight: 'normal',
- text_size: 12,
- text_option: 'none',
- text_location: 'left',
- text_padding: {
- padding: 0,
- padding_top: 0,
- padding_bottom: 0,
- padding_left: 0,
- padding_right: 0,
- },
- text_rotate: 0,
- border_show: false,
- border_color: '#FF5D5D',
- border_style: 'solid',
- border_radius: {
- radius: 0,
- radius_top_left: 0,
- radius_top_right: 0,
- radius_bottom_left: 0,
- radius_bottom_right: 0,
- },
- border_size: 1,
- com_bg: '',
- bottom_up: true,
-}
-// 图片的默认值
-const img_com_data = {
- com_width: 50,
- com_height: 50,
- staging_height: 50,
- img_src: [],
- data_source_id: '',
- data_source_list: {},
- link: {},
- img_radius: {
- radius: 0,
- radius_top_left: 0,
- radius_top_right: 0,
- radius_bottom_left: 0,
- radius_bottom_right: 0,
- },
- img_width: 50,
- img_height: 50,
- img_rotate: 0,
- border_show: false,
- border_color: '#FF3F3F',
- border_style: 'dashed',
- border_radius: {
- radius: 0,
- radius_top_left: 0,
- radius_top_right: 0,
- radius_bottom_left: 0,
- radius_bottom_right: 0,
- },
- border_size: 1,
- bottom_up: true,
-}
-// 线条的默认值
-const line_com_data = {
- com_width: 306,
- com_height: 11,
- staging_height: 11,
- line_settings: 'horizontal',
- line_style: 'solid',
- line_width: 306,
- line_size: 1,
- line_color: '#000',
- bottom_up: true,
}
\ No newline at end of file
diff --git a/src/components/model-custom/components/index.vue b/src/components/model-custom/components/index.vue
index 1bc7ad77..a28a3edf 100644
--- a/src/components/model-custom/components/index.vue
+++ b/src/components/model-custom/components/index.vue
@@ -80,7 +80,8 @@