index.ts 764 B

1234567891011121314151617181920212223
  1. import type { App } from 'vue'
  2. import { createRouter, createWebHashHistory } from 'vue-router'
  3. import { staticRoutes } from './routes/staticRoutes'
  4. import { configureNProgress } from '@/utils/router'
  5. import { setupBeforeEachGuard } from './guards/beforeEach'
  6. import { setupAfterEachGuard } from './guards/afterEach'
  7. // 创建路由实例
  8. export const router = createRouter({
  9. history: createWebHashHistory(),
  10. routes: staticRoutes // 静态路由
  11. })
  12. // 初始化路由
  13. export function initRouter(app: App<Element>): void {
  14. configureNProgress() // 顶部进度条
  15. setupBeforeEachGuard(router) // 路由前置守卫
  16. setupAfterEachGuard(router) // 路由后置守卫
  17. app.use(router)
  18. }
  19. // 门户菜单启动器首页
  20. export const HOME_PAGE_PATH = '/home'