deepchart后台管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
5.0 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. import { createRouter, createWebHistory } from 'vue-router'
  2. import Layout from '../layout/Layout.vue'
  3. const routes = [
  4. {
  5. path: '/',
  6. redirect: '/userPermissions/market'
  7. },
  8. {
  9. path: '/login',
  10. name: 'login',
  11. component: () => import('../views/Login.vue'),
  12. meta: {
  13. title: '登录',
  14. hiddenSidebar: true,
  15. requireAuth: false // 登录页不需要登录
  16. }
  17. },
  18. {
  19. path: '',
  20. component: Layout,
  21. meta: {
  22. requireAuth: true // Layout下所有子路由都需要登录
  23. },
  24. children: [
  25. {
  26. path: 'userPermissions',
  27. name: 'userPermissions',
  28. meta: { title: '用户权限管理', icon: "UserFilled", showSidebar: true, isParentNav: true },
  29. children: [
  30. {
  31. path: 'market',
  32. name: 'market',
  33. component: () => import('../views/UserPermissions/Market.vue'),
  34. meta: { title: '行情期限', showSidebar: true }
  35. },
  36. {
  37. path: 'module',
  38. name: 'module',
  39. component: () => import('../views/UserPermissions/Module.vue'),
  40. meta: { title: '模块期限', showSidebar: true }
  41. },
  42. {
  43. path: 'invitedLook',
  44. name: 'invitedLook',
  45. component: () => import('../views/UserPermissions/invitedLook.vue'),
  46. meta: { title: '查看被邀请用户', showSidebar: true }
  47. },
  48. // 深度探索--操作日志
  49. {
  50. path: 'logDeepexplore',
  51. name: 'logDeepexplore',
  52. component: () => import('../views/UserPermissions/LogDeepExplore.vue'),
  53. meta: { hidden: true }
  54. },
  55. // DeepMate--操作日志
  56. {
  57. path: 'logDeepMate',
  58. name: 'logDeepMate',
  59. component: () => import('../views/UserPermissions/LogDeepMate.vue'),
  60. meta: { hidden: true }
  61. },
  62. // 行情期限--操作日志
  63. {
  64. path: 'logMarket',
  65. name: 'logMarket',
  66. component: () => import('../views/UserPermissions/LogMarket.vue'),
  67. meta: { hidden: true }
  68. },
  69. // 导出列表页面
  70. {
  71. path: 'export',
  72. name: 'export',
  73. component: () => import('../views/UserPermissions/Export.vue'),
  74. meta: { hidden: true }
  75. }
  76. ]
  77. },
  78. {
  79. path: 'platformData',
  80. name: 'platformData',
  81. meta: { title: '平台数据管理', icon: "TrendCharts", showSidebar: true, isParentNav: true },
  82. children: [
  83. {
  84. path: 'overview',
  85. name: 'overview',
  86. component: () => import('../views/PlatformData/UserOverview.vue'),
  87. meta: { title: '用户数据概览', showSidebar: true }
  88. },
  89. // {
  90. // path: 'loginStats',
  91. // name: 'loginStats',
  92. // component: () => import('../views/PlatformData/UserLoginStats.vue'),
  93. // meta: { title: '用户登录统计', showSidebar: true }
  94. // },
  95. {
  96. path: 'activityStats',
  97. name: 'activityStats',
  98. component: () => import('../views/PlatformData/UserActivityStats.vue'),
  99. meta: { title: '用户活跃度统计', showSidebar: true }
  100. }
  101. ]
  102. },
  103. {
  104. path: 'EventManagement',
  105. name: 'EventManagement',
  106. meta: { title: '活动管理', icon: "Management", showSidebar: true, isParentNav: true },
  107. children: [
  108. {
  109. path: 'NewYearAct',
  110. name: 'NewYearAct',
  111. meta: { title: '新年幸运签', showSidebar: true },
  112. children: [
  113. {
  114. path: 'winningRecords',
  115. name: 'winningRecords',
  116. component: () => import('../views/EventManagement/WinningRecords.vue'),
  117. meta: { title: '历史记录', showSidebar: true }
  118. },
  119. {
  120. path: 'contentConfiguration',
  121. name: 'contentConfiguration',
  122. component: () => import('../views/EventManagement/ContentConfiguration.vue'),
  123. meta: { title: '内容配置', showSidebar: true }
  124. },
  125. ]
  126. },
  127. ]
  128. }
  129. ]
  130. }
  131. ]
  132. const router = createRouter({
  133. history: createWebHistory(import.meta.env.BASE_URL),
  134. routes
  135. })
  136. // 全局前置守卫
  137. router.beforeEach((to, from, next) => {
  138. // 登录状态判断
  139. const token = localStorage.getItem('token')
  140. // 权限拦截逻辑
  141. if (to.meta.requireAuth) {
  142. // 目标页面需要登录:已登录→放行,未登录→跳登录页
  143. if (token) {
  144. next() // 已登录,放行
  145. } else {
  146. next({ path: '/login' }) // 跳登录页
  147. }
  148. } else {
  149. // 目标页面不需要登录:已登录→跳首页,未登录→放行
  150. if (token && to.path === '/login') {
  151. next('/') // 自动跳首页
  152. } else {
  153. next() // 未登录,放行到登录页
  154. }
  155. }
  156. })
  157. export default router