index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. import { createWebHistory, createRouter } from 'vue-router'
  2. /* Layout */
  3. import Layout from '@/layout'
  4. // 公共路由
  5. export const constantRoutes = [
  6. {
  7. path: '/redirect',
  8. component: Layout,
  9. hidden: true,
  10. children: [
  11. {
  12. path: '/redirect/:path(.*)',
  13. component: () => import('@/views/redirect/index.vue')
  14. }
  15. ]
  16. },
  17. {
  18. path: '/login',
  19. component: () => import('@/views/login'),
  20. hidden: true
  21. },
  22. {
  23. path: '/register',
  24. component: () => import('@/views/register'),
  25. hidden: true
  26. },
  27. {
  28. path: '/401',
  29. component: () => import('@/views/error/401'),
  30. hidden: true
  31. },
  32. {
  33. path: '/index',
  34. component: Layout,
  35. children: [
  36. {
  37. path: '',
  38. component: () => import('@/views/index'),
  39. name: 'Index',
  40. meta: { title: '首页', icon: 'dashboard', affix: true }
  41. }
  42. ]
  43. },
  44. {
  45. path: '',
  46. redirect: '/index'
  47. },
  48. {
  49. path: '/lock',
  50. component: () => import('@/views/lock'),
  51. hidden: true,
  52. meta: { title: '锁定屏幕' }
  53. },
  54. {
  55. path: '/user',
  56. component: Layout,
  57. hidden: true,
  58. redirect: 'noredirect',
  59. children: [
  60. {
  61. path: 'profile/:activeTab?',
  62. component: () => import('@/views/system/user/profile/index'),
  63. name: 'Profile',
  64. meta: { title: '个人中心', icon: 'user' }
  65. }
  66. ]
  67. },
  68. {
  69. path: "/:pathMatch(.*)*",
  70. component: () => import('@/views/error/404'),
  71. hidden: true
  72. }
  73. ]
  74. // 业务模块路由(顶层菜单 + 侧边栏子菜单)
  75. export const businessRoutes = [
  76. {
  77. path: '/zggc',
  78. component: Layout,
  79. redirect: '/zggc/index',
  80. name: 'ZggcMenu',
  81. meta: { title: '直管工程' },
  82. children: [
  83. {
  84. path: 'index',
  85. component: () => import('@/views/portal/zggc'),
  86. name: 'Zggc',
  87. meta: { title: '直管工程' }
  88. },
  89. {
  90. path: 'detail/:folderId',
  91. component: () => import('@/views/portal/portalDetail'),
  92. name: 'ZggcDetail',
  93. hidden: true,
  94. meta: { title: '直管工程详情', activeMenu: '/zggc/index' }
  95. }
  96. ]
  97. },
  98. {
  99. path: '/zdgc',
  100. component: Layout,
  101. redirect: '/zdgc/index',
  102. name: 'ZdgcMenu',
  103. meta: { title: '重点工程' },
  104. children: [
  105. {
  106. path: 'index',
  107. component: () => import('@/views/portal/zdgc'),
  108. name: 'Zdgc',
  109. meta: { title: '重点工程' }
  110. },
  111. {
  112. path: 'detail/:folderId',
  113. component: () => import('@/views/portal/portalDetail'),
  114. name: 'ZdgcDetail',
  115. hidden: true,
  116. meta: { title: '重点工程详情', activeMenu: '/zdgc/index' }
  117. }
  118. ]
  119. },
  120. {
  121. path: '/ddjc',
  122. component: Layout,
  123. redirect: '/ddjc/index',
  124. name: 'DdjcMenu',
  125. meta: { title: '督导检查' },
  126. children: [
  127. {
  128. path: 'index',
  129. component: () => import('@/views/portal/ddjc'),
  130. name: 'Ddjc',
  131. meta: { title: '督导检查' }
  132. }
  133. ]
  134. },
  135. {
  136. path: '/gzzd',
  137. component: Layout,
  138. redirect: '/gzzd/index',
  139. name: 'GzzdMenu',
  140. meta: { title: '规章制度' },
  141. children: [
  142. {
  143. path: 'index',
  144. component: () => import('@/views/portal/gzzd'),
  145. name: 'Gzzd',
  146. meta: { title: '规章制度' }
  147. },
  148. {
  149. path: 'detail/:folderId',
  150. component: () => import('@/views/portal/portalDetail'),
  151. name: 'GzzdDetail',
  152. hidden: true,
  153. meta: { title: '规章制度详情', activeMenu: '/gzzd/index' }
  154. }
  155. ]
  156. },
  157. // 隐藏路由(通过代码导航访问,不在导航栏显示)
  158. {
  159. path: '/more',
  160. component: Layout,
  161. hidden: true,
  162. redirect: '/more/tpz',
  163. name: 'MoreHidden',
  164. meta: { title: '更多' },
  165. children: [
  166. {
  167. path: 'tpz',
  168. component: () => import('@/views/portal/tpz'),
  169. name: 'MoreTpz',
  170. meta: { title: '太浦闸(图片展)' }
  171. },
  172. {
  173. path: 'wyh',
  174. component: () => import('@/views/portal/wyh'),
  175. name: 'MoreWyh',
  176. meta: { title: '望亭闸' }
  177. }
  178. ]
  179. },
  180. {
  181. path: '/efinder',
  182. component: Layout,
  183. hidden: true,
  184. name: 'EfinderHidden',
  185. meta: { title: '文件管理' },
  186. children: [
  187. {
  188. path: 'viewer',
  189. component: () => import('@/views/efinder/viewer'),
  190. name: 'EfinderViewer',
  191. meta: { title: '文件预览' }
  192. }
  193. ]
  194. }
  195. ];
  196. // 动态路由(隐藏页面,基于权限加载)
  197. export const dynamicRoutes = [];
  198. const router = createRouter({
  199. history: createWebHistory(import.meta.env.VITE_APP_BASE_TITLE),
  200. routes: constantRoutes,
  201. scrollBehavior(to, from, savedPosition) {
  202. if (savedPosition) {
  203. return savedPosition
  204. }
  205. return { top: 0 }
  206. },
  207. })
  208. export default router