Skip to content

Commit 2871b5b

Browse files
authored
feat: sync utils/constants (alibaba#506)
1 parent 8255b79 commit 2871b5b

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

packages/designer/src/builtin-simulator/host.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
190190
this.componentsConsumer = new ResourceConsumer<Asset | undefined>(() => this.componentsAsset);
191191
this.injectionConsumer = new ResourceConsumer(() => {
192192
return {
193+
appHelper: engineConfig.get('appHelper'),
193194
i18n: this.project.i18n,
194195
};
195196
});

packages/editor-core/src/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ export interface EngineOptions {
208208
// 是否开启在 render 阶段开启 filter reducer,默认值:false
209209
enableFilterReducerInRenderStage?: boolean;
210210
};
211+
/**
212+
* 与 react-renderer 的 appHelper 一致, https://lowcode-engine.cn/docV2/nhilce#appHelper
213+
*/
214+
appHelper?: {
215+
/** 全局公共函数 */
216+
utils?: Record<string, any>;
217+
/** 全局常量 */
218+
constants?: Record<string, any>;
219+
};
211220

212221
requestHandlersMap: RequestHandlersMap;
213222
}

packages/react-simulator-renderer/src/renderer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { createMemoryHistory, MemoryHistory } from 'history';
2525
import Slot from './builtin-components/slot';
2626
import Leaf from './builtin-components/leaf';
2727
import { withQueryParams, parseQuery } from './utils/url';
28+
import { merge } from 'lodash';
2829

2930
const loader = new AssetLoader();
3031
configure({ enforceActions: 'never' });
@@ -308,6 +309,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
308309
...this._appContext,
309310
};
310311
newCtx.utils.i18n.messages = data.i18n || {};
312+
merge(newCtx, data.appHelper || {});
311313
this._appContext = newCtx;
312314
});
313315
}

0 commit comments

Comments
 (0)