Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugins): custom loading component for qiankun #11498

Merged
merged 8 commits into from
Aug 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/plugins/src/qiankun/master.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export function isMasterEnable(opts: { userConfig: any }) {
return !!process.env.INITIAL_QIANKUN_MASTER_OPTIONS;
}

export function getQiankunLoading(api: IApi) {
return api.userConfig.qiankun?.master?.loading;
}

export default (api: IApi) => {
api.describe({
key: 'qiankun-master',
Expand Down Expand Up @@ -113,10 +117,13 @@ export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts

api.writeTmpFile({
path: 'MicroAppLoader.tsx',
// 开启了 antd 插件的时候,使用 antd 的 loader 组件,否则提示用户必须设置一个自定义的 loader 组件
content: api.isPluginEnable('antd')
content: getQiankunLoading(api)
fz6m marked this conversation as resolved.
Show resolved Hide resolved
? // 用户自定义的 loading 优先级最高
`export { default } from '${getQiankunLoading(api)}';`
PeachScript marked this conversation as resolved.
Show resolved Hide resolved
: api.isPluginEnable('antd')
? getFileContent('AntdLoader.tsx')
: `export default function Loader() { console.warn(\`[plugins/qiankun]: Seems like you'r not using @umijs/plugin-antd, you need to provide a custom loader or set autoSetLoading false to shut down this warning!\`); return null; }`,
: // 开启了 antd 插件的时候,使用 antd 的 loader 组件,否则提示用户必须设置一个自定义的 loader 组件
`export default function Loader() { console.warn(\`[plugins/qiankun]: Seems like you'r not using @umijs/plugin-antd, you need to provide a custom loader or set autoSetLoading false to shut down this warning!\`); return null; }`,
});

[
Expand Down
Loading