index.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. Vue.use(Router)
  4. /* Layout */
  5. import Layout from '@/layout'
  6. /* Router Modules */
  7. // import componentsRouter from './modules/components'
  8. // import chartsRouter from './modules/charts'
  9. // import tableRouter from './modules/table'
  10. // import nestedRouter from './modules/nested'
  11. /**
  12. * Note: sub-menu only appear when route children.length >= 1
  13. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  14. *
  15. * hidden: true if set true, item will not show in the sidebar(default is false)
  16. * alwaysShow: true if set true, will always show the root menu
  17. * if not set alwaysShow, when item has more than one children route,
  18. * it will becomes nested mode, otherwise not show the root menu
  19. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  20. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  21. * meta : {
  22. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  23. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  24. icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
  25. noCache: true if set true, the page will no be cached(default is false)
  26. affix: true if set true, the tag will affix in the tags-view
  27. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  28. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  29. }
  30. */
  31. /**
  32. * constantRoutes
  33. * a base page that does not have permission requirements
  34. * all roles can be accessed
  35. */
  36. export const constantRoutes = [
  37. {
  38. path: '/redirect',
  39. component: Layout,
  40. hidden: true,
  41. children: [
  42. {
  43. path: '/redirect/:path(.*)',
  44. component: () => import('@/views/redirect/index')
  45. }
  46. ]
  47. },
  48. {
  49. path: '/login',
  50. component: () => import('@/views/login/index'),
  51. hidden: true
  52. },
  53. {
  54. path: '/auth-redirect',
  55. component: () => import('@/views/login/auth-redirect'),
  56. hidden: true
  57. },
  58. {
  59. path: '/404',
  60. component: () => import('@/views/error-page/404'),
  61. hidden: true
  62. },
  63. {
  64. path: '/401',
  65. component: () => import('@/views/error-page/401'),
  66. hidden: true
  67. },
  68. {
  69. path: '/',
  70. component: Layout,
  71. redirect: '/dashboard',
  72. children: [
  73. {
  74. path: 'dashboard',
  75. component: () => import('@/views/dashboard/index'),
  76. name: 'Dashboard',
  77. meta: { title: 'Dashboard', icon: 'dashboard', affix: true }
  78. }
  79. ]
  80. },
  81. {
  82. path: '/Components',
  83. component: Layout,
  84. meta: {
  85. title: '元器件管理',
  86. icon: 'lock'
  87. },
  88. children: [
  89. {
  90. path: 'mainCategory',
  91. component: () => import('@/views/mainCategory/index'),
  92. name: 'MainCategory',
  93. meta: { title: '主类管理', icon: 'documentation', affix: true }
  94. },
  95. {
  96. path: 'subCategory',
  97. component: () => import('@/views/subCategory/index'),
  98. name: 'SubCategory',
  99. meta: { title: '次类管理', icon: 'documentation', affix: true }
  100. },
  101. {
  102. path: 'parameter',
  103. component: () => import('@/views/parameter/index'),
  104. name: 'parameter',
  105. meta: { title: '参数管理', icon: 'documentation', affix: true }
  106. },
  107. {
  108. path: 'componentManage',
  109. component: () => import('@/views/componentManage/index'),
  110. name: 'ComponentManage',
  111. meta: { title: '元器件管理', icon: 'documentation', affix: true }
  112. },
  113. {
  114. path: 'compDetail',
  115. component: () => import('@/views/compDetail/index'),
  116. name: 'CompDetail',
  117. meta: { title: '明细管理', icon: 'documentation', affix: true }
  118. },
  119. {
  120. path: 'history',
  121. component: () => import('@/views/history/index'),
  122. name: 'History',
  123. meta: { title: '历史质量信息管理', icon: 'documentation', affix: true }
  124. }
  125. ]
  126. },
  127. {
  128. path: '/components',
  129. component: Layout,
  130. meta: {
  131. title: '元器件推荐',
  132. icon: 'lock'
  133. },
  134. children: [
  135. {
  136. path: 'Purchase',
  137. component: () => import('@/views/purchase/index'),
  138. name: 'Purchase',
  139. meta: { title: '元器件推荐', icon: 'documentation', affix: true }
  140. },
  141. {
  142. path: '/buyProduct/:id',
  143. component: () => import('@/views/purchase/buyProduct'),
  144. name: 'BuyProduct',
  145. meta: { title: '选择类型', icon: 'documentation', affix: true },
  146. hidden: true
  147. },
  148. {
  149. path: '/ProductList',
  150. component: () => import('@/views/purchase/productList'),
  151. name: 'ProductList',
  152. meta: { title: '产品列表', icon: 'documentation', affix: true },
  153. hidden: true
  154. },
  155. {
  156. path: '/ProductDetail/:model',
  157. component: () => import('@/views/purchase/productDetail'),
  158. name: 'ProductDetail',
  159. meta: { title: '产品详情', icon: 'documentation', affix: true },
  160. hidden: true
  161. },
  162. {
  163. path: '/HistoryQuality/:model',
  164. component: () => import('@/views/purchase/historyQuality'),
  165. name: 'HistoryQuality',
  166. meta: { title: '历史质量问题', icon: 'documentation', affix: true },
  167. hidden: true
  168. }
  169. ]
  170. },
  171. {
  172. path: '/Record',
  173. component: Layout,
  174. meta: {
  175. title: '后台记录',
  176. icon: 'lock'
  177. },
  178. children: [
  179. {
  180. path: 'Score',
  181. component: () => import('@/views/score/index'),
  182. name: 'Score',
  183. meta: { title: '评分管理', icon: 'documentation', affix: true }
  184. },
  185. {
  186. path: 'UserBehavior',
  187. component: () => import('@/views/userBehavior/index'),
  188. name: 'UserBehavior',
  189. meta: { title: '用户行为记录', icon: 'documentation', affix: true }
  190. }
  191. ]
  192. },
  193. {
  194. path: '/DataManagement',
  195. component: Layout,
  196. meta: {
  197. title: '数据管理',
  198. icon: 'lock'
  199. },
  200. children: [
  201. {
  202. path: 'EvaluateManage',
  203. component: () => import('@/views/evaluateManage/index'),
  204. name: 'EvaluateManage',
  205. meta: { title: '评价管理', icon: 'documentation', affix: true }
  206. },
  207. {
  208. path: 'DataAnnotationsManage',
  209. component: () => import('@/views/dataAnnotationsManage/index'),
  210. name: 'DataAnnotationsManage',
  211. meta: { title: '数据标注管理', icon: 'documentation', affix: true }
  212. }
  213. ]
  214. },
  215. {
  216. path: '/AlgorithmManage',
  217. component: Layout,
  218. meta: {
  219. title: '算法管理',
  220. icon: 'lock'
  221. },
  222. children: [
  223. {
  224. path: 'AlgorithmManage',
  225. component: () => import('@/views/algorithmManage/index'),
  226. name: 'AlgorithmManage',
  227. meta: { title: '算法管理', icon: 'documentation', affix: true }
  228. }
  229. ]
  230. }
  231. // {
  232. // path: '/documentation',
  233. // component: Layout,
  234. // children: [
  235. // {
  236. // path: 'index',
  237. // component: () => import('@/views/documentation/index'),
  238. // name: 'Documentation',
  239. // meta: { title: 'Documentation', icon: 'documentation', affix: true }
  240. // }
  241. // ]
  242. // },
  243. // {
  244. // path: '/guide',
  245. // component: Layout,
  246. // redirect: '/guide/index',
  247. // children: [
  248. // {
  249. // path: 'index',
  250. // component: () => import('@/views/guide/index'),
  251. // name: 'Guide',
  252. // meta: { title: 'Guide', icon: 'guide', noCache: true }
  253. // }
  254. // ]
  255. // },
  256. // {
  257. // path: '/profile',
  258. // component: Layout,
  259. // redirect: '/profile/index',
  260. // hidden: true,
  261. // children: [
  262. // {
  263. // path: 'index',
  264. // component: () => import('@/views/profile/index'),
  265. // name: 'Profile',
  266. // meta: { title: 'Profile', icon: 'user', noCache: true }
  267. // }
  268. // ]
  269. // }
  270. ]
  271. /**
  272. * asyncRoutes
  273. * the routes that need to be dynamically loaded based on user roles
  274. */
  275. export const asyncRoutes = [
  276. // {
  277. // path: '/permission',
  278. // component: Layout,
  279. // redirect: '/permission/page',
  280. // alwaysShow: true, // will always show the root menu
  281. // name: 'Permission',
  282. // meta: {
  283. // title: 'Permission',
  284. // icon: 'lock',
  285. // roles: ['admin', 'editor'] // you can set roles in root nav
  286. // },
  287. // children: [
  288. // {
  289. // path: 'page',
  290. // component: () => import('@/views/permission/page'),
  291. // name: 'PagePermission',
  292. // meta: {
  293. // title: 'Page Permission',
  294. // roles: ['admin'] // or you can only set roles in sub nav
  295. // }
  296. // },
  297. // {
  298. // path: 'directive',
  299. // component: () => import('@/views/permission/directive'),
  300. // name: 'DirectivePermission',
  301. // meta: {
  302. // title: 'Directive Permission'
  303. // // if do not set roles, means: this page does not require permission
  304. // }
  305. // },
  306. // {
  307. // path: 'role',
  308. // component: () => import('@/views/permission/role'),
  309. // name: 'RolePermission',
  310. // meta: {
  311. // title: 'Role Permission',
  312. // roles: ['admin']
  313. // }
  314. // }
  315. // ]
  316. // },
  317. // {
  318. // path: '/icon',
  319. // component: Layout,
  320. // children: [
  321. // {
  322. // path: 'index',
  323. // component: () => import('@/views/icons/index'),
  324. // name: 'Icons',
  325. // meta: { title: 'Icons', icon: 'icon', noCache: true }
  326. // }
  327. // ]
  328. // },
  329. /** when your routing map is too long, you can split it into small modules **/
  330. // componentsRouter,
  331. // chartsRouter,
  332. // nestedRouter,
  333. // tableRouter,
  334. // {
  335. // path: '/example',
  336. // component: Layout,
  337. // redirect: '/example/list',
  338. // name: 'Example',
  339. // meta: {
  340. // title: 'Example',
  341. // icon: 'el-icon-s-help'
  342. // },
  343. // children: [
  344. // {
  345. // path: 'create',
  346. // component: () => import('@/views/example/create'),
  347. // name: 'CreateArticle',
  348. // meta: { title: 'Create Article', icon: 'edit' }
  349. // },
  350. // {
  351. // path: 'edit/:id(\\d+)',
  352. // component: () => import('@/views/example/edit'),
  353. // name: 'EditArticle',
  354. // meta: { title: 'Edit Article', noCache: true, activeMenu: '/example/list' },
  355. // hidden: true
  356. // },
  357. // {
  358. // path: 'list',
  359. // component: () => import('@/views/example/list'),
  360. // name: 'ArticleList',
  361. // meta: { title: 'Article List', icon: 'list' }
  362. // }
  363. // ]
  364. // },
  365. // {
  366. // path: '/tab',
  367. // component: Layout,
  368. // children: [
  369. // {
  370. // path: 'index',
  371. // component: () => import('@/views/tab/index'),
  372. // name: 'Tab',
  373. // meta: { title: 'Tab', icon: 'tab' }
  374. // }
  375. // ]
  376. // },
  377. // {
  378. // path: '/error',
  379. // component: Layout,
  380. // redirect: 'noRedirect',
  381. // name: 'ErrorPages',
  382. // meta: {
  383. // title: 'Error Pages',
  384. // icon: '404'
  385. // },
  386. // children: [
  387. // {
  388. // path: '401',
  389. // component: () => import('@/views/error-page/401'),
  390. // name: 'Page401',
  391. // meta: { title: '401', noCache: true }
  392. // },
  393. // {
  394. // path: '404',
  395. // component: () => import('@/views/error-page/404'),
  396. // name: 'Page404',
  397. // meta: { title: '404', noCache: true }
  398. // }
  399. // ]
  400. // },
  401. // {
  402. // path: '/error-log',
  403. // component: Layout,
  404. // children: [
  405. // {
  406. // path: 'log',
  407. // component: () => import('@/views/error-log/index'),
  408. // name: 'ErrorLog',
  409. // meta: { title: 'Error Log', icon: 'bug' }
  410. // }
  411. // ]
  412. // },
  413. // {
  414. // path: '/excel',
  415. // component: Layout,
  416. // redirect: '/excel/export-excel',
  417. // name: 'Excel',
  418. // meta: {
  419. // title: 'Excel',
  420. // icon: 'excel'
  421. // },
  422. // children: [
  423. // {
  424. // path: 'export-excel',
  425. // component: () => import('@/views/excel/export-excel'),
  426. // name: 'ExportExcel',
  427. // meta: { title: 'Export Excel' }
  428. // },
  429. // {
  430. // path: 'export-selected-excel',
  431. // component: () => import('@/views/excel/select-excel'),
  432. // name: 'SelectExcel',
  433. // meta: { title: 'Export Selected' }
  434. // },
  435. // {
  436. // path: 'export-merge-header',
  437. // component: () => import('@/views/excel/merge-header'),
  438. // name: 'MergeHeader',
  439. // meta: { title: 'Merge Header' }
  440. // },
  441. // {
  442. // path: 'upload-excel',
  443. // component: () => import('@/views/excel/upload-excel'),
  444. // name: 'UploadExcel',
  445. // meta: { title: 'Upload Excel' }
  446. // }
  447. // ]
  448. // },
  449. // {
  450. // path: '/zip',
  451. // component: Layout,
  452. // redirect: '/zip/download',
  453. // alwaysShow: true,
  454. // name: 'Zip',
  455. // meta: { title: 'Zip', icon: 'zip' },
  456. // children: [
  457. // {
  458. // path: 'download',
  459. // component: () => import('@/views/zip/index'),
  460. // name: 'ExportZip',
  461. // meta: { title: 'Export Zip' }
  462. // }
  463. // ]
  464. // },
  465. // {
  466. // path: '/pdf',
  467. // component: Layout,
  468. // redirect: '/pdf/index',
  469. // children: [
  470. // {
  471. // path: 'index',
  472. // component: () => import('@/views/pdf/index'),
  473. // name: 'PDF',
  474. // meta: { title: 'PDF', icon: 'pdf' }
  475. // }
  476. // ]
  477. // },
  478. // {
  479. // path: '/pdf/download',
  480. // component: () => import('@/views/pdf/download'),
  481. // hidden: true
  482. // },
  483. // {
  484. // path: '/theme',
  485. // component: Layout,
  486. // children: [
  487. // {
  488. // path: 'index',
  489. // component: () => import('@/views/theme/index'),
  490. // name: 'Theme',
  491. // meta: { title: 'Theme', icon: 'theme' }
  492. // }
  493. // ]
  494. // },
  495. // {
  496. // path: '/clipboard',
  497. // component: Layout,
  498. // children: [
  499. // {
  500. // path: 'index',
  501. // component: () => import('@/views/clipboard/index'),
  502. // name: 'ClipboardDemo',
  503. // meta: { title: 'Clipboard', icon: 'clipboard' }
  504. // }
  505. // ]
  506. // },
  507. // {
  508. // path: 'external-link',
  509. // component: Layout,
  510. // children: [
  511. // {
  512. // path: 'https://github.com/PanJiaChen/vue-element-admin',
  513. // meta: { title: 'External Link', icon: 'link' }
  514. // }
  515. // ]
  516. // },
  517. // 404 page must be placed at the end !!!
  518. { path: '*', redirect: '/404', hidden: true }
  519. ]
  520. const createRouter = () => new Router({
  521. // mode: 'history', // require service support
  522. scrollBehavior: () => ({ y: 0 }),
  523. routes: constantRoutes
  524. })
  525. const router = createRouter()
  526. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  527. export function resetRouter() {
  528. const newRouter = createRouter()
  529. router.matcher = newRouter.matcher // reset router
  530. }
  531. export default router