From 4614c147aff06a78e0fc0c8b4bd0f2a46a03e06e Mon Sep 17 00:00:00 2001 From: wanchun <445436867@qq.com> Date: Mon, 9 May 2022 14:07:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20plugin-qiankun=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=BB=E5=BA=94=E7=94=A8=E6=9B=B4=E6=96=B0props=E4=B8=8D?= =?UTF-8?q?=E8=A7=A6=E5=8F=91update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/runtime/MicroApp.tpl | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/packages/fes-plugin-qiankun/src/main/runtime/MicroApp.tpl b/packages/fes-plugin-qiankun/src/main/runtime/MicroApp.tpl index 5c1b4583..1140bdbe 100644 --- a/packages/fes-plugin-qiankun/src/main/runtime/MicroApp.tpl +++ b/packages/fes-plugin-qiankun/src/main/runtime/MicroApp.tpl @@ -64,13 +64,11 @@ export const MicroApp = defineComponent({ return {}; }); - const propsFromParams = attrs; - const propsConfigRef = computed(() => { return { ...propsFromConfigRef.value, ...props.props, - ...propsFromParams + ...attrs }; }); @@ -85,7 +83,7 @@ export const MicroApp = defineComponent({ name: `${name}_${Date.now()}`, entry: entry, container: containerRef.value, - props: propsConfigRef.value + props: {...propsConfigRef.value} }, { ...globalSettings, @@ -107,37 +105,36 @@ export const MicroApp = defineComponent({ if (!updatingPromiseRef.value) { // 初始化 updatingPromiseRef 为 microApp.mountPromise,从而确保后续更新是在应用 mount 完成之后 updatingPromiseRef.value = microApp.mountPromise; - } else { - // 确保 microApp.update 调用是跟组件状态变更顺序一致的,且后一个微应用更新必须等待前一个更新完成 - updatingPromiseRef.value = updatingPromiseRef.value.then( - () => { - const canUpdate = (app) => - app?.update && app.getStatus() === 'MOUNTED'; - if (canUpdate(microApp)) { - if (process.env.NODE_ENV === 'development') { - if ( - Date.now() - - updatingTimestampRef.value < - 200 - ) { - console.warn( - `[@fesjs/plugin-qiankun] It seems like microApp ${props.name} is updating too many times in a short time(200ms), you may need to do some optimization to avoid the unnecessary re-rendering.` - ); - } - - console.info( - `[@fesjs/plugin-qiankun] MicroApp ${props.name} is updating with props: `, - props + } + // 确保 microApp.update 调用是跟组件状态变更顺序一致的,且后一个微应用更新必须等待前一个更新完成 + updatingPromiseRef.value = updatingPromiseRef.value.then( + () => { + const canUpdate = (app) => + app?.update && app.getStatus() === 'MOUNTED'; + if (canUpdate(microApp)) { + if (process.env.NODE_ENV === 'development') { + if ( + Date.now() - + updatingTimestampRef.value < + 200 + ) { + console.warn( + `[@fesjs/plugin-qiankun] It seems like microApp ${props.name} is updating too many times in a short time(200ms), you may need to do some optimization to avoid the unnecessary re-rendering.` ); - updatingTimestampRef.value = Date.now(); } - // 返回 microApp.update 形成链式调用 - return microApp.update(propsConfigRef.value); + console.info( + `[@fesjs/plugin-qiankun] MicroApp ${props.name} is updating with props: `, + props + ); + updatingTimestampRef.value = Date.now(); } + + // 返回 microApp.update 形成链式调用 + return microApp.update({...propsConfigRef.value}); } - ); - } + } + ); } };