kun-galgame-vue/src/router/index.ts

21 lines
592 B
TypeScript
Raw Normal View History

import { createWebHistory, createRouter } from 'vue-router'
import { KUNRouteType } from './types'
import { noCertRoutes, WHITE_LIST } from './router'
import { asyncRoutes } from './router'
2023-04-20 08:04:08 +00:00
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [...noCertRoutes, ...asyncRoutes] as KUNRouteType[],
2023-05-02 18:20:22 +00:00
})
2023-04-20 08:04:08 +00:00
export function resetRouter() {
router.getRoutes().forEach((route) => {
const { name } = route
if (name && !WHITE_LIST.includes(name as string)) {
router.hasRoute(name) && router.removeRoute(name)
}
})
2023-04-20 08:04:08 +00:00
}
2023-05-02 18:20:22 +00:00
export default router