From 1028ea0302e2b6719d397bef980f20bf5a99afea Mon Sep 17 00:00:00 2001 From: MTrun <1262327911@qq.com> Date: Fri, 4 Mar 2022 20:57:36 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=20=E6=96=B0=E5=A2=9E=E5=AF=B9?= =?UTF-8?q?=E9=BD=90=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chartEditStore/chartEditStore.d.ts | 17 +- .../modules/chartEditStore/chartEditStore.ts | 20 +- .../chartLayoutStore/chartLayoutStore.ts | 4 +- src/views/chart/ContentBox/index.vue | 4 +- .../components/ChartThemeColor/index.vue | 8 +- .../components/CanvasPage/index.vue | 22 +- .../components/ChartSetting/index.vue | 8 +- .../chart/ContentConfigurations/index.vue | 10 +- .../components/EditAlignLine/index.ts | 3 + .../components/EditAlignLine/index.vue | 321 ++++++++++++++++++ .../components/EditBottom/index.vue | 13 +- .../components/EditRange/index.vue | 13 +- .../components/EditShapeBox/index.vue | 7 +- .../chart/ContentEdit/hooks/useDrag.hook.ts | 53 ++- .../chart/ContentEdit/hooks/useLayout.hook.ts | 4 +- .../chart/ContentEdit/hooks/useStore.hook.ts | 10 - .../chart/ContentEdit/hooks/useStyle.hook.ts | 10 +- src/views/chart/ContentEdit/index.vue | 4 +- .../components/ListItem/index.vue | 4 +- src/views/chart/ContentLayers/index.vue | 4 +- src/views/chart/hooks/useContextMenu.hook.ts | 4 +- src/views/chart/hooks/useKeyboard.hook.ts | 4 +- src/views/chart/index.vue | 4 +- 23 files changed, 452 insertions(+), 99 deletions(-) create mode 100644 src/views/chart/ContentEdit/components/EditAlignLine/index.ts create mode 100644 src/views/chart/ContentEdit/components/EditAlignLine/index.vue delete mode 100644 src/views/chart/ContentEdit/hooks/useStore.hook.ts diff --git a/src/store/modules/chartEditStore/chartEditStore.d.ts b/src/store/modules/chartEditStore/chartEditStore.d.ts index 4d8779f2..682deeaf 100644 --- a/src/store/modules/chartEditStore/chartEditStore.d.ts +++ b/src/store/modules/chartEditStore/chartEditStore.d.ts @@ -10,7 +10,8 @@ export enum EditCanvasTypeEnum { SCALE = 'scale', USER_SCALE = 'userScale', LOCK_SCALE = 'lockScale', - Is_Drag= 'isDrag', + IS_CREATE = 'isCreate', + IS_DRAG= 'isDrag', } // 编辑区域 @@ -26,8 +27,10 @@ export type EditCanvasType = { [EditCanvasTypeEnum.USER_SCALE]: number // 锁定缩放 [EditCanvasTypeEnum.LOCK_SCALE]: boolean + // 初始化创建 + [EditCanvasTypeEnum.IS_CREATE]: boolean // 拖拽中 - [EditCanvasTypeEnum.Is_Drag]: boolean + [EditCanvasTypeEnum.IS_DRAG]: boolean } // 滤镜 @@ -74,15 +77,21 @@ export interface EditCanvasConfigType { // 坐标轴信息 export enum EditCanvasTypeEnum { + START_X = 'startX', + START_Y = 'startY', X = 'x', Y = 'y' } // 鼠标位置 export type MousePositionType = { - // X 轴 + // 开始 X + [EditCanvasTypeEnum.START_X]: number + // 开始 Y + [EditCanvasTypeEnum.START_Y]: number + // X [EditCanvasTypeEnum.X]: number - // y 轴 + // y [EditCanvasTypeEnum.Y]: number } diff --git a/src/store/modules/chartEditStore/chartEditStore.ts b/src/store/modules/chartEditStore/chartEditStore.ts index 010b53fd..32a79987 100644 --- a/src/store/modules/chartEditStore/chartEditStore.ts +++ b/src/store/modules/chartEditStore/chartEditStore.ts @@ -19,8 +19,8 @@ import { const chartHistoryStoreStore = useChartHistoryStoreStore() // 编辑区域内容 -export const useChartEditStoreStore = defineStore({ - id: 'useChartEditStoreStore', +export const useChartEditStore = defineStore({ + id: 'useChartEditStore', state: (): chartEditStoreType => ({ // 画布属性 editCanvas: { @@ -35,6 +35,8 @@ export const useChartEditStoreStore = defineStore({ userScale: 1, // 锁定缩放 lockScale: false, + // 初始化 + isCreate: false, // 拖拽中 isDrag: false }, @@ -42,6 +44,8 @@ export const useChartEditStoreStore = defineStore({ rightMenuShow: false, // 鼠标定位 mousePosition: { + startX: 0, + startY: 0, x: 0, y: 0 }, @@ -128,6 +132,13 @@ export const useChartEditStoreStore = defineStore({ setRecordChart(item: RecordChartType | undefined) { this.recordChart = cloneDeep(item) }, + // * 设置鼠标位置 + setMousePosition(x?: number, y?: number, startX?: number, startY?: number): void { + if (startX) this.mousePosition.startX = startX + if (startY) this.mousePosition.startY = startY + if (x) this.mousePosition.x = x + if (y) this.mousePosition.y = y + }, // * 找到目标 id 数据下标位置 fetchTargetIndex(): number { if(!this.getTargetChart.selectId) { @@ -451,11 +462,6 @@ export const useChartEditStoreStore = defineStore({ } }, // ---------------- - // * 设置鼠标位置 - setMousePosition(x: number, y: number): void { - this.mousePosition.x = x - this.mousePosition.y = y - }, // * 设置页面变换时候的 Class setPageSizeClass(): void { const dom = this.getEditCanvas.editContentDom diff --git a/src/store/modules/chartLayoutStore/chartLayoutStore.ts b/src/store/modules/chartLayoutStore/chartLayoutStore.ts index a3931f82..de32435f 100644 --- a/src/store/modules/chartLayoutStore/chartLayoutStore.ts +++ b/src/store/modules/chartLayoutStore/chartLayoutStore.ts @@ -2,9 +2,9 @@ import { defineStore } from 'pinia' import { ChartLayoutType } from './chartLayoutStore.d' import { setLocalStorage, getLocalStorage } from '@/utils' import { StorageEnum } from '@/enums/storageEnum' -import { useChartEditStoreStore } from '@/store/modules/chartEditStore/chartEditStore' +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' -const chartEditStore = useChartEditStoreStore() +const chartEditStore = useChartEditStore() const { GO_CHART_LAYOUT_STORE } = StorageEnum diff --git a/src/views/chart/ContentBox/index.vue b/src/views/chart/ContentBox/index.vue index aab92681..685915a0 100644 --- a/src/views/chart/ContentBox/index.vue +++ b/src/views/chart/ContentBox/index.vue @@ -47,11 +47,11 @@ diff --git a/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue b/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue index 32355265..3be9f875 100644 --- a/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue +++ b/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue @@ -7,7 +7,7 @@ size="small" v-model:value="canvasConfig.width" :validator="validator" - @update:value="chartEditStoreStore.computedScale" + @update:value="chartEditStore.computedScale" /> @@ -15,7 +15,7 @@ size="small" v-model:value="canvasConfig.height" :validator="validator" - @update:value="chartEditStoreStore.computedScale" + @update:value="chartEditStore.computedScale" /> @@ -110,7 +110,7 @@ diff --git a/src/views/chart/ContentConfigurations/index.vue b/src/views/chart/ContentConfigurations/index.vue index e35233ef..d9eefc6f 100644 --- a/src/views/chart/ContentConfigurations/index.vue +++ b/src/views/chart/ContentConfigurations/index.vue @@ -82,11 +82,11 @@ import { loadAsyncComponent } from '@/utils' import { ContentBox } from '../ContentBox/index' import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore' import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d' -import { useChartEditStoreStore } from '@/store/modules/chartEditStore/chartEditStore' +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' const { getDetails } = toRefs(useChartLayoutStore()) const { setItem } = useChartLayoutStore() -const chartEditStoreStore = useChartEditStoreStore() +const chartEditStore = useChartEditStore() const { ConstructIcon, FlashIcon, DesktopOutlineIcon, RocketIcon } = icon.ionicons5 @@ -117,10 +117,10 @@ const expandHindle = () => { } const selectTarget = computed(() => { - const selectId = chartEditStoreStore.getTargetChart.selectId + const selectId = chartEditStore.getTargetChart.selectId if (!selectId) return undefined - return chartEditStoreStore.componentList[ - chartEditStoreStore.fetchTargetIndex() + return chartEditStore.componentList[ + chartEditStore.fetchTargetIndex() ] }) diff --git a/src/views/chart/ContentEdit/components/EditAlignLine/index.ts b/src/views/chart/ContentEdit/components/EditAlignLine/index.ts new file mode 100644 index 00000000..d07271c8 --- /dev/null +++ b/src/views/chart/ContentEdit/components/EditAlignLine/index.ts @@ -0,0 +1,3 @@ +import EditAlignLine from './index.vue' + +export { EditAlignLine } diff --git a/src/views/chart/ContentEdit/components/EditAlignLine/index.vue b/src/views/chart/ContentEdit/components/EditAlignLine/index.vue new file mode 100644 index 00000000..0bfad9f0 --- /dev/null +++ b/src/views/chart/ContentEdit/components/EditAlignLine/index.vue @@ -0,0 +1,321 @@ + + + + + diff --git a/src/views/chart/ContentEdit/components/EditBottom/index.vue b/src/views/chart/ContentEdit/components/EditBottom/index.vue index 29a6b210..41e7d353 100644 --- a/src/views/chart/ContentEdit/components/EditBottom/index.vue +++ b/src/views/chart/ContentEdit/components/EditBottom/index.vue @@ -62,19 +62,18 @@ import { reactive, ref, toRefs, watchEffect } from 'vue' import { icon } from '@/plugins' import { EditHistory } from '../EditHistory/index' import { useDesignStore } from '@/store/modules/designStore/designStore' +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' +import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d' + const { LockClosedOutlineIcon, LockOpenOutlineIcon } = icon.ionicons5 const { DicomOverlayIcon } = icon.carbon -import { - getChartEditStore, - getChartEditStoreEnum -} from '../../hooks/useStore.hook' + // 全局颜色 const designStore = useDesignStore() const themeColor = ref(designStore.getAppTheme) -const chartEditStore = getChartEditStore() -const ChartEditStoreEnum = getChartEditStoreEnum() +const chartEditStore = useChartEditStore() const { lockScale, scale } = toRefs(chartEditStore.getEditCanvas) // 缩放选项 @@ -115,7 +114,7 @@ const selectHandle = (v: number) => { // 点击锁处理 const lockHandle = () => { - chartEditStore.setEditCanvas(ChartEditStoreEnum.LOCK_SCALE, !lockScale.value) + chartEditStore.setEditCanvas(EditCanvasTypeEnum.LOCK_SCALE, !lockScale.value) } // 拖动 diff --git a/src/views/chart/ContentEdit/components/EditRange/index.vue b/src/views/chart/ContentEdit/components/EditRange/index.vue index 5d5c2bcd..2813119f 100644 --- a/src/views/chart/ContentEdit/components/EditRange/index.vue +++ b/src/views/chart/ContentEdit/components/EditRange/index.vue @@ -6,18 +6,22 @@ > + + +