From 534fcac409ce85c1afde9f3a75681eed56607c20 Mon Sep 17 00:00:00 2001 From: xiaohuoni Date: Mon, 17 Apr 2023 14:31:06 +0800 Subject: [PATCH] feat: cache antd runtime config --- .../plugins/templates/antd/runtime.ts.tpl | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/plugins/templates/antd/runtime.ts.tpl b/packages/plugins/templates/antd/runtime.ts.tpl index e3315cfce50f..21d20a6db4f6 100644 --- a/packages/plugins/templates/antd/runtime.ts.tpl +++ b/packages/plugins/templates/antd/runtime.ts.tpl @@ -13,21 +13,29 @@ import { import { ApplyPluginsType } from 'umi'; import { getPluginManager } from '../core/plugin'; -export function rootContainer(rawContainer) { - const finalConfigProvider = getPluginManager().applyPlugins({ - key: 'antd', - type: ApplyPluginsType.modify, - initialValue: { -{{#configProvider}} - ...{{{configProvider}}}, -{{/configProvider}} - }, - }); - - let container = rawContainer; - +let cacheAntdConfig = null; +const getAntdConfig = () => { + if(!cacheAntdConfig){ + cacheAntdConfig = getPluginManager().applyPlugins({ + key: 'antd', + type: ApplyPluginsType.modify, + initialValue: { + {{#configProvider}} + ...{{{configProvider}}}, + {{/configProvider}} + {{#appConfig}} + appConfig: {{{appConfig}}}, + {{/appConfig}} + }, + }); + } + return cacheAntdConfig; +} +export function rootContainer(rawContainer) { + const finalConfigProvider = getAntdConfig(); + let container = rawContainer; {{#configProvider}} if (finalConfigProvider.prefixCls) { Modal.config({ @@ -59,15 +67,7 @@ export function rootContainer(rawContainer) { export function innerProvider(container: any) { const { appConfig: finalAppConfig = {}, - } = getPluginManager().applyPlugins({ - key: 'antd', - type: ApplyPluginsType.modify, - initialValue: { -{{#appConfig}} - appConfig: {{{appConfig}}}, -{{/appConfig}} - }, - }); + } = getAntdConfig(); return {container}; } {{/appConfig}} \ No newline at end of file