123456789101112131415161718192021222324252627282930313233 |
- import { createRouter, createWebHashHistory } from 'vue-router'
- import { useRouteStore } from '@/stores'
- import { constantRoutes, systemRoutes } from '@/router/route'
- import { setupRouterGuard } from '@/router/guard'
- const router = createRouter({
- history: createWebHashHistory(import.meta.env.BASE_URL),
- routes: [...constantRoutes, ...systemRoutes],
- scrollBehavior: () => ({ left: 0, top: 0 }),
- })
- setupRouterGuard(router)
- export function resetRouter() {
- try {
- const routeStore = useRouteStore()
- routeStore.asyncRoutes.forEach((route) => {
- const { name } = route
- if (name) {
- router.hasRoute(name) && router.removeRoute(name)
- }
- })
- } catch (error) {
-
- window.location.reload()
- }
- }
- export default router
|