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 @@