feat: 运营平台基建 搭建

This commit is contained in:
2026-07-23 15:00:19 +08:00
parent 3b5a908ee4
commit 5523695518
11 changed files with 1096 additions and 130 deletions
+11 -6
View File
@@ -13,17 +13,22 @@ const router = createRouter({
const WHITE_LIST = ['/login', '/404'];
/**
* 重置路由:清除动态添加的子路由,恢复到只包含静态路由的状态
* 用于退出登录时清理
* 静态路由名称集合(这些路由不会被 resetRouter 移除)
*/
const STATIC_ROUTE_NAMES = new Set(['Login', 'NotFound']);
/**
* 重置路由:清除动态添加的路由(包括 BasicLayout 和其子路由),
* 恢复到只包含静态路由的状态。用于退出登录时清理。
*/
export function resetRouter() {
const currentRoutes = router.getRoutes();
const protectedNames = new Set(['Login', 'BasicLayout', 'NotFound']);
currentRoutes.forEach((route) => {
// 保留静态路由(Login, BasicLayout, NotFound),移除动态添加的子路由
if (!protectedNames.has(route.name as string)) {
router.removeRoute(route.name!);
const routeName = route.name as string;
// 保留静态路由(Login, NotFound),移除所有动态路由(含 BasicLayout 及其子路由)
if (routeName && !STATIC_ROUTE_NAMES.has(routeName)) {
router.removeRoute(routeName);
}
});
}