This commit is contained in:
sjl
2025-03-07 10:17:06 +08:00
parent 2377916f29
commit 7dcff99de5
10 changed files with 804 additions and 6 deletions

View File

@@ -30,6 +30,7 @@ const routerMode = {
* @param meta.isKeepAlive ==> 当前路由是否缓存
* */
const router = createRouter({
history: routerMode[mode](),
routes: [...staticRouter],
// 不区分路由大小写,非严格模式下提供了更宽松的路径匹配
@@ -68,10 +69,9 @@ router.beforeEach(async (to, from, next) => {
await initDynamicRouter()
return next({ ...to, replace: true })
}
//console.log(to)
// 7.存储 routerName 做按钮权限筛选
authStore.setRouteName(to.name as string)
// 8.正常访问页面
next()
})

View File

@@ -41,6 +41,7 @@ export const initDynamicRouter = async () => {
if (item.component && typeof item.component == "string") {
item.component = modules["/src/views" + item.component + ".vue"];
}
if (item.meta.isFull) {
router.addRoute(item as unknown as RouteRecordRaw);
} else {