mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-09-08 22:57:11 +08:00
refactor: 优化重置路由实现
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { type RouteRecordRaw, createRouter, createWebHashHistory } from 'vue-router'
|
||||
import { useRouteStore } from '@/stores'
|
||||
|
||||
/** 默认布局 */
|
||||
const Layout = () => import('@/layout/index.vue')
|
||||
@@ -79,10 +80,10 @@ const router = createRouter({
|
||||
*/
|
||||
export function resetRouter() {
|
||||
try {
|
||||
router.getRoutes().forEach((route) => {
|
||||
const routeStore = useRouteStore()
|
||||
routeStore.asyncRoutes.forEach((route) => {
|
||||
const { name } = route
|
||||
// console.log('name', name, path)
|
||||
if (name && !['Home', 'Setting', 'SettingProfile'].includes(name.toString())) {
|
||||
if (name) {
|
||||
router.hasRoute(name) && router.removeRoute(name)
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user