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'
|
|
|
|
import { GO_Chart_Layout_Store } from '@/settings/storageConst'
|
|
|
|
|
|
|
|
const storageChartLayout: ChartLayoutType = getLocalStorage(
|
|
|
|
GO_Chart_Layout_Store
|
|
|
|
)
|
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,
|
|
|
|
// 不透明度
|
|
|
|
unOpacity: 100
|
|
|
|
}
|
|
|
|
},
|
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-07 22:02:13 +08:00
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
setItem(key: string, value: boolean): void {
|
|
|
|
;(this as any)[key] = value
|
|
|
|
setLocalStorage(GO_Chart_Layout_Store, this.$state)
|
|
|
|
},
|
|
|
|
setFilter<T extends keyof ChartLayoutType>(key: T, value: boolean): void {
|
|
|
|
;(this.filter as any)[key] = value
|
|
|
|
setLocalStorage(GO_Chart_Layout_Store, this.$state)
|
|
|
|
}
|
2022-01-05 21:05:55 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
export function useChartLayoutSettingWithOut() {
|
|
|
|
return useChartLayoutStore(store)
|
2022-01-07 22:02:13 +08:00
|
|
|
}
|