index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { createRouter, createWebHistory } from 'vue-router'
  2. import SystemConfig from '../views/SystemConfig.vue'
  3. const routes = [
  4. {
  5. path: '/',
  6. redirect: '/system-config'
  7. },
  8. {
  9. path: '/real-time-status',
  10. name: 'RealTimeStatus',
  11. component: () => import('../views/RealTimeStatus.vue'),
  12. meta: { title: '实时状态' }
  13. },
  14. {
  15. path: '/system-config',
  16. name: 'SystemConfig',
  17. component: SystemConfig,
  18. meta: { title: '系统配置' }
  19. },
  20. {
  21. path: '/network-config',
  22. name: 'NetworkConfig',
  23. component: () => import('../views/NetworkConfig.vue'),
  24. meta: { title: '网络配置' }
  25. },
  26. {
  27. path: '/led-debug',
  28. name: 'LedDebug',
  29. component: () => import('../views/LedDebug.vue'),
  30. meta: { title: 'LED调试' }
  31. },
  32. {
  33. path: '/about',
  34. name: 'About',
  35. component: () => import('../views/About.vue'),
  36. meta: { title: '关于' }
  37. }
  38. ]
  39. const router = createRouter({
  40. history: createWebHistory(),
  41. routes
  42. })
  43. // 路由守卫,设置页面标题
  44. router.beforeEach((to, from, next) => {
  45. if (to.meta.title) {
  46. document.title = `${to.meta.title} - 配线架配置`
  47. }
  48. next()
  49. })
  50. export default router