feature(性能):前进回退操作加入到常量中

This commit is contained in:
ligz 2024-12-30 15:41:56 +08:00
parent 44cd5aad96
commit 1e9a603eef
3 changed files with 3 additions and 2 deletions

View File

@ -2,6 +2,7 @@
export const CONSTANTS = {
CHANGE_THEME: 'changeTheme',
CHANGE_LAYOUT: 'changeLayout',
HISTORY_RECORD:'historyRecord',
SET_DATA: 'setData',
MODE: {
READONLY: 'readonly',

View File

@ -682,7 +682,7 @@ class Render {
if (data) {
this.renderTree = data
// 给前进后退增加类型 主要是当它这样操作时全量渲染 暂时未作两次数据得变更比对 这个是简单临时方案
this.mindMap.render(()=>{},"HISTORY_RECORD")
this.mindMap.render(()=>{},CONSTANTS.HISTORY_RECORD)
}
this.mindMap.emit('data_change', data)
}

View File

@ -55,7 +55,7 @@ class LogicalStructure extends Base {
(cur, parent, isRoot, layerIndex, index, ancestors) => {
let newNode = cur?._node
// 只有变动的节点 结构改变 和 执行撤销和前进的操作才进入创建节点的操作
if(!newNode || activeUiDList.includes(cur.data.uid) || this.checkIsNeedResizeSources() || this.renderer.renderSource === CONSTANTS.CHANGE_LAYOUT || this.renderer.renderSource === "HISTORY_RECORD"){
if(!newNode || activeUiDList.includes(cur.data.uid) || this.checkIsNeedResizeSources() || [CONSTANTS.CHANGE_LAYOUT,CONSTANTS.HISTORY_RECORD].includes(this.renderer.renderSource)){
newNode = this.createNode(cur, parent, isRoot, layerIndex, index, ancestors,this.renderer.renderSource !== "HISTORY_RECORD")
}
// 将缓存节点移至外边去缓存。保证每个节点缓存都是最新的