index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. import axios from 'axios'
  4. Vue.use(VueRouter)
  5. export const routes = [
  6. {
  7. path: '/',
  8. name: '首页',
  9. component: () => import('@/layouts/BaseLayout'),
  10. redirect: '/domain',
  11. children: [
  12. /*{
  13. path: 'dashboard',
  14. //component: () => import('@/views/dashboard/DashBoard'),
  15. name: '仪表盘',
  16. meta: {
  17. //hiddenHeaderContent: true,
  18. icon: 'home'
  19. }
  20. },*/
  21. {
  22. path: 'domain',
  23. name: '网站管理',
  24. component: () => import('@/layouts/BaseRouterView'),
  25. meta: {
  26. icon: 'cloud'
  27. },
  28. redirect: '/domain/list',
  29. children: [{
  30. path: 'list',
  31. name: '网站列表',
  32. component: () => import('@/views/Domain.vue'),
  33. }, {
  34. path: 'add',
  35. name: '添加站点',
  36. component: () => import('@/views/DomainEdit.vue'),
  37. }, {
  38. path: ':name',
  39. name: '编辑站点',
  40. component: () => import('@/views/DomainEdit.vue'),
  41. meta: {
  42. hiddenInSidebar: true
  43. }
  44. }, ]
  45. },
  46. {
  47. path: 'config',
  48. name: '配置管理',
  49. component: () => import('@/views/Config.vue'),
  50. meta: {
  51. icon: 'file'
  52. },
  53. },
  54. {
  55. path: 'config/:name',
  56. name: '配置编辑',
  57. component: () => import('@/views/ConfigEdit.vue'),
  58. meta: {
  59. hiddenInSidebar: true
  60. },
  61. },
  62. {
  63. path: 'about',
  64. name: '关于',
  65. component: () => import('@/views/About.vue'),
  66. meta: {
  67. icon: 'info-circle'
  68. }
  69. },
  70. ]
  71. },
  72. {
  73. path: '/404',
  74. name: '404 Not Found',
  75. component: () => import('@/views/Error'),
  76. meta: {noAuth: true, status_code: 404, error: 'Not Found'}
  77. },
  78. {
  79. path: '*',
  80. name: '未找到页面',
  81. redirect: '/404',
  82. meta: {noAuth: true}
  83. }
  84. ]
  85. const router = new VueRouter({
  86. routes
  87. })
  88. router.beforeEach((to, from, next) => {
  89. document.title = 'Nginx UI | ' + to.name
  90. if (process.env.NODE_ENV === 'production') {
  91. axios.get('/version.json?' + Date.now()).then(r => {
  92. if (!(process.env.VUE_APP_VERSION === r.data.version
  93. && Number(process.env.VUE_APP_BUILD_ID) === r.data.build_id)) {
  94. Vue.prototype.$info({
  95. title: '系统信息',
  96. content: '检测到版本更新,将会自动刷新本页',
  97. onOk() {
  98. location.reload()
  99. },
  100. okText: '好的'
  101. })
  102. }
  103. })
  104. }
  105. next()
  106. })
  107. export {router}