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(() => {