From 35b5db898c08f8fc34443c52c6c1e4a1adb42209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=92=AC=E8=BD=AE=E7=8C=AB?= <10928033@qq.com> Date: Thu, 27 Oct 2022 22:55:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=AB=E4=B8=AA=E7=82=B9=E7=9A=84?= =?UTF-8?q?=E5=9D=90=E6=A0=87=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/center-panel/index.vue | 34 +++++++++++++ .../webtopo-svgedit/composables/index.ts | 51 +++++++++++++++++++ src/store/global/index.ts | 3 ++ src/store/global/types.ts | 19 +++++-- 4 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 src/components/webtopo-svgedit/composables/index.ts diff --git a/src/components/webtopo-svgedit/components/center-panel/index.vue b/src/components/webtopo-svgedit/components/center-panel/index.vue index 35ca468..ac661cb 100644 --- a/src/components/webtopo-svgedit/components/center-panel/index.vue +++ b/src/components/webtopo-svgedit/components/center-panel/index.vue @@ -153,6 +153,40 @@ width: 0, height: 0 }, + point_coordinate: { + tl: { + x: 0, + y: 0 + }, + tc: { + x: 0, + y: 0 + }, + tr: { + x: 0, + y: 0 + }, + l: { + x: 0, + y: 0 + }, + r: { + x: 0, + y: 0 + }, + bl: { + x: 0, + y: 0 + }, + bc: { + x: 0, + y: 0 + }, + br: { + x: 0, + y: 0 + } + }, ...globalStore.create_svg_info }; globalStore.setHandleSvgInfo(done_item_json, globalStore.done_json.length); diff --git a/src/components/webtopo-svgedit/composables/index.ts b/src/components/webtopo-svgedit/composables/index.ts new file mode 100644 index 0000000..cc7a37e --- /dev/null +++ b/src/components/webtopo-svgedit/composables/index.ts @@ -0,0 +1,51 @@ +import { useGlobalStore } from '../store/global'; +import { calculateRotatedPointCoordinate } from '../utils'; + +export const useSetPointCoordinate = () => { + const globalStore = useGlobalStore(); + if (globalStore.handle_svg_info) { + const item_point = globalStore.handle_svg_info.info; + globalStore.handle_svg_info.info.point_coordinate = { + tl: calculateRotatedPointCoordinate( + item_point.point_coordinate.tl, + item_point.client, + -item_point.rotate + ), + tc: calculateRotatedPointCoordinate( + item_point.point_coordinate.tc, + item_point.client, + -item_point.rotate + ), + tr: calculateRotatedPointCoordinate( + item_point.point_coordinate.tr, + item_point.client, + -item_point.rotate + ), + l: calculateRotatedPointCoordinate( + item_point.point_coordinate.l, + item_point.client, + -item_point.rotate + ), + r: calculateRotatedPointCoordinate( + item_point.point_coordinate.r, + item_point.client, + -item_point.rotate + ), + bl: calculateRotatedPointCoordinate( + item_point.point_coordinate.bl, + item_point.client, + -item_point.rotate + ), + bc: calculateRotatedPointCoordinate( + item_point.point_coordinate.bc, + item_point.client, + -item_point.rotate + ), + br: calculateRotatedPointCoordinate( + item_point.point_coordinate.br, + item_point.client, + -item_point.rotate + ) + }; + } +}; diff --git a/src/store/global/index.ts b/src/store/global/index.ts index 94b5c71..5fccdb2 100644 --- a/src/store/global/index.ts +++ b/src/store/global/index.ts @@ -98,3 +98,6 @@ export const useGlobalStore = defineStore('global-store', { } } }); +useGlobalStore().$subscribe((mutation, state) => { + console.log(mutation, state, 102); +}); diff --git a/src/store/global/types.ts b/src/store/global/types.ts index f17e113..75874c8 100644 --- a/src/store/global/types.ts +++ b/src/store/global/types.ts @@ -14,10 +14,7 @@ export interface IDoneJson extends IConfigItem { id: string; x: number; y: number; - client: { - x: number; - y: number; - }; + client: ICoordinate; scale_x: number; scale_y: number; rotate: number; @@ -27,6 +24,16 @@ export interface IDoneJson extends IConfigItem { width: number; height: number; }; + point_coordinate: { + tl: ICoordinate; + tc: ICoordinate; + tr: ICoordinate; + l: ICoordinate; + r: ICoordinate; + bl: ICoordinate; + bc: ICoordinate; + br: ICoordinate; + }; } export enum EGlobalStoreIntention { None = 'None', @@ -91,3 +98,7 @@ export enum EScaleInfoType { BottomCenter = 'BottomCenter', BottomRight = 'BottomRight' } +export interface ICoordinate { + x: number; + y: number; +}