mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
fix: 解决组件移动未加入历史栈
This commit is contained in:
@@ -7,7 +7,7 @@ import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
import { loadingStart, loadingFinish, loadingError } from '@/utils'
|
||||
import throttle from 'lodash/throttle'
|
||||
import { throttle, cloneDeep } from 'lodash'
|
||||
|
||||
const chartEditStore = useChartEditStore()
|
||||
const { onClickOutSide } = useContextMenu()
|
||||
@@ -222,6 +222,16 @@ export const useMouseHandle = () => {
|
||||
const startX = e.screenX
|
||||
const startY = e.screenY
|
||||
|
||||
// 记录历史位置
|
||||
let prevComponentInstance:CreateComponentType | CreateComponentGroupType
|
||||
chartEditStore.getTargetChart.selectId.forEach(id => {
|
||||
if (!targetMap.has(id)) return
|
||||
|
||||
const index = chartEditStore.fetchTargetIndex(id)
|
||||
// 拿到初始位置数据
|
||||
prevComponentInstance = cloneDeep(chartEditStore.getComponentList[index])
|
||||
})
|
||||
|
||||
// 记录初始位置
|
||||
chartEditStore.setMousePosition(undefined, undefined, startX, startY)
|
||||
|
||||
@@ -267,6 +277,10 @@ export const useMouseHandle = () => {
|
||||
const mouseup = () => {
|
||||
chartEditStore.setMousePosition(0, 0, 0, 0)
|
||||
chartEditStore.setEditCanvas(EditCanvasTypeEnum.IS_DRAG, false)
|
||||
// 加入历史栈
|
||||
if(prevComponentInstance){
|
||||
chartEditStore.moveComponentList(prevComponentInstance)
|
||||
}
|
||||
document.removeEventListener('mousemove', mousemove)
|
||||
document.removeEventListener('mouseup', mouseup)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user