mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-28 21:20:28 +00:00
refactor: 增加增量更新机制的部分限制条件, 并将门槛调整到 200 节点
This commit is contained in:
parent
1297e3c0e5
commit
45cd088e60
@ -48,8 +48,8 @@ export class DocumentInstance {
|
||||
this.disposeFunctions.push(host.onActivityEvent((data: ActivityData, ctx: any) => {
|
||||
if (host.mutedActivityEvent || (ctx && ctx.doc !== this.document)) return;
|
||||
|
||||
// 当节点数小数 300 个时,不走入增量更新逻辑,后面优化、细化逻辑后逐步放开限制
|
||||
if (this.document.nodesMap.size < 300) return;
|
||||
// 当节点数小数 200 个时,不走入增量更新逻辑,后面优化、细化逻辑后逐步放开限制
|
||||
if (this.document.nodesMap.size < 200) return;
|
||||
|
||||
if (tid) clearTimeout(tid);
|
||||
// 临时关闭全量计算 schema 的逻辑,在增量计算结束后,来一次全量计算
|
||||
@ -59,7 +59,7 @@ export class DocumentInstance {
|
||||
if (supportsQuickPropSetting(data, this)) {
|
||||
setInstancesProp(data, this);
|
||||
} else {
|
||||
this._schema = applyActivities(this._schema!, data);
|
||||
// this._schema = applyActivities(this._schema!, data);
|
||||
}
|
||||
} else if (data.type === ActivityType.ADDED) {
|
||||
// FIXME: 待补充 节点增加 逻辑
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { ReactInstance } from 'react';
|
||||
import { ActivityData, isJSSlot } from '@ali/lowcode-types';
|
||||
import { DocumentInstance } from '../renderer';
|
||||
import { isReactClass } from '@ali/lowcode-utils';
|
||||
|
||||
interface UtilsMetadata {
|
||||
name: string;
|
||||
@ -55,9 +56,9 @@ function haveForceUpdate(instances: any[]): boolean {
|
||||
export function supportsQuickPropSetting(data: ActivityData, doc: DocumentInstance) {
|
||||
const { payload } = data;
|
||||
const { schema, prop } = payload;
|
||||
const nodeId = schema.id!;
|
||||
const { componentName, id: nodeId } = schema;
|
||||
// const key = data.payload.prop.key;
|
||||
const instances = doc.instancesMap.get(nodeId);
|
||||
const instances = doc.instancesMap.get(nodeId!);
|
||||
const propKey = getUppermostPropKey(prop);
|
||||
let value = (schema.props as any)[propKey];
|
||||
|
||||
@ -65,14 +66,28 @@ export function supportsQuickPropSetting(data: ActivityData, doc: DocumentInstan
|
||||
nodeId &&
|
||||
Array.isArray(instances) &&
|
||||
instances.length > 0 &&
|
||||
haveForceUpdate(instances) &&
|
||||
propKey &&
|
||||
// 不是 extraProp
|
||||
!propKey.startsWith('___') &&
|
||||
!isJSSlot(value)
|
||||
!isJSSlot(value) &&
|
||||
// functional component 不支持 ref.props 直接设值,是 readonly 的
|
||||
isReactClass((doc.container?.components as any)[componentName]) &&
|
||||
haveForceUpdate(instances) &&
|
||||
// 黑名单组件通常会把 schema / children 魔改,导致直接设置 props 失效
|
||||
isAllowedComponent(componentName)
|
||||
);
|
||||
}
|
||||
|
||||
// 不允许走快捷设置的组件黑名单
|
||||
const DISABLED__QUICK_SETTING_COMPONENT_NAMES = [
|
||||
'Filter', // 查询组件
|
||||
'Filter2', // 查询组件
|
||||
'TableField', // 明细组件
|
||||
];
|
||||
function isAllowedComponent(name: string): boolean {
|
||||
return !DISABLED__QUICK_SETTING_COMPONENT_NAMES.includes(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置属性值
|
||||
* @param data
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user