diff --git a/packages/fes-plugin-qiankun/examples/main/src/app.js b/packages/fes-plugin-qiankun/examples/main/src/app.js index 52361d60..a6deff63 100644 --- a/packages/fes-plugin-qiankun/examples/main/src/app.js +++ b/packages/fes-plugin-qiankun/examples/main/src/app.js @@ -1,5 +1,7 @@ import { access as accessApi } from '@fesjs/fes'; import PageLoading from '@/components/PageLoading'; +import Antdv from 'ant-design-vue'; +import 'ant-design-vue/dist/antd.css'; export const beforeRender = { loading: , @@ -13,3 +15,7 @@ export const beforeRender = { }); } }; + +export const onAppCreated = ({ app }) => { + app.use(Antdv); +}; diff --git a/packages/fes-plugin-qiankun/examples/main/src/pages/index.vue b/packages/fes-plugin-qiankun/examples/main/src/pages/index.vue index 6bbe5a4e..1ac39714 100644 --- a/packages/fes-plugin-qiankun/examples/main/src/pages/index.vue +++ b/packages/fes-plugin-qiankun/examples/main/src/pages/index.vue @@ -1,8 +1,12 @@ { @@ -24,6 +28,7 @@ export default { }, 3000); }); return { + activeKey: ref('1'), url }; } diff --git a/packages/fes-plugin-qiankun/src/micro/index.js b/packages/fes-plugin-qiankun/src/micro/index.js index 855385ee..c92e20d7 100644 --- a/packages/fes-plugin-qiankun/src/micro/index.js +++ b/packages/fes-plugin-qiankun/src/micro/index.js @@ -165,7 +165,7 @@ export default function (api) { api.addEntryCode( () => ` -export const bootstrap = qiankun_genBootstrap(completeClientRender, app); +export const bootstrap = qiankun_genBootstrap(clientRender, app); export const mount = qiankun_genMount('#${api.config.mountElementId}'); export const unmount = qiankun_genUnmount(); export const update = qiankun_genUpdate(); diff --git a/packages/fes-preset-built-in/src/plugins/generateFiles/fes/fes.tpl b/packages/fes-preset-built-in/src/plugins/generateFiles/fes/fes.tpl index a586b53a..a4d45f41 100644 --- a/packages/fes-preset-built-in/src/plugins/generateFiles/fes/fes.tpl +++ b/packages/fes-preset-built-in/src/plugins/generateFiles/fes/fes.tpl @@ -40,29 +40,7 @@ const renderClient = (opts = {}) => { return app; } -const getClientRender = (args = {}) => plugin.applyPlugins({ - key: 'render', - type: ApplyPluginsType.compose, - initialValue: () => { - const opts = plugin.applyPlugins({ - key: 'modifyClientRenderOpts', - type: ApplyPluginsType.modify, - initialValue: { - initialState: args.initialState, - routes: args.routes || getRoutes(), - plugin, - rootElement: '{{{ rootElement }}}', -{{#enableTitle}} - defaultTitle: `{{{ defaultTitle }}}`, -{{/enableTitle}} - }, - }); - return renderClient(opts); - }, - args, -}); - -const beforeRender = async () => { +const beforeRender = async ({rootElement}) => { const beforeRenderConfig = plugin.applyPlugins({ key: "beforeRender", type: ApplyPluginsType.modify, @@ -74,7 +52,7 @@ const beforeRender = async () => { let initialState = {}; if (typeof beforeRenderConfig.action === "function") { const app = createApp(beforeRenderConfig.loading); - app.mount('{{{ rootElement }}}'); + app.mount(rootElement); try { initialState = await beforeRenderConfig.action(); } catch(e){ @@ -86,14 +64,31 @@ const beforeRender = async () => { return initialState; }; -const completeClientRender = async () => { - const initialState = await beforeRender(); - const clientRender = getClientRender({initialState}); - const app = clientRender(); - return app; -}; +const getClientRender = (args = {}) => plugin.applyPlugins({ + key: 'render', + type: ApplyPluginsType.compose, + initialValue: async () => { + const opts = plugin.applyPlugins({ + key: 'modifyClientRenderOpts', + type: ApplyPluginsType.modify, + initialValue: { + routes: args.routes || getRoutes(), + plugin, + rootElement: '{{{ rootElement }}}', +{{#enableTitle}} + defaultTitle: `{{{ defaultTitle }}}`, +{{/enableTitle}} + }, + }); + const initialState = await beforeRender(opts); + return renderClient({...opts, initialState}); + }, + args, +}); -const app = completeClientRender(); +const clientRender = getClientRender(); + +const app = clientRender(); {{{ entryCode }}}