mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 03:02:19 +08:00
fix: fork model
This commit is contained in:
parent
4d0ebc10a4
commit
aa4ea33698
@ -38,6 +38,9 @@
|
||||
/** fork 在 master.forks 中的索引 */
|
||||
public readonly forkId: number;
|
||||
|
||||
/** 用于共享上下文的对象,存储跨 fork 的共享数据 */
|
||||
private _sharedContext: Record<string, any> = {};
|
||||
|
||||
constructor(master: TMaster, initialProps: IModelComponentProps = {}, forkId = 0) {
|
||||
this.master = master;
|
||||
this.uid = master.uid;
|
||||
@ -117,6 +120,20 @@
|
||||
});
|
||||
}
|
||||
|
||||
public setSharedContext(ctx: Record<string, any>) {
|
||||
this._sharedContext = ctx;
|
||||
}
|
||||
|
||||
public getSharedContext() {
|
||||
if (this.async || !this.parent) {
|
||||
return this._sharedContext;
|
||||
}
|
||||
return {
|
||||
...this.parent?.getSharedContext(),
|
||||
...this._sharedContext, // 当前实例的 context 优先级最高
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象及其原型链上的属性描述符
|
||||
*/
|
||||
@ -194,4 +211,5 @@
|
||||
}
|
||||
|
||||
// 类型断言:让 ForkFlowModel 可以被当作 FlowModel 使用
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface ForkFlowModel<TMaster extends FlowModel = FlowModel> extends FlowModel {}
|
Loading…
x
Reference in New Issue
Block a user