refactor(仪表板、数据大屏): 优化画布编辑镜像记录,修复含有过滤组件的画布无法点恢复按钮问题 #13937

This commit is contained in:
wangjiahao 2024-12-13 13:03:50 +08:00 committed by 王嘉豪
parent 2b461f1abe
commit 590b995cde
43 changed files with 73 additions and 71 deletions

View File

@ -456,7 +456,7 @@ const saveLinkageSetting = () => {
}
const onDvNameChange = () => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onDvNameChange')
}
const appStore = useAppStoreWithOut()
const isEmbedded = computed(() => appStore.getIsDataEaseBi || appStore.getIsIframe)

View File

@ -237,7 +237,7 @@ const changeColorOption = (modifyName = 'value') => {
}
const changePagerColorChange = () => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('changePagerColorChange')
}
const changeColorCase = modifyName => {

View File

@ -19,7 +19,7 @@ const handleScaleChange = () => {
if (scaleChangeReady.value) {
scaleChangeReady.value = false
setTimeout(() => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('handleScaleChange')
// 0
scale.value = ~~scale.value || 10
scale.value = scale.value < 10 ? 10 : scale.value

View File

@ -256,7 +256,7 @@ const backHandler = (url: string) => {
const openHandler = ref(null)
const onDvNameChange = () => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onDvNameChange')
}
const getFullScale = () => {

View File

@ -159,7 +159,7 @@ const hideComponent = () => {
const showComponent = () => {
setTimeout(() => {
layerStore.showComponent()
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('showComponent')
})
}

View File

@ -246,7 +246,7 @@ const hideComponent = () => {
const showComponent = () => {
setTimeout(() => {
layerStore.showComponent()
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('showComponent')
})
}
@ -269,7 +269,7 @@ const dragOnEnd = ({ oldIndex, newIndex }) => {
componentData.value.splice(comLength - 1 - oldIndex, 1)
componentData.value.splice(comLength - 1 - newIndex, 0, target)
dvMainStore.setCurComponent({ component: target, index: transformIndex(comLength - oldIndex) })
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('dragOnEnd')
}
const iconMap = {
bar: bar,
@ -391,7 +391,7 @@ const areaClick = area => {
}
const canvasChange = () => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('canvasChange')
}
</script>

View File

@ -76,7 +76,7 @@ const dragOnEnd = ({ oldIndex, newIndex }) => {
const source = componentData.value[newIndex]
dvMainStore.setCurTabName(source.title)
eventBus.emit('onTabSortChange-' + tabElement.value?.id)
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('dragOnEnd')
}
const menuAsideClose = (param, index) => {

View File

@ -45,7 +45,7 @@ const lock = () => {
lockStore.lock(component)
})
}
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('lock')
menuOpt('lock')
}
@ -94,7 +94,7 @@ const hide = () => {
layerStore.hideComponentWithComponent(component.id)
})
}
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('hide')
menuOpt('hide')
}
@ -106,12 +106,12 @@ const show = () => {
layerStore.showComponent(component.id)
})
}
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('show')
menuOpt('show')
}
const categoryChange = type => {
if (curComponent.value) {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('categoryChange')
curComponent.value['category'] = type
if (type === 'hidden') {
dvMainStore.canvasStateChange({ key: 'curPointArea', value: 'hidden' })
@ -138,7 +138,7 @@ const deleteComponent = () => {
})
}
eventBus.emit('hideArea-canvas-main')
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('deleteComponent')
menuOpt('deleteComponent')
}

View File

