perf: 优化切换图表导致画布缩放的交互

This commit is contained in:
奔跑的面条 2023-04-23 21:14:28 +08:00
parent a400526108
commit 9ce042cc8a
2 changed files with 175 additions and 169 deletions

View File

@ -55,7 +55,11 @@ export const useChartLayoutStore = defineStore({
}
},
actions: {
setItem<T extends keyof ChartLayoutType, K extends ChartLayoutType[T]>(key: T, value: K): void {
setItem<T extends keyof ChartLayoutType, K extends ChartLayoutType[T]>(
key: T,
value: K,
computedScale = true
): void {
this.$patch(state => {
state[key] = value
})
@ -64,9 +68,11 @@ export const useChartLayoutStore = defineStore({
// 这里需要标记重置画布位置
this.rePositionCanvas = true;
// 重新计算拖拽区域缩放比例
if (computedScale) {
setTimeout(() => {
chartEditStore.computedScale()
}, 500)
}
},
setItemUnHandle<T extends keyof ChartLayoutType, K extends ChartLayoutType[T]>(key: T, value: K): void {
this.$patch(state => {

View File

@ -74,9 +74,9 @@ const clickItemHandle = (key: string, item: any) => {
selectOptions.value = item
// 处理折叠
if (beforeSelect === key) {
setItem(ChartLayoutStoreEnum.CHARTS, !getCharts.value)
setItem(ChartLayoutStoreEnum.CHARTS, !getCharts.value, false)
} else {
setItem(ChartLayoutStoreEnum.CHARTS, true)
setItem(ChartLayoutStoreEnum.CHARTS, true, false)
}
beforeSelect = key
}