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.

173 lines
5.5 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 weeks 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. path: 'exchangeRecords',
  127. name: 'exchangeRecords',
  128. component: () => import('../views/EventManagement/ExchangeRecords.vue'),
  129. meta: { title: 'Token兑换记录', showSidebar: true }
  130. },
  131. {
  132. path: 'learningPageConfig',
  133. name: 'learningPageConfig',
  134. component: () => import('../views/EventManagement/LearningPageConfig.vue'),
  135. meta: { title: '学习页配置', showSidebar: true }
  136. },
  137. ]
  138. },
  139. ]
  140. }
  141. ]
  142. }
  143. ]
  144. const router = createRouter({
  145. history: createWebHistory(import.meta.env.BASE_URL),
  146. routes
  147. })
  148. // 全局前置守卫
  149. router.beforeEach((to, from, next) => {
  150. // 登录状态判断
  151. const token = localStorage.getItem('token')
  152. // 权限拦截逻辑
  153. if (to.meta.requireAuth) {
  154. // 目标页面需要登录:已登录→放行,未登录→跳登录页
  155. if (token) {
  156. next() // 已登录,放行
  157. } else {
  158. next({ path: '/login' }) // 跳登录页
  159. }
  160. } else {
  161. // 目标页面不需要登录:已登录→跳首页,未登录→放行
  162. if (token && to.path === '/login') {
  163. next('/') // 自动跳首页
  164. } else {
  165. next() // 未登录,放行到登录页
  166. }
  167. }
  168. })
  169. export default router