@ -107,7 +107,7 @@ const onFontFamilyChange = () => {
snapshotStore.recordSnapshotCache('renderChart')
}
const onThemeChange = () => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onThemeChange')
}
withDefaults(

View File

@ -465,7 +465,7 @@ const exportAsImage = () => {
const deleteComponent = () => {
eventBus.emit('removeMatrixItem-' + canvasId.value, index.value)
dvMainStore.setCurComponent({ component: null, index: null })
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('deleteComponent')
}
const datasetParamsInit = () => {

View File

@ -51,7 +51,7 @@ const dvMainStore = dvMainStoreWithOut()
const onSubmit = () => {
state.linkInfo.content = checkAddHttp(state.linkInfo.content)
dvMainStore.curComponent.hyperlinks = deepCopy(state.linkInfo)
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('ds-onSubmit')
onClose()
}

View File

@ -108,7 +108,7 @@ const editComponentName = () => {
}
const onComponentNameChange = () => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onComponentNameChange')
}
</script>

View File

@ -51,7 +51,7 @@ const dvMainStore = dvMainStoreWithOut()
const onSubmit = () => {
state.linkInfo.content = checkAddHttp(state.linkInfo.content)
dvMainStore.curComponent.hyperlinks = deepCopy(state.linkInfo)
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('hyper-onSubmit')
onClose()
}

View File

@ -865,7 +865,7 @@ const save = () => {
state.loading = true
updateJumpSet(state.linkJump)
.then(() => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('updateJumpSet')
ElMessage.success('保存成功')
//
queryVisualizationJumpInfo(dvInfo.value.id).then(rsp => {

View File

@ -486,7 +486,7 @@ const saveLinkageSetting = () => {
saveLinkage(request)
.then(() => {
curComponent.value.actionSelection.linkageActive = customLinkageActive.value.linkageActive
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('saveLinkageSetting')
ElMessage.success('保存成功')
//
getPanelAllLinkageInfo(dvInfo.value.id).then(rsp => {

View File

@ -98,7 +98,7 @@ const onSubmit = () => {
} else {
curActiveTabInner.value.streamMediaLinks = state.streamMediaInfoTemp
}
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onSubmit')
eventBus.emit('streamMediaLinksChange-' + curComponent.value.id)
popoverClose()
}

View File

@ -56,7 +56,7 @@ const switchTimeChange = () => {
const onSubmit = () => {
curComponent.value.style.carouselEnable = state.carouselEnable
curComponent.value.style.switchTime = state.switchTime
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onSubmit')
onClose()
}

View File

@ -189,20 +189,20 @@ const onPositionChange = key => {
groupSizeStyleAdaptor(curComponent.value)
}
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onPositionChange')
}
const maintainRadioChange = () => {
curComponent.value.aspectRatio = curComponent.value.style.width / curComponent.value.style.height
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('maintainRadioChange')
}
const multiDimensionalChange = () => {
// do change
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('multiDimensionalChange')
}
const snapshotChange = () => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('snapshotChange')
}
const positionInit = () => {

View File

@ -87,7 +87,7 @@ const handlePictureCardPreview = file => {
}
const upload = file => {
uploadFileResult(file.file, fileUrl => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('deUpload')
imgUrlInner.value = fileUrl
emits('onImgChange', fileUrl)
})
@ -100,7 +100,7 @@ const reUpload = e => {
return
}
uploadFileResult(file, fileUrl => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('uploadFileResult')
imgUrlInner.value = fileUrl
emits('onImgChange', fileUrl)
})

View File

@ -210,7 +210,7 @@ const upload = file => {
}
const onBackgroundChange = () => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onBackgroundChange')
}
const bgForm = ref()

View File

@ -52,7 +52,7 @@ const styleInit = () => {
const styleForm = computed<any>(() => styleInfo.value)
const changeStyle = params => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('border-changeStyle')
emits('onStyleAttrChange', params)
}

View File

@ -561,7 +561,7 @@ const sizeChange = key => {
}
const changeStyle = params => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('changeStyle')
emits('onStyleAttrChange', params)
}

View File

@ -76,7 +76,7 @@ const init = () => {
const onBlur = () => {
state.linkInfoTemp.src = checkAddHttp(state.linkInfoTemp.src)
curComponent.value.frameLinks.src = state.linkInfoTemp.src
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('frame-onBlur')
useEmitt().emitter.emit('frameLinksChange-' + curComponent.value.id)
}
init()

View File

@ -106,7 +106,7 @@ const onChange = () => {
} else {
curActiveTabInner.value.streamMediaLinks = state.streamMediaInfoTemp
}
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('stream-onChange')
useEmitt().emitter.emit('streamMediaLinksChange-' + curComponent.value.id)
}
init()

View File

@ -266,7 +266,7 @@ const curPreviewGap = computed(() =>
function sureCurTitle() {
state.curItem.title = state.textarea
state.dialogVisible = false
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('sureCurTitle')
}
function addTab() {
@ -279,7 +279,7 @@ function addTab() {
}
element.value.propValue.push(newTab)
editableTabsValue.value = newTab.name
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('addTab')
}
function deleteCur(param) {
@ -321,11 +321,11 @@ function handleCommand(command) {
break
case 'deleteCur':
deleteCur(command.param)
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('deleteCur')
break
case 'copyCur':
copyCur(command.param)
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('copyCur')
break
}
}

View File

@ -59,7 +59,7 @@ const closeDialog = () => {
}
const save = () => {
config.value.propValue = deepCopy(sortList.value)
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('tab-sort-save')
eventBus.emit('onTabSortChange-' + config.value.id)
closeDialog()
}

View File

@ -93,13 +93,13 @@ const onChange = () => {
}
curComponent.value.videoLinks = state.linkInfoTemp
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('video-onChange')
useEmitt().emitter.emit('videoLinksChange-' + curComponent.value.id)
}
const onBlur = () => {
state.linkInfoTemp.src = checkAddHttp(state.linkInfoTemp.src)
curComponent.value.frameLinks.src = state.linkInfoTemp.src
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('video-onBlur')
useEmitt().emitter.emit('frameLinksChange-' + curComponent.value.id)
}
init()

View File

@ -59,12 +59,12 @@ const handleRemove = (file, fileListArray) => {
element.value.propValue['urlList'].splice(index, 1)
useEmitt().emitter.emit('calcData-' + element.value.id)
}
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('picture-handleRemove')
}
async function upload(file) {
if (element.value.propValue.urlList.length < 10) {
uploadFileResult(file.file, fileUrl => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('pic-upload')
element.value.propValue.urlList.unshift({ name: file.file.name, url: fileUrl })
useEmitt().emitter.emit('calcData-' + element.value.id)
})
@ -72,7 +72,7 @@ async function upload(file) {
}
const onStyleChange = () => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('pic-onStyleChange')
}
const goFile = () => {

View File

@ -42,17 +42,17 @@ const handleRemove = (_, fileList) => {
uploadDisabled.value = false
curComponent.value.propValue.url = null
fileList.value = []
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('handleRemove')
}
async function upload(file) {
uploadFileResult(file.file, fileUrl => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('pic-upload')
curComponent.value.propValue.url = fileUrl
})
}
const onStyleChange = () => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('pic-onStyleChange')
}
const goFile = () => {
@ -66,7 +66,7 @@ const reUpload = e => {
return
}
uploadFileResult(file, fileUrl => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('uploadFileResult')
curComponent.value.propValue.url = fileUrl
fileList.value = [{ url: imgUrlTrans(curComponent.value.propValue.url) }]
})

View File

@ -202,7 +202,7 @@ const setCustomStyle = val => {
customStyle.labelColorBtn = labelColorBtn || '#ffffff'
customStyle.labelShow = labelShow ?? true
customStyle.btnColor = btnColor || '#3370ff'
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('setCustomStyle')
}
watch(
@ -436,7 +436,7 @@ const drop = e => {
})
})
element.value.propValue = [...list.value]
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('drop')
}
const editeQueryConfig = (queryId: string) => {
@ -458,7 +458,7 @@ const addCriteriaConfigOut = () => {
const delQueryConfig = index => {
list.value.splice(index, 1)
element.value.propValue = [...list.value]
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('delQueryConfig')
}
const resetData = () => {

View File

@ -1506,7 +1506,7 @@ const confirmClick = () => {
queryElement.value.cascade = cloneDeep(cascadeArr)
cascadeArr = []
queryElement.value.propValue = cloneDeep(conditions.value)
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('confirmClick')
nextTick(() => {
emits('queryData')
})

View File

@ -134,7 +134,7 @@ export const copyStore = defineStore('copy', {
i++
}
}, moveTime)
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('paste')
},
cut(curComponentData = componentData.value) {
if (curComponent.value && curComponent.value.component !== 'GroupArea') {
@ -155,7 +155,7 @@ export const copyStore = defineStore('copy', {
components: []
})
}
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('cut')
this.isCut = true
},

View File

@ -36,6 +36,7 @@ let defaultCanvasInfo = {
export const snapshotStore = defineStore('snapshot', {
state: () => {
return {
snapshotDisableTime: 1, // 镜像禁用时间解决redo undo 造成的样式变更
styleChangeTimes: -1, // 组件样式修改次数
cacheStyleChangeTimes: 0, // 仪表板未缓存的组件样式修改次数
snapshotCacheTimes: 0, // 当前未计入镜像中的修改变动次数, 此为定时缓存缓存间隔时间5秒一次 针对类型样式这种变动不大的修改
@ -99,6 +100,7 @@ export const snapshotStore = defineStore('snapshot', {
// undo 是当前没有记录
this.snapshotPublish(componentSnapshot)
this.styleChangeTimes++
this.snapshotDisableTime = Date.now() + 3000
}
},
@ -109,7 +111,7 @@ export const snapshotStore = defineStore('snapshot', {
snapshotInfo.dvInfo.id = dvInfo.value.id
snapshotInfo.dvInfo.pid = dvInfo.value.pid
this.snapshotPublish(snapshotInfo)
this.styleChangeTimes++
this.snapshotDisableTime = Date.now() + 3000
}
},
snapshotPublish(snapshotInfo) {
@ -180,9 +182,9 @@ export const snapshotStore = defineStore('snapshot', {
this.recordSnapshot()
},
recordSnapshot() {
recordSnapshot(type) {
// 移动端设计时暂不保存镜像
if (dataPrepareState.value && !mobileInPc.value) {
if (dataPrepareState.value && !mobileInPc.value && Date.now() > this.snapshotDisableTime) {
this.styleChangeTimes = ++this.styleChangeTimes
const snapshotComponentData = deepCopy(componentData.value)
dvMainStore.removeGroupArea(snapshotComponentData)

View File

@ -205,12 +205,12 @@ const onBasicStyleChange = (val, prop) => {
}
const onBackgroundChange = (val, prop) => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onBackgroundChange')
state.initReady && emit('onBackgroundChange', val, prop)
}
const onActiveChange = val => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onActiveChange')
state.initReady &&
emit('onStyleAttrChange', {
custom: 'style',

View File

@ -113,7 +113,7 @@ const onLegendChange = (val, prop) => {
const onBackgroundChange = val => {
dvMainStore.setBatchChangeBackground(val)
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onBackgroundChange')
}
const onBasicStyleChange = (val, prop) => {
//

View File

@ -163,7 +163,7 @@ const goFile = () => {
}
const onBackgroundChange = () => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onBackgroundChange')
commonBackgroundPop.value.outerImage = state.commonBackground['outerImage']
}
onMounted(() => {
@ -196,7 +196,7 @@ const handleCurrentPlaceholderCustomChange = () => {
value: { type: 'renderChart', component: JSON.parse(JSON.stringify(chart.value)) }
})
} else {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('handleCurrentPlaceholderCustomChange')
}
}

View File

@ -40,7 +40,7 @@ const changeFilter = val => {
}
dfsTreeDelete(items)
emits('filter-data', { logic, items })
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('changeFilter')
dialogVisible.value = false
}

View File

@ -127,7 +127,7 @@ const calcEdit = ref()
const route = useRoute()
const onComponentNameChange = () => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onComponentNameChange')
}
const closeEditComponentName = () => {

View File

@ -903,7 +903,7 @@ const vClickOutside = {
}
function onTitleChange() {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('onTitleChange')
}
const toolTip = computed(() => {

View File

@ -93,7 +93,7 @@ const saveMultiplexing = () => {
const canvasViewInfoPreview = previewStateInfo.canvasViewInfoPreview
nextTick(() => {
copyStore.copyMultiplexingComponents(canvasViewInfoPreview)
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('saveMultiplexing')
})
}

View File

@ -211,7 +211,7 @@ const commitStyle = () => {
type: 'setCanvasStyle',
value: JSON.parse(JSON.stringify(unref(canvasStyleDataCopy)))
})
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('commitStyle')
}
onMounted(() => {

View File

@ -142,7 +142,7 @@ const doUseCache = flag => {
snapshotStore.snapshotPublish(canvasCacheSeries)
dataInitState.value = true
setTimeout(() => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('doUseCache')
// 使
snapshotStore.recordSnapshotCache('renderChart')
}, 1500)
@ -162,7 +162,7 @@ const initLocalCanvasData = () => {
dvInfo.value.optType = 'copy'
dvInfo.value.pid = sourcePid
setTimeout(() => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('initLocalCanvasData')
}, 1500)
}
onInitReady({ resourceId: resourceId })
@ -236,7 +236,7 @@ onMounted(async () => {
dvMainStore.setCanvasViewInfo(deTemplateData['canvasViewInfo'])
dvMainStore.setAppDataInfo(deTemplateData['appData'])
setTimeout(() => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('template')
}, 1500)
if (dvMainStore.getAppDataInfo()) {
eventBus.emit('save')

View File

@ -421,7 +421,7 @@ onMounted(async () => {
dvMainStore.setCanvasViewInfo(deTemplateData['canvasViewInfo'])
dvMainStore.setAppDataInfo(deTemplateData['appData'])
setTimeout(() => {
snapshotStore.recordSnapshotCache()
snapshotStore.recordSnapshotCache('template')
}, 1500)
}
if (dvMainStore.getAppDataInfo()) {