diff --git a/.gitignore b/.gitignore index 2aff0c138..19a0b2f6a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ .temp .hound .fes +.fes* dist *.log node_modules diff --git a/docs/README.md b/docs/README.md index d8dd99e17..357892a13 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,7 +13,7 @@ features: - title: Fast details: Fes.js 内置路由、构建、插件管理,提供测试、布局、权限、国际化、状态管理、请求、数据字典、Svg等插件,可以满足大部分日常开发需求。 - title: Easy - details: 基于Vue.js 3.0,上手简单。贯彻 “约定优于配置” 思想,在设计插件上尽可能用约定替代配置,依然提供统一的插件配置入口,简单简洁又不失灵活。提供一致性的API入口,一致化的体验,学习起来更轻松。 + details: 基于Vue.js 3.0,上手非常简单。贯彻 “约定优于配置” 思想,在设计插件上尽可能用约定替代配置,依然提供统一的插件配置入口,简单简洁又不失灵活。提供一致性的API入口,一致化的体验,学习起来更轻松。 - title: Strong details: 仅仅需要关心页面内容,减少犯错的机会!提供单元测试、覆盖测试的能力保障项目质量。 - title: 可扩展 diff --git a/docs/reference/api/README.md b/docs/reference/api/README.md index 47c7b8adb..a33f65558 100644 --- a/docs/reference/api/README.md +++ b/docs/reference/api/README.md @@ -74,7 +74,6 @@ Fes.js 路由基于 [Vue Router 4.0](https://next.router.vuejs.org/introduction. 返回当前 `router` 实例。 ```js import { getRouter } from "@fesjs/fes"; - const router = getRouter(); router.push(); ``` diff --git a/docs/reference/plugin/dev/api.md b/docs/reference/plugin/dev/api.md index 702099312..9c70905bf 100644 --- a/docs/reference/plugin/dev/api.md +++ b/docs/reference/plugin/dev/api.md @@ -301,7 +301,7 @@ import { access, useAccess } from '@fesjs/fes'; ```js api.addCoreExports(() => [ { - specifiers: ['getRoutes', 'getRouter', 'getHistory', 'destroyRouter'], + specifiers: ['getRoutes'], source: absCoreFilePath } ]); diff --git a/docs/reference/plugin/plugins/qiankun.md b/docs/reference/plugin/plugins/qiankun.md index 61706c49a..06c98428c 100644 --- a/docs/reference/plugin/plugins/qiankun.md +++ b/docs/reference/plugin/plugins/qiankun.md @@ -269,3 +269,24 @@ export default { - 主应用使用 props 的模式传递数据(参考主应用装载子应用配置一节) - 子应用在生命周期钩子中获取 props 消费数据(参考子应用运行时配置一节) + + +### MicroApp +| 属性 | 说明 | 类型 | 默认值 | +| ---- | ----------- | ------------- | ---------- | +| name | 子应用名称,传入`qiankun.main.apps`配置中的`name` | String | - | +| settings | 子应用配置信息 | Object | {} | +| props | 传入子应用的参数 | Object | {} | +| lifeCycles | 子应用生命周期钩子 | Object | {} | +| cacheName | 子应用缓存名称,配置后根据`name`+`cacheName`缓存子应用实例 | Object | - | + + +### MicroAppWithMemoHistory +| 属性 | 说明 | 类型 | 默认值 | +| ---- | ----------- | ------------- | ---------- | +| name | 子应用名称,传入`qiankun.main.apps`配置中的`name` | String | - | +| settings | 子应用配置信息 | Object | {} | +| props | 传入子应用的参数 | Object | {} | +| lifeCycles | 子应用生命周期钩子 | Object | {} | +| cacheName | 子应用缓存名称,配置后根据`name`+`cacheName`缓存子应用实例 | Object | - | +| url | 子应用的路由地址 | String | - | \ No newline at end of file diff --git a/packages/fes-plugin-layout/package.json b/packages/fes-plugin-layout/package.json index 90e8797ea..607fda9b6 100644 --- a/packages/fes-plugin-layout/package.json +++ b/packages/fes-plugin-layout/package.json @@ -1,6 +1,6 @@ { "name": "@fesjs/plugin-layout", - "version": "5.0.0-beta.4", + "version": "5.0.0-beta.5", "description": "@fesjs/plugin-layout", "main": "lib/index.js", "files": [ diff --git a/packages/fes-plugin-layout/src/runtime/views/MultiTabProvider.vue b/packages/fes-plugin-layout/src/runtime/views/MultiTabProvider.vue index f2c514320..fe839520e 100644 --- a/packages/fes-plugin-layout/src/runtime/views/MultiTabProvider.vue +++ b/packages/fes-plugin-layout/src/runtime/views/MultiTabProvider.vue @@ -9,7 +9,7 @@ @close="handleCloseTab" @update:modelValue="switchPage" > - + - - + + @@ -59,11 +59,12 @@ export default { return { path: _route.path, route: _route, - name: _route.meta.name, + name: _route.meta.name ?? _route.name, title: computed(() => transTitle(title)), key: getKey(), }; }; + const keepAlivePages = ref([]); const route = useRoute(); const router = useRouter(); @@ -71,11 +72,11 @@ export default { const actions = [ { value: 'closeOtherPage', - label: '关闭其他', + label: '关闭其他页签', }, { value: 'reloadPage', - label: '刷新当前页', + label: '刷新当前页签', }, ]; @@ -88,22 +89,37 @@ export default { return true; }); // 还需要考虑参数 - const switchPage = (path) => { + const switchPage = async (path) => { const selectedPage = findPage(path); if (selectedPage) { - router.push({ + await router.push({ path, query: selectedPage.route.query, params: selectedPage.route.params, }); } }; - const handleCloseTab = (targetKey) => { + const handleCloseTab = async (targetKey) => { const selectedPage = findPage(targetKey); const list = [...pageList.value]; const index = list.indexOf(selectedPage); + if (route.path === selectedPage.path) { + if (list.length > 1) { + if (list.length - 1 === index) { + await switchPage(list[index - 1].path); + } else { + await switchPage(list[index + 1].path); + } + } + } list.splice(index, 1); pageList.value = list; + const _keepAlivePages = [...keepAlivePages.value]; + const keepIndex = _keepAlivePages.indexOf(selectedPage.name); + if (keepIndex !== -1) { + _keepAlivePages.splice(keepIndex, 1); + } + keepAlivePages.value = _keepAlivePages; }; const reloadPage = (path) => { const selectedPage = findPage(path || unref(route.path)); @@ -114,6 +130,7 @@ export default { const closeOtherPage = (path) => { const selectedPage = findPage(path || unref(route.path)); pageList.value = [selectedPage]; + keepAlivePages.value = [selectedPage.name]; }; const getPageKey = (_route) => { const selectedPage = findPage(_route.path); @@ -133,10 +150,10 @@ export default { default: } }; - const keepAlivePages = ref([]); - const getComponent = (Component, _route) => { - if (_route.meta['keep-alive']) { - const name = _route.meta?.name || _route.name; + + const getComponent = (Component, _route, isKeep = false) => { + if (isKeep || _route.meta['keep-alive']) { + const name = _route.meta?.name ?? _route.name; if (name) { // 修改组件的 name Component.type.name = name; diff --git a/packages/fes-plugin-qiankun/examples/micro/src/pages/micro/index.vue b/packages/fes-plugin-qiankun/examples/micro/src/pages/micro/index.vue index 06741c9b5..6fd529b82 100644 --- a/packages/fes-plugin-qiankun/examples/micro/src/pages/micro/index.vue +++ b/packages/fes-plugin-qiankun/examples/micro/src/pages/micro/index.vue @@ -1,5 +1,6 @@ { @@ -10,7 +11,9 @@ diff --git a/packages/fes-plugin-qiankun/examples/micro/src/pages/micro/test.vue b/packages/fes-plugin-qiankun/examples/micro/src/pages/micro/test.vue index 043eb514a..33504e200 100644 --- a/packages/fes-plugin-qiankun/examples/micro/src/pages/micro/test.vue +++ b/packages/fes-plugin-qiankun/examples/micro/src/pages/micro/test.vue @@ -1,5 +1,6 @@ { @@ -10,7 +11,9 @@ diff --git a/packages/fes-plugin-qiankun/examples/vite-main/src/pages/index.vue b/packages/fes-plugin-qiankun/examples/vite-main/src/pages/index.vue index d7c6f5812..60251284d 100644 --- a/packages/fes-plugin-qiankun/examples/vite-main/src/pages/index.vue +++ b/packages/fes-plugin-qiankun/examples/vite-main/src/pages/index.vue @@ -1,6 +1,7 @@