From 2ac27379535c0a79320fe37ccd1133eede1e7625 Mon Sep 17 00:00:00 2001 From: icssoa <615206459@qq.com> Date: Tue, 27 Sep 2022 12:39:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cool/config/index.ts | 2 + src/cool/router/index.ts | 17 ++++++++ src/modules/base/layout/components/bmenu.tsx | 43 ++++++-------------- src/modules/base/layout/components/views.vue | 4 +- src/modules/base/pages/login/index.vue | 5 +++ src/modules/base/store/user.ts | 1 + 6 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/cool/config/index.ts b/src/cool/config/index.ts index 71f5531..e5d885d 100644 --- a/src/cool/config/index.ts +++ b/src/cool/config/index.ts @@ -22,6 +22,8 @@ export const config = { router: { // 模式 mode: "history", + // 转场动画 + transition: "slide", // 首页组件 home: () => import("/$/demo/views/home/index.vue") }, diff --git a/src/cool/router/index.ts b/src/cool/router/index.ts index a1c6151..1ae4b2d 100644 --- a/src/cool/router/index.ts +++ b/src/cool/router/index.ts @@ -44,6 +44,10 @@ router.append = function (data) { d.name = d.path.substring(1); } + if (!d.meta) { + d.meta = {}; + } + if (!d.component) { const url = d.viewPath; @@ -62,6 +66,8 @@ router.append = function (data) { } } + d.meta.dynamic = true; + if (d.isPage) { router.addRoute(d); } else { @@ -70,6 +76,17 @@ router.append = function (data) { }); }; +// 清空路由 +router.clear = function () { + const rs = router.getRoutes(); + + rs.forEach((e) => { + if (e.name) { + router.removeRoute(e.name); + } + }); +}; + // 找路由 router.find = function (path: string) { return router.getRoutes().find((e) => e.path == path); diff --git a/src/modules/base/layout/components/bmenu.tsx b/src/modules/base/layout/components/bmenu.tsx index f6379b7..c78e943 100644 --- a/src/modules/base/layout/components/bmenu.tsx +++ b/src/modules/base/layout/components/bmenu.tsx @@ -1,4 +1,4 @@ -import { h, ref, watch } from "vue"; +import { h } from "vue"; import { useStore } from "../../store"; import { Menu } from "../../types"; import { useCool } from "/@/cool"; @@ -10,9 +10,6 @@ export default { const { router, route } = useCool(); const { menu, app } = useStore(); - // 是否可见 - const visible = ref(true); - // 页面跳转 function toView(url: string) { if (url != route.path) { @@ -25,23 +22,9 @@ export default { } } - // 刷新菜单 - function refresh() { - visible.value = false; - - setTimeout(() => { - visible.value = true; - }, 0); - } - - // 监听菜单变化 - watch(menu.list, refresh); - return { route, - visible, toView, - refresh, menu }; }, @@ -105,19 +88,17 @@ export default { const children = deep(ctx.menu.list, 1); return ( - ctx.visible && ( -
- ) + ); } }; diff --git a/src/modules/base/layout/components/views.vue b/src/modules/base/layout/components/views.vue index 66252fb..065e4ea 100644 --- a/src/modules/base/layout/components/views.vue +++ b/src/modules/base/layout/components/views.vue @@ -2,7 +2,7 @@