mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-12 17:08:14 +00:00
refactor: 增加 settings 销毁的鲁棒性
This commit is contained in:
parent
f84ec7e72e
commit
1825da1949
@ -1,6 +1,7 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { Node, Designer, Selection, SettingTopEntry } from '@ali/lowcode-designer';
|
||||
import { Editor, obx, computed } from '@ali/lowcode-editor-core';
|
||||
import { executePendingFn } from '@ali/lowcode-utils';
|
||||
|
||||
function generateSessionId(nodes: Node[]) {
|
||||
return nodes
|
||||
@ -69,7 +70,11 @@ export class SettingsMain {
|
||||
this.designer = nodes[0].document.designer;
|
||||
}
|
||||
|
||||
this._settings?.purge();
|
||||
let lastSettings = this._settings;
|
||||
// obx 的一些响应式计算会延迟到下一个时钟周期,导致 prop.parent 获取不到,这里也做一个延迟
|
||||
executePendingFn(() => {
|
||||
lastSettings?.purge();
|
||||
}, 2000);
|
||||
this._settings = this.designer.createSettingEntry(nodes);
|
||||
}
|
||||
|
||||
|
||||
@ -61,3 +61,13 @@ export function waitForThing(obj: any, path: string): Promise<any> {
|
||||
export function isFromVC(meta: ComponentMeta) {
|
||||
return !!meta?.getMetadata()?.experimental;
|
||||
}
|
||||
|
||||
export function arrShallowEquals(arr1: any[], arr2: any[]): boolean {
|
||||
if (!Array.isArray(arr1) || !Array.isArray(arr2)) return false;
|
||||
if (arr1.length !== arr2.length) return false;
|
||||
return arr1.every(item => arr2.includes(item));
|
||||
}
|
||||
|
||||
export function executePendingFn(fn: () => void, timeout: number = 2000) {
|
||||
return setTimeout(fn, timeout);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user