mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-17 10:35:11 +08:00
fix(editor): 修复优化性能引起的问题,支持回退撤销对代码关系的更新
This commit is contained in:
parent
8102aaeb12
commit
010918198a
@ -87,7 +87,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup name="MEditorCodeBlockList">
|
<script lang="ts" setup name="MEditorCodeBlockList">
|
||||||
import { computed, inject, onMounted, reactive, ref, watch } from 'vue';
|
import { computed, inject, reactive, ref, watch } from 'vue';
|
||||||
import { Close, Edit, Link, View } from '@element-plus/icons-vue';
|
import { Close, Edit, Link, View } from '@element-plus/icons-vue';
|
||||||
import { cloneDeep, forIn, isEmpty } from 'lodash-es';
|
import { cloneDeep, forIn, isEmpty } from 'lodash-es';
|
||||||
|
|
||||||
@ -152,10 +152,13 @@ const refreshCodeList = async () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
watch(
|
||||||
|
() => services?.editorService.get('root'),
|
||||||
|
() => {
|
||||||
services?.codeBlockService.refreshAllRelations();
|
services?.codeBlockService.refreshAllRelations();
|
||||||
refreshCodeList();
|
refreshCodeList();
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => services?.codeBlockService.getCodeDslSync(), () => services?.codeBlockService.getCombineInfo()],
|
[() => services?.codeBlockService.getCodeDslSync(), () => services?.codeBlockService.getCombineInfo()],
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
import { reactive } from 'vue';
|
import { reactive } from 'vue';
|
||||||
import { cloneDeep, forIn, isEmpty, keys, omit, pick, union } from 'lodash-es';
|
import { cloneDeep, forIn, isEmpty, keys, omit, pick, union } from 'lodash-es';
|
||||||
|
|
||||||
import { CodeBlockContent, CodeBlockDSL, HookType, Id, MNode } from '@tmagic/schema';
|
import { CodeBlockContent, CodeBlockDSL, HookType, Id, MNode, MPage } from '@tmagic/schema';
|
||||||
|
|
||||||
import editorService from '../services/editor';
|
import editorService from '../services/editor';
|
||||||
import type { CodeRelation, CodeState, HookData } from '../type';
|
import type { CodeRelation, CodeState, HookData } from '../type';
|
||||||
@ -251,6 +251,12 @@ class CodeBlock extends BaseService {
|
|||||||
this.state.relations = this.deleteNodeRelation(node, this.state.relations);
|
this.state.relations = this.deleteNodeRelation(node, this.state.relations);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// 监听历史记录,历史快照为页面整体,需要深层遍历更新
|
||||||
|
editorService.on('history-change', (page: MPage) => {
|
||||||
|
const relations: CodeRelation = {};
|
||||||
|
this.getNodeRelation(page, relations, true);
|
||||||
|
this.state.relations = relations;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -886,6 +886,7 @@ class Editor extends BaseService {
|
|||||||
await this.select(value.nodeId);
|
await this.select(value.nodeId);
|
||||||
this.get('stage')?.select(value.nodeId);
|
this.get('stage')?.select(value.nodeId);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
this.emit('history-change', value.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async toggleFixedPosition(dist: MNode, src: MNode, root: MApp) {
|
private async toggleFixedPosition(dist: MNode, src: MNode, root: MApp) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user