index.ts 601 B

123456789101112131415161718192021
  1. import { createRouter, createWebHashHistory } from 'vue-router'
  2. import { routes } from './config'
  3. import { computed } from 'vue'
  4. import { routesMetas } from './constant'
  5. import type { RoutesName } from './constant'
  6. export const history = createWebHashHistory()
  7. export const router = createRouter({ history, routes })
  8. export const currentMeta = computed(() => {
  9. const currentName = router.currentRoute.value.name as RoutesName
  10. if (currentName && currentName in routesMetas) {
  11. return routesMetas[currentName]
  12. }
  13. })
  14. export * from './config'
  15. export * from './constant'
  16. export default router