2022-01-05 21:05:55 +08:00
|
|
|
import { defineStore } from 'pinia'
|
|
|
|
import { store } from '@/store'
|
2022-01-07 22:02:13 +08:00
|
|
|
import { ChartLayoutType, ChartLayoutFilterType } from './chartLayoutStore.d'
|
|
|
|
import { setLocalStorage, getLocalStorage } from '@/utils'
|
2022-01-08 14:27:56 +08:00
|
|
|
import { StorageEnum } from '@/enums/storageEnum'
|
|
|
|
|
|
|
|
const { GO_CHART_LAYOUT_STORE } = StorageEnum
|
2022-01-07 22:02:13 +08:00
|
|
|
|
|
|
|
const storageChartLayout: ChartLayoutType = getLocalStorage(
|
2022-01-08 14:27:56 +08:00
|
|
|
GO_CHART_LAYOUT_STORE
|
2022-01-07 22:02:13 +08:00
|
|
|
)
|
2022-01-05 21:05:55 +08:00
|
|
|
|
|
|
|
export const useChartLayoutStore = defineStore({
|
|
|
|
id: 'useChartLayoutStore',
|
2022-01-07 22:02:13 +08:00
|
|
|
state: (): ChartLayoutType =>
|
|
|
|
storageChartLayout || {
|
|
|
|
// 图层控制
|
|
|
|
layers: true,
|
|
|
|
// 图表组件
|
|
|
|
charts: true,
|
|
|
|
// 详情设置
|
|
|
|
details: true,
|
|
|
|
// 对齐线
|
|
|
|
alignLine: true,
|
|
|
|
// 滤镜
|
|
|
|
filter: {
|
|
|
|
// 色相
|
|
|
|
hueRotate: 0,
|
|
|
|
// 饱和度
|
|
|
|
saturate: 0,
|
|
|
|
// 亮度
|
|
|
|
brightness: 100,
|
|
|
|
// 对比度
|
|
|
|
contrast: 100,
|
|
|
|
// 不透明度
|
2022-01-15 14:56:48 +08:00
|
|
|
unOpacity: 100,
|
|
|
|
},
|
2022-01-07 22:02:13 +08:00
|
|
|
},
|
2022-01-05 21:05:55 +08:00
|
|
|
getters: {
|
2022-01-07 22:02:13 +08:00
|
|
|
getLayers(): boolean {
|
2022-01-05 21:05:55 +08:00
|
|
|
return this.layers
|
|
|
|
},
|
|
|
|
getCharts(): boolean {
|
|
|
|
return this.charts
|
|
|
|
},
|
|
|
|
getDetails(): boolean {
|
|
|
|
return this.details
|
|
|
|
},
|
|
|
|
getAlignLine(): boolean {
|
|
|
|
return this.alignLine
|
|
|
|
},
|
2022-01-07 22:02:13 +08:00
|
|
|
getFilter(): ChartLayoutFilterType {
|
2022-01-05 21:05:55 +08:00
|
|
|
return this.filter
|
2022-01-15 14:56:48 +08:00
|
|
|
},
|
2022-01-07 22:02:13 +08:00
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
setItem(key: string, value: boolean): void {
|
|
|
|
;(this as any)[key] = value
|
2022-01-08 14:27:56 +08:00
|
|
|
setLocalStorage(GO_CHART_LAYOUT_STORE, this.$state)
|
2022-01-07 22:02:13 +08:00
|
|
|
},
|
|
|
|
setFilter<T extends keyof ChartLayoutType>(key: T, value: boolean): void {
|
|
|
|
;(this.filter as any)[key] = value
|
2022-01-08 14:27:56 +08:00
|
|
|
setLocalStorage(GO_CHART_LAYOUT_STORE, this.$state)
|
2022-01-15 14:56:48 +08:00
|
|
|
},
|
|
|
|
},
|
2022-01-05 21:05:55 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
export function useChartLayoutSettingWithOut() {
|
|
|
|
return useChartLayoutStore(store)
|
2022-01-07 22:02:13 +08:00
|
|
|
}
|