mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-05 09:47:20 +00:00
Merge branch 'feat/autoRepaintNode' into release/1.0.16-beta
This commit is contained in:
commit
600b468ef2
@ -203,12 +203,9 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
};
|
||||
});
|
||||
transactionManager.onStartTransaction(() => {
|
||||
this.project.currentDocument?.history?.sleep();
|
||||
this.stopAutoRepaintNode();
|
||||
}, TransitionType.REPAINT);
|
||||
transactionManager.onEndTransaction(() => {
|
||||
this.project.currentDocument?.history?.wakeup();
|
||||
this.project.currentDocument?.history?.savePoint();
|
||||
this.rerender();
|
||||
this.enableAutoRepaintNode();
|
||||
}, TransitionType.REPAINT);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { autorun, reaction, mobx, untracked, globalContext, Editor } from '@alilc/lowcode-editor-core';
|
||||
import { reaction, untracked, globalContext, Editor } from '@alilc/lowcode-editor-core';
|
||||
import { NodeSchema } from '@alilc/lowcode-types';
|
||||
import { History as ShellHistory } from '@alilc/lowcode-shell';
|
||||
|
||||
@ -40,24 +40,22 @@ export class History<T = NodeSchema> {
|
||||
if (this.asleep) return null;
|
||||
return dataFn();
|
||||
}, (data: T) => {
|
||||
if (this.asleep) return;
|
||||
untracked(() => {
|
||||
const log = this.currentSerialization.serialize(data);
|
||||
if (this.session.isActive()) {
|
||||
this.session.log(log);
|
||||
} else {
|
||||
this.session.end();
|
||||
const lastState = this.getState();
|
||||
const cursor = this.session.cursor + 1;
|
||||
const session = new Session(cursor, log, this.timeGap);
|
||||
this.session = session;
|
||||
this.records.splice(cursor, this.records.length - cursor, session);
|
||||
const currentState = this.getState();
|
||||
if (currentState !== lastState) {
|
||||
this.emitter.emit('statechange', currentState);
|
||||
}
|
||||
if (this.session.isActive()) {
|
||||
this.session.log(log);
|
||||
} else {
|
||||
this.session.end();
|
||||
const lastState = this.getState();
|
||||
const cursor = this.session.cursor + 1;
|
||||
const session = new Session(cursor, log, this.timeGap);
|
||||
this.session = session;
|
||||
this.records.splice(cursor, this.records.length - cursor, session);
|
||||
const currentState = this.getState();
|
||||
if (currentState !== lastState) {
|
||||
this.emitter.emit('statechange', currentState);
|
||||
}
|
||||
// }
|
||||
}
|
||||
});
|
||||
}, { fireImmediately: true });
|
||||
}
|
||||
|
||||
@ -229,11 +229,11 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
||||
this.recordTime();
|
||||
}
|
||||
|
||||
get defaultState() {
|
||||
getDefaultState(nextProps: any) {
|
||||
const {
|
||||
hidden = false,
|
||||
condition = true,
|
||||
} = this.leaf?.export?.(TransformStage.Render) || {};
|
||||
} = nextProps.__inner__ || {};
|
||||
return {
|
||||
nodeChildren: null,
|
||||
childrenInState: false,
|
||||
@ -257,7 +257,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
||||
|
||||
let cacheState = cache.state.get(componentCacheId);
|
||||
if (!cacheState || cacheState.__tag !== props.__tag) {
|
||||
cacheState = this.defaultState;
|
||||
cacheState = this.getDefaultState(props);
|
||||
}
|
||||
|
||||
this.state = cacheState;
|
||||
@ -393,7 +393,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
||||
const {
|
||||
visible,
|
||||
...resetState
|
||||
} = this.defaultState;
|
||||
} = this.getDefaultState(nextProps);
|
||||
this.setState(resetState);
|
||||
}
|
||||
|
||||
@ -562,6 +562,8 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
||||
ref: forwardedRef,
|
||||
};
|
||||
|
||||
delete compProps.__inner__;
|
||||
|
||||
return engine.createElement(Comp, compProps, this.hasChildren ? this.children : null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -670,7 +670,14 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
return renderComp({ ...props, ...otherProps });
|
||||
return renderComp({
|
||||
...props,
|
||||
...otherProps,
|
||||
__inner__: {
|
||||
hidden: schema.hidden,
|
||||
condition,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
return engine.createElement(engine.getFaultComponent(), {
|
||||
error: e,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { TransitionType } from '@alilc/lowcode-types';
|
||||
import { transaction } from 'mobx';
|
||||
import EventEmitter from 'events';
|
||||
|
||||
class TransactionManager {
|
||||
@ -6,7 +7,7 @@ class TransactionManager {
|
||||
|
||||
startTransaction = (fn: () => void, type: TransitionType = TransitionType.REPAINT): void => {
|
||||
this.emitter.emit(`[${type}]startTransaction`);
|
||||
fn();
|
||||
transaction(fn);
|
||||
this.emitter.emit(`[${type}]endTransaction`);
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user