Skip to content

Commit

Permalink
feat: cache antd runtime config
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohuoni committed Apr 17, 2023
1 parent c3a781c commit 534fcac
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions packages/plugins/templates/antd/runtime.ts.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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 <App {...finalAppConfig}>{container}</App>;
}
{{/appConfig}}

0 comments on commit 534fcac

Please sign in to comment.