From 29f3cafb741f57f67900052d524e479304969fce Mon Sep 17 00:00:00 2001 From: harrywan <445436867@qq.com> Date: Thu, 28 Jul 2022 11:37:19 +0800 Subject: [PATCH 1/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 808f8be6..404d4910 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Fes.js 是一个好用的前端应用解决方案。提供覆盖编译构建到 - 📦 __可扩展__ ,借鉴Umi实现了完整的生命周期和插件化机制,插件可以管理项目的编译时和运行时,能力均可以通过插件封装进来,在 Fes.js 中协调有序的运行。 -- 📡 __面向未来__ ,在满足需求的同时,我们也不会停止对新技术的探索。已使用Vue3.0来提升应用性能,已使用webpack5提升构建性能和实现微服务,未来会探索vite等新技术。 +- 📡 __面向未来__ ,在满足需求的同时,我们也不会停止对新技术的探索。已使用Vue3.0来提升应用性能,已使用webpack5提升构建性能和实现微服务,在3.0版本中支持 vite 快速构建。 ## 插件 From c64bd4844d3bde1d69da45fdaefc348ba0fbb5a0 Mon Sep 17 00:00:00 2001 From: wanchun <445436867@qq.com> Date: Mon, 1 Aug 2022 14:33:31 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix(plugin-qiankun):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=BB=E5=BA=94=E7=94=A8=E7=8A=B6=E6=80=81=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=E5=90=8E=E4=BD=BF=E7=94=A8useModel=E6=B2=A1=E6=9C=89=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/runtime/MicroApp.tpl | 34 ++++++++++++++----- .../src/micro/runtime/qiankunModel.tpl | 5 +-- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/packages/fes-plugin-qiankun/src/main/runtime/MicroApp.tpl b/packages/fes-plugin-qiankun/src/main/runtime/MicroApp.tpl index 4e524891..e85882e8 100644 --- a/packages/fes-plugin-qiankun/src/main/runtime/MicroApp.tpl +++ b/packages/fes-plugin-qiankun/src/main/runtime/MicroApp.tpl @@ -6,9 +6,10 @@ import { computed, onBeforeUnmount, onMounted, + shallowRef, } from "vue"; import { loadMicroApp } from "{{{QIANKUN}}}"; -import {mergeWith} from "{{{LODASH_ES}}}"; +import { mergeWith, cloneDeep, isEqual } from "{{{LODASH_ES}}}"; // eslint-disable-next-line import/extensions import { getMasterOptions } from "./masterOptions"; @@ -66,12 +67,27 @@ export const MicroApp = defineComponent({ }); - const propsConfigRef = computed(() => { - return { - ...propsFromConfigRef.value, - ...props.props, - }; - }); + const propsConfigRef = shallowRef({}); + + watch( + [() => props.props, () => attrs, propsFromConfigRef], + () => { + // 使用深拷贝去掉主应用数据和子应用数据的引用关系,避免出现副作用。 + const newProps = cloneDeep({ + ...propsFromConfigRef.value, + ...props.props, + ...attrs + }); + // 避免第一次无意义update + if(!isEqual(newProps, propsConfigRef.value)) { + propsConfigRef.value = newProps + } + }, + { + deep: true, + immediate: true + } + ); // 只有当name变化时才重新加载新的子应用 const loadApp = () => { @@ -84,7 +100,7 @@ export const MicroApp = defineComponent({ name: `${name}_${props.cacheName || ''}`, entry: entry, container: containerRef.value, - props: {...propsConfigRef.value, ...attrs} + props: propsConfigRef.value }, { ...globalSettings, @@ -138,7 +154,7 @@ export const MicroApp = defineComponent({ } // 返回 microApp.update 形成链式调用 - return microApp.update({...propsConfigRef.value, ...attrs}); + return microApp.update(propsConfigRef.value); } } ); diff --git a/packages/fes-plugin-qiankun/src/micro/runtime/qiankunModel.tpl b/packages/fes-plugin-qiankun/src/micro/runtime/qiankunModel.tpl index 93bf2383..c1223729 100644 --- a/packages/fes-plugin-qiankun/src/micro/runtime/qiankunModel.tpl +++ b/packages/fes-plugin-qiankun/src/micro/runtime/qiankunModel.tpl @@ -1,8 +1,9 @@ import { reactive } from 'vue'; - +import { cloneDeep } from 'lodash-es' let initState = reactive({}); const setModelState = (props) => { - Object.assign(initState, props) + // 使用深拷贝去掉主应用数据和子应用数据的引用关系,避免出现副作用。 + Object.assign(initState, cloneDeep(props)) }; export default () => initState; From e28760e9271e73a4695c01ad661508a86e43e7df Mon Sep 17 00:00:00 2001 From: wanchun <445436867@qq.com> Date: Mon, 1 Aug 2022 14:34:07 +0800 Subject: [PATCH 3/3] chore(release): publish - @fesjs/plugin-qiankun@2.1.3 --- packages/fes-plugin-qiankun/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fes-plugin-qiankun/package.json b/packages/fes-plugin-qiankun/package.json index 64da97ef..933d92bd 100644 --- a/packages/fes-plugin-qiankun/package.json +++ b/packages/fes-plugin-qiankun/package.json @@ -1,6 +1,6 @@ { "name": "@fesjs/plugin-qiankun", - "version": "2.1.2", + "version": "2.1.3", "description": "@fesjs/plugin-qiankun", "main": "lib/index.js", "files": [