refactor: 重构重置路由功能

This commit is contained in:
xiaoxian521
2022-08-18 18:34:53 +08:00
parent 5ac646444f
commit d6a329a63c
5 changed files with 40 additions and 16 deletions

View File

@@ -98,6 +98,19 @@ export const router: Router = createRouter({
}
});
// 重置路由
export function resetRouter() {
router.getRoutes().forEach(route => {
const { name, meta } = route;
if (name && router.hasRoute(name) && meta?.backstage) {
router.removeRoute(name);
router.options.routes = formatTwoStageRoutes(
formatFlatteningRoutes(buildHierarchyTree(ascending(routes)))
);
}
});
}
// 路由白名单
const whiteList = ["/login"];