wireguard-dashboard-admin/src/router/index.js

26 lines
663 B
JavaScript
Raw Normal View History

2022-01-08 17:20:46 +08:00
import { createRouter, createWebHistory } from 'vue-router'
import { setupRouterGuard } from './guard'
import { basicRoutes } from './routes'
export const router = createRouter({
history: createWebHistory('/'),
routes: basicRoutes,
scrollBehavior: () => ({ left: 0, top: 0 }),
})
export function resetRouter() {
router.getRoutes().forEach((route) => {
const { name } = route
2022-02-17 19:02:05 +08:00
router.hasRoute(name) && router.removeRoute(name)
})
basicRoutes.forEach((route) => {
!router.hasRoute(route.name) && router.addRoute(route)
2022-01-08 17:20:46 +08:00
})
}
2022-03-28 18:31:32 +08:00
export async function setupRouter(app) {
2022-01-08 17:20:46 +08:00
app.use(router)
setupRouterGuard(router)
2022-03-28 18:31:32 +08:00
await router.isReady()
2022-01-08 17:20:46 +08:00
}