index.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. import { createRouter, createWebHistory } from 'vue-router';
  2. import store from '@/stores/counter';
  3. import axios from 'axios';
  4. const system = [
  5. {
  6. path: '/system/menus',
  7. name: 'menus',
  8. meta: { title: '吉林省重点领域技术转移平台-菜单管理' },
  9. component: () => import('@/views/system/menus/index.vue')
  10. },
  11. {
  12. path: '/system/config',
  13. name: 'config',
  14. meta: { title: '吉林省重点领域技术转移平台-基础设置' },
  15. component: () => import('@/views/system/config/index.vue')
  16. },
  17. {
  18. path: '/system/role',
  19. name: 'role',
  20. meta: { title: '吉林省重点领域技术转移平台-角色管理' },
  21. component: () => import('@/views/system/role/index.vue')
  22. },
  23. {
  24. path: '/system/dict',
  25. meta: { title: '字典管理' },
  26. component: () => import('@/views/system/dict/index.vue')
  27. },
  28. {
  29. path: '/system/dictData',
  30. meta: { title: '字典数据管理' },
  31. component: () => import('@/views/system/dictData/index.vue')
  32. },
  33. {
  34. path: '/acccount/updatepd',
  35. meta: { title: '修改密码' },
  36. component: () => import('@/views/acccount/updatepd/index.vue')
  37. }
  38. ];
  39. const user = [
  40. {
  41. path: '/user/admin',
  42. meta: { title: '管理员管理' },
  43. component: () => import('@/views/user/admin/index.vue')
  44. },
  45. {
  46. path: '/user/research',
  47. meta: { title: '科研单位管理' },
  48. component: () => import('@/views/user/research/index.vue')
  49. },
  50. {
  51. path: '/user/unit',
  52. meta: { title: '企业管理' },
  53. component: () => import('@/views/user/unit/index.vue')
  54. },
  55. {
  56. path: '/user/selfUser',
  57. meta: { title: '个人用户管理' },
  58. component: () => import('@/views/user/selfUser/index.vue')
  59. }
  60. ];
  61. const core = [
  62. {
  63. path: '/core/achieve/admin',
  64. meta: { title: '管理员-成果管理' },
  65. component: () => import('@/views/core/achieve/admin.vue')
  66. },
  67. {
  68. path: '/core/achieve',
  69. meta: { title: '成果管理' },
  70. component: () => import('@/views/core/achieve/index.vue')
  71. },
  72. {
  73. path: '/core/demand/admin',
  74. meta: { title: '管理员-需求管理' },
  75. component: () => import('@/views/core/demand/admin.vue')
  76. },
  77. {
  78. path: '/core/demand',
  79. meta: { title: '需求管理' },
  80. component: () => import('@/views/core/demand/index.vue')
  81. },
  82. {
  83. path: '/core/service/admin',
  84. meta: { title: '管理员-服务管理' },
  85. component: () => import('@/views/core/service/admin.vue')
  86. },
  87. {
  88. path: '/core/service',
  89. meta: { title: '服务管理' },
  90. component: () => import('@/views/core/service/index.vue')
  91. }
  92. ];
  93. const trade = [
  94. {
  95. path: '/core/trade/negotiate/admin',
  96. meta: { title: '管理员-协商定价管理' },
  97. component: () => import('@/views/core/trade/negotiate/admin.vue')
  98. },
  99. {
  100. path: '/core/trade/negotiate',
  101. meta: { title: '协商定价管理' },
  102. component: () => import('@/views/core/trade/negotiate/index.vue')
  103. },
  104. {
  105. path: '/core/trade/listing/admin',
  106. meta: { title: '管理员-挂牌交易管理' },
  107. component: () => import('@/views/core/trade/listing/admin.vue')
  108. },
  109. {
  110. path: '/core/trade/listing',
  111. meta: { title: '挂牌交易管理' },
  112. component: () => import('@/views/core/trade/listing/index.vue')
  113. },
  114. {
  115. path: '/core/trade/auction/admin',
  116. meta: { title: '管理员-拍卖管理' },
  117. component: () => import('@/views/core/trade/auction/admin.vue')
  118. },
  119. {
  120. path: '/core/trade/auction/test',
  121. meta: { title: '管理员-拍卖管理' },
  122. component: () => import('@/views/core/trade/auction/makeListing.vue')
  123. }
  124. ];
  125. const service = [
  126. {
  127. path: '/service/linkItem',
  128. meta: { title: '管理员-办事事项管理' },
  129. component: () => import('@/views/service/linkItem/index.vue')
  130. },
  131. {
  132. path: '/service/notice',
  133. meta: { title: '管理员-通知公告管理' },
  134. component: () => import('@/views/service/notice/index.vue')
  135. },
  136. {
  137. path: '/service/policy',
  138. meta: { title: '管理员-政策法规管理' },
  139. component: () => import('@/views/service/policy/index.vue')
  140. },
  141. {
  142. path: '/service/trends',
  143. meta: { title: '管理员-行业动态管理' },
  144. component: () => import('@/views/service/trends/index.vue')
  145. },
  146. {
  147. path: '/service/video/admin',
  148. meta: { title: '管理员-点播视频管理' },
  149. component: () => import('@/views/service/video/admin.vue')
  150. }
  151. ];
  152. const router = createRouter({
  153. history: createWebHistory(import.meta.env.BASE_URL),
  154. routes: [
  155. {
  156. path: '/',
  157. redirect: '/login'
  158. },
  159. {
  160. path: '/login',
  161. name: 'login',
  162. meta: { title: '吉林省重点领域技术转移平台-账号登录' },
  163. component: () => import('@/views/login/index.vue')
  164. },
  165. {
  166. path: '/homeIndex',
  167. meta: { title: '吉林省重点领域技术转移平台-系统首页' },
  168. component: () => import('@/components/admin-frame/home.vue'),
  169. children: [
  170. ...system,
  171. ...user,
  172. ...core,
  173. ...trade,
  174. ...service,
  175. {
  176. path: '/homeIndex',
  177. meta: { title: '吉林省重点领域技术转移平台-系统首页' },
  178. component: () => import('@/views/home/index.vue')
  179. }
  180. ]
  181. }
  182. ]
  183. });
  184. router.beforeEach(async (to, from, next) => {
  185. document.title = `${to.meta.title} `;
  186. const token = localStorage.getItem('token');
  187. if (to.name != 'login') {
  188. if (token) {
  189. const res = await axios.request({
  190. method: 'get',
  191. url: `${import.meta.env.VITE_REQUEST_BASE}/token/tokenView`,
  192. responseType: 'json',
  193. headers: {
  194. token: token
  195. }
  196. });
  197. if (res.data.errcode == '0') {
  198. console.log(res.data.data);
  199. store.commit('setUser', res.data.data, { root: true });
  200. }
  201. next();
  202. } else next('/login');
  203. } else next();
  204. });
  205. export default router;