From 48bf4aa9898236899cd079b5ca2cc980c651fac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=86=9B?= <253495832@qq.com> Date: Tue, 12 May 2026 14:43:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E5=8D=87=E7=BA=A7vue3-sketch-ruler?= =?UTF-8?q?=E5=88=B02X?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- pnpm-lock.yaml | 26 +- src/plugins/customComponents.ts | 2 +- .../chartLayoutStore/chartLayoutStore.d.ts | 2 - .../chartLayoutStore/chartLayoutStore.ts | 5 - .../components/EditBottom/index.vue | 10 +- .../components/EditRange/index.vue | 12 +- .../ContentEdit/components/EditRule/index.vue | 270 +++++------------- src/views/chart/ContentEdit/index.vue | 27 +- 9 files changed, 114 insertions(+), 242 deletions(-) diff --git a/package.json b/package.json index 0e732bdbb..b3f7dbcfe 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "vue-i18n": "9.2.2", "vue-router": "4.0.12", "vue3-lazyload": "^0.2.5-beta", - "vue3-sketch-ruler": "^1.3.3", + "vue3-sketch-ruler": "^2.4.1", "vuedraggable": "^4.1.0" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9704bd877..701fcea8a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -111,8 +111,8 @@ importers: specifier: ^0.2.5-beta version: 0.2.5-beta(@vue/compiler-sfc@3.5.16)(vue@3.5.16(typescript@4.6.3)) vue3-sketch-ruler: - specifier: ^1.3.3 - version: 1.3.16(vue@3.5.16(typescript@4.6.3)) + specifier: ^2.4.1 + version: 2.4.1 vuedraggable: specifier: ^4.1.0 version: 4.1.0(vue@3.5.16(typescript@4.6.3)) @@ -3946,18 +3946,8 @@ packages: '@vue/compiler-sfc': '>=3.0.0' vue: '>=3.0.0' - vue3-sketch-ruler@1.3.16: - resolution: {integrity: sha512-k/TBOwbueU9eWOF7k/emsZMwtEqFk/FxG+h//TlaZ2B8RWbxhIe6hPFgggO4Jng10ARsuH4cMGAR+ZOuN4ozgg==} - deprecated: This version is deprecated. Please upgrade to version 2X for better features and performance.See https://github.com/kakajun/vue3-sketch-ruler - hasBin: true - peerDependencies: - '@vue/composition-api': ^1.1.0 - vue: ^2.6.0 || ^3.2.0 - peerDependenciesMeta: - '@vue/composition-api': - optional: true - vue: - optional: true + vue3-sketch-ruler@2.4.1: + resolution: {integrity: sha512-TMMJ5v3cqDA94DPUa1iFHBx4D+FqEqpNXwzGU310aaMDllqyvyFfZigBFryeCRO7Q7EuOD5J5Zwc++LOCHB7Jw==} vue@3.5.16: resolution: {integrity: sha512-rjOV2ecxMd5SiAmof2xzh2WxntRcigkX/He4YFJ6WdRvVUrbt6DxC1Iujh10XLl8xCDRDtGKMeO3D+pRQ1PP9w==} @@ -4323,7 +4313,7 @@ snapshots: '@types/node': 20.5.1 chalk: 4.1.2 cosmiconfig: 8.3.6(typescript@5.8.3) - cosmiconfig-typescript-loader: 4.4.0(@types/node@20.5.1)(cosmiconfig@8.3.6(typescript@5.8.3))(ts-node@10.9.2(@types/node@20.5.1)(typescript@5.8.3))(typescript@5.8.3) + cosmiconfig-typescript-loader: 4.4.0(@types/node@20.5.1)(cosmiconfig@8.3.6(typescript@4.6.3))(ts-node@10.9.2(@types/node@16.18.126)(typescript@4.6.3))(typescript@5.8.3) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -5556,7 +5546,7 @@ snapshots: core-util-is@1.0.3: {} - cosmiconfig-typescript-loader@4.4.0(@types/node@20.5.1)(cosmiconfig@8.3.6(typescript@5.8.3))(ts-node@10.9.2(@types/node@20.5.1)(typescript@5.8.3))(typescript@5.8.3): + cosmiconfig-typescript-loader@4.4.0(@types/node@20.5.1)(cosmiconfig@8.3.6(typescript@4.6.3))(ts-node@10.9.2(@types/node@16.18.126)(typescript@4.6.3))(typescript@5.8.3): dependencies: '@types/node': 20.5.1 cosmiconfig: 8.3.6(typescript@5.8.3) @@ -8186,9 +8176,7 @@ snapshots: '@vue/compiler-sfc': 3.5.16 vue: 3.5.16(typescript@4.6.3) - vue3-sketch-ruler@1.3.16(vue@3.5.16(typescript@4.6.3)): - optionalDependencies: - vue: 3.5.16(typescript@4.6.3) + vue3-sketch-ruler@2.4.1: {} vue@3.5.16(typescript@4.6.3): dependencies: diff --git a/src/plugins/customComponents.ts b/src/plugins/customComponents.ts index 0fad1075f..35e7b5db5 100644 --- a/src/plugins/customComponents.ts +++ b/src/plugins/customComponents.ts @@ -1,7 +1,7 @@ import type { App } from 'vue' import { GoSkeleton } from '@/components/GoSkeleton' import { GoLoading } from '@/components/GoLoading' -import { SketchRule } from 'vue3-sketch-ruler' +import SketchRule from 'vue3-sketch-ruler' /** * 全局注册自定义组件 diff --git a/src/store/modules/chartLayoutStore/chartLayoutStore.d.ts b/src/store/modules/chartLayoutStore/chartLayoutStore.d.ts index b485dd595..f387799e8 100644 --- a/src/store/modules/chartLayoutStore/chartLayoutStore.d.ts +++ b/src/store/modules/chartLayoutStore/chartLayoutStore.d.ts @@ -31,6 +31,4 @@ export interface ChartLayoutType { [ChartLayoutStoreEnum.LAYER_TYPE]: LayerModeEnum // 当前正在加载的数量 [ChartLayoutStoreEnum.PERCENTAGE]: number - // 是否重置当前画布位置 - [ChartLayoutStoreEnum.RE_POSITION_CANVAS]: boolean } diff --git a/src/store/modules/chartLayoutStore/chartLayoutStore.ts b/src/store/modules/chartLayoutStore/chartLayoutStore.ts index 95a0cb704..74983becb 100644 --- a/src/store/modules/chartLayoutStore/chartLayoutStore.ts +++ b/src/store/modules/chartLayoutStore/chartLayoutStore.ts @@ -49,9 +49,6 @@ export const useChartLayoutStore = defineStore({ }, getPercentage(): number { return this.percentage - }, - getRePositionCanvas(): boolean { - return this.rePositionCanvas } }, actions: { @@ -65,8 +62,6 @@ export const useChartLayoutStore = defineStore({ }) // 存储本地 setLocalStorage(GO_CHART_LAYOUT_STORE, this.$state) - // 这里需要标记重置画布位置 - this.rePositionCanvas = true; // 重新计算拖拽区域缩放比例 if (computedScale) { setTimeout(() => { diff --git a/src/views/chart/ContentEdit/components/EditBottom/index.vue b/src/views/chart/ContentEdit/components/EditBottom/index.vue index 361b474a3..e541417d6 100644 --- a/src/views/chart/ContentEdit/components/EditBottom/index.vue +++ b/src/views/chart/ContentEdit/components/EditBottom/index.vue @@ -62,10 +62,15 @@ import { useDesignStore } from '@/store/modules/designStore/designStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d' import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore' -import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d' const { LockClosedOutlineIcon, LockOpenOutlineIcon } = icon.ionicons5 +const props = defineProps<{ + reset?: () => void + zoomIn?: () => void + zoomOut?: () => void +}>() + // 全局颜色 const designStore = useDesignStore() const themeColor = ref(designStore.getAppTheme) @@ -105,8 +110,7 @@ const filterValue = ref('') const selectHandle = (v: number) => { selectInstRef.value?.blur() if (v === 0) { - chartLayoutStore.setItemUnHandle(ChartLayoutStoreEnum.RE_POSITION_CANVAS, true) - chartEditStore.computedScale() + props.reset?.() return } chartEditStore.setScale(v / 100) diff --git a/src/views/chart/ContentEdit/components/EditRange/index.vue b/src/views/chart/ContentEdit/components/EditRange/index.vue index 81944bd6c..e80340551 100644 --- a/src/views/chart/ContentEdit/components/EditRange/index.vue +++ b/src/views/chart/ContentEdit/components/EditRange/index.vue @@ -1,5 +1,5 @@