From 4f1dc1acd77f8632536eaefb90e697b67cd4d5d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Sat, 19 Nov 2022 20:37:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E5=88=86=E5=88=97=E6=B2=A1=E5=8F=8D=E5=BA=94?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chartLayoutStore/chartLayoutStore.ts | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/store/modules/chartLayoutStore/chartLayoutStore.ts b/src/store/modules/chartLayoutStore/chartLayoutStore.ts index b3f0919f..c50bd520 100644 --- a/src/store/modules/chartLayoutStore/chartLayoutStore.ts +++ b/src/store/modules/chartLayoutStore/chartLayoutStore.ts @@ -8,24 +8,25 @@ const chartEditStore = useChartEditStore() const { GO_CHART_LAYOUT_STORE } = StorageEnum -const storageChartLayout: ChartLayoutType = getLocalStorage(GO_CHART_LAYOUT_STORE) +const storageChartLayout: Partial = getLocalStorage(GO_CHART_LAYOUT_STORE) // 编辑区域布局和静态设置 export const useChartLayoutStore = defineStore({ id: 'useChartLayoutStore', - state: (): ChartLayoutType => - storageChartLayout || { - // 图层控制 - layers: true, - // 图表组件 - charts: true, - // 详情设置(收缩为true) - details: false, - // 组件列表展示类型(默认单列) - chartType: ChartModeEnum.SINGLE, - // 图层类型(默认图片) - layerType: LayerModeEnum.THUMBNAIL - }, + state: (): ChartLayoutType => ({ + // 图层控制 + layers: true, + // 图表组件 + charts: true, + // 详情设置(收缩为true) + details: false, + // 组件列表展示类型(默认单列) + chartType: ChartModeEnum.SINGLE, + // 图层类型(默认图片) + layerType: LayerModeEnum.THUMBNAIL, + // 防止值不存在 + ...storageChartLayout + }), getters: { getLayers(): boolean { return this.layers @@ -46,8 +47,8 @@ export const useChartLayoutStore = defineStore({ actions: { setItem(key: T, value: K): void { this.$patch(state => { - state[key]= value - }); + state[key] = value + }) setLocalStorage(GO_CHART_LAYOUT_STORE, this.$state) // 重新计算拖拽区域缩放比例 setTimeout(() => {