From b6e058f3d535c6d16ead43020cc0ae6bc4ec414f Mon Sep 17 00:00:00 2001 From: Zhou xiao Date: Fri, 22 Mar 2024 11:12:31 +0800 Subject: [PATCH] feat: add global insulation variable (#664) * feat: add global insulation variable * chore: add merge logic --- packages/core/src/config.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/core/src/config.ts b/packages/core/src/config.ts index 231f95315..23d49105d 100644 --- a/packages/core/src/config.ts +++ b/packages/core/src/config.ts @@ -72,17 +72,28 @@ export const getAppConfig = ( return mergeResult; }; +function getGlobalInsulationVariable() { + return window['__GARFISH_INSULATION_VARIABLE__'] || []; +} + export const generateAppOptions = ( appName: string, garfish: interfaces.Garfish, options?: Partial>, ): AppInfo => { let appInfo: AppInfo = garfish.appInfos[appName] || { name: appName }; + const insulationVariable = Array.from( + new Set([ + ...getGlobalInsulationVariable(), + ...(appInfo?.insulationVariable || []), + ]), + ); // Merge register appInfo config and loadApp config appInfo = getAppConfig(garfish.options, { ...appInfo, ...options, + insulationVariable, props: { ...(appInfo.props || {}), ...(options?.props || {}),