index.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  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', //访问/的时候会跳转到dashboard
  72. children: [
  73. {
  74. path: 'dashboard',
  75. component: () => import('@/views/dashboard/index'),
  76. name: '首页',
  77. meta: {
  78. title: '首页',
  79. icon: require('@/assets/public/sidebar/default/index.png'),
  80. selected_icon: require('@/assets/public/sidebar/select/index.png'),
  81. affix: true,
  82. }
  83. }
  84. ]
  85. },
  86. //增加新的路由 站点列表
  87. //注意必须含有component:Layout项目否则会导致页面找不到模板
  88. //必须含有children中的path且两个path必须一致
  89. {
  90. path: '/website',
  91. component: Layout,
  92. children: [
  93. {
  94. name: '', //直接就是根目录所以为空
  95. path: '',
  96. component: () => import('@/views/website/WebsiteList'),
  97. meta: {
  98. title: '网站管理', // 设置菜单和面包屑显示的标题
  99. hidden: true, // 不在侧边菜单显示
  100. breadcrumb: true // 强制在面包屑中显示
  101. }
  102. }
  103. ]
  104. },
  105. {
  106. path: '/categoryList',
  107. component: Layout,
  108. children: [
  109. {
  110. name: '',
  111. path: '',
  112. component: () => import('@/views/website/categoryList'),
  113. meta: {
  114. title: '导航池',
  115. hidden: true,
  116. breadcrumb: true
  117. }
  118. }
  119. ]
  120. },
  121. {
  122. path: '/websiteColumn',
  123. component: Layout,
  124. children: [
  125. {
  126. name: '',
  127. path: '',
  128. component: () => import('@/views/website/websiteColumn'),
  129. meta: {
  130. title: '网站导航',
  131. hidden: true,
  132. breadcrumb: true
  133. }
  134. }
  135. ]
  136. },
  137. {
  138. path: '/editNavigation',
  139. component: Layout,
  140. children: [
  141. {
  142. name: '',
  143. path: '',
  144. component: () => import('@/views/website/editNavigation'),
  145. meta: {
  146. title: '导航详情',
  147. hidden: true,
  148. breadcrumb: true
  149. }
  150. }
  151. ]
  152. },
  153. {
  154. path: '/articleList',
  155. component: Layout,
  156. children: [
  157. {
  158. name: '',
  159. path: '',
  160. component: () => import('@/views/news/NewList'),
  161. meta: {
  162. title: '资讯列表',
  163. hidden: true,
  164. breadcrumb: true
  165. }
  166. }
  167. ]
  168. },
  169. {
  170. path: '/creatNews',
  171. component: Layout,
  172. children: [
  173. {
  174. name: '',
  175. path: '',
  176. component: () => import('@/views/news/creatNews'),
  177. meta: {
  178. title: '添加资讯',
  179. hidden: true,
  180. breadcrumb: true
  181. }
  182. }
  183. ]
  184. },
  185. {
  186. path: '/menuList',
  187. component: Layout,
  188. children: [
  189. {
  190. name: '',
  191. path: '',
  192. component: () => import('@/views/menu/menulist'),
  193. meta: {
  194. title: '菜单列表',
  195. hidden: true,
  196. breadcrumb: true
  197. }
  198. }
  199. ]
  200. },
  201. {
  202. path: '/complaintList',
  203. component: Layout,
  204. children: [
  205. {
  206. name: '',
  207. path: '',
  208. component: () => import('@/views/complaint/complaintList'),
  209. meta: {
  210. title: '投诉举报',
  211. hidden: true,
  212. breadcrumb: true
  213. }
  214. }
  215. ]
  216. },
  217. {
  218. path: '/roleList',
  219. component: Layout,
  220. children: [
  221. {
  222. name: '',
  223. path: '',
  224. component: () => import('@/views/role/roleList'),
  225. meta: {
  226. title: '角色管理',
  227. hidden: true,
  228. breadcrumb: true
  229. }
  230. }
  231. ]
  232. },
  233. {
  234. path: '/userList',
  235. component: Layout,
  236. children: [
  237. {
  238. name: '',
  239. path: '',
  240. component: () => import('@/views/role/userList'),
  241. meta: {
  242. title: '用户管理',
  243. hidden: true,
  244. breadcrumb: true
  245. }
  246. }
  247. ]
  248. },
  249. {
  250. path: '/creatUser',
  251. component: Layout,
  252. children: [
  253. {
  254. name: '',
  255. path: '',
  256. component: () => import('@/views/role/creatUser'),
  257. meta: {
  258. title: '添加用户',
  259. hidden: true,
  260. breadcrumb: true
  261. }
  262. }
  263. ]
  264. },
  265. {
  266. path: '/department',
  267. component: Layout,
  268. children: [
  269. {
  270. name: '',
  271. path: '',
  272. component: () => import('@/views/menu/department'),
  273. meta: {
  274. title: '行政职能',
  275. hidden: true,
  276. breadcrumb: true
  277. }
  278. }
  279. ]
  280. },
  281. {
  282. path: '/hall',
  283. component: Layout,
  284. children: [
  285. {
  286. name: '',
  287. path: '',
  288. component: () => import('@/views/chat/hall'),
  289. meta: {
  290. title: '聊天',
  291. hidden: true,
  292. breadcrumb: true
  293. }
  294. }
  295. ]
  296. },
  297. {
  298. path: '/creatWebsite',
  299. component: Layout,
  300. children: [
  301. {
  302. name: '',
  303. path: '',
  304. component: () => import('@/views/website/creatWebsite'),
  305. meta: {
  306. title: '搭建网站',
  307. hidden: true,
  308. breadcrumb: true
  309. }
  310. }
  311. ]
  312. },
  313. {
  314. path: '/contacts',
  315. component: Layout,
  316. children: [
  317. {
  318. name: '',
  319. path: '',
  320. component: () => import('@/views/chat/contacts'),
  321. meta: {
  322. title: '通讯录',
  323. hidden: true,
  324. breadcrumb: true
  325. }
  326. }
  327. ]
  328. },
  329. {
  330. path: '/webCrawler',
  331. component: Layout,
  332. children: [
  333. {
  334. name: '',
  335. path: '',
  336. component: () => import('@/views/crawler/webCrawler'),
  337. meta: {
  338. title: '建立网站',
  339. hidden: true,
  340. breadcrumb: true
  341. }
  342. }
  343. ]
  344. },
  345. {
  346. path: '/topic',
  347. component: Layout,
  348. children: [
  349. {
  350. name: '',
  351. path: '',
  352. component: () => import('@/views/chat/topic'),
  353. meta: {
  354. title: '课题',
  355. hidden: true,
  356. breadcrumb: true
  357. }
  358. }
  359. ]
  360. },
  361. {
  362. path: '/webRule',
  363. component: Layout,
  364. children: [
  365. {
  366. name: '',
  367. path: '',
  368. component: () => import('@/views/crawler/webRule'),
  369. meta: {
  370. title: '规则列表',
  371. hidden: true,
  372. breadcrumb: true
  373. }
  374. }
  375. ]
  376. },
  377. {
  378. path: '/creatTopic',
  379. component: Layout,
  380. children: [
  381. {
  382. name: '',
  383. path: '',
  384. component: () => import('@/views/chat/creatTopic'),
  385. meta: {
  386. title: '编辑课题',
  387. hidden: true,
  388. breadcrumb: true
  389. }
  390. }
  391. ]
  392. },
  393. {
  394. path: '/webCrawlerList',
  395. component: Layout,
  396. children: [
  397. {
  398. name: '',
  399. path: '',
  400. component: () => import('@/views/crawler/webCrawlerList'),
  401. meta: {
  402. title: '采集列表',
  403. hidden: true,
  404. breadcrumb: true
  405. }
  406. }
  407. ]
  408. },
  409. {
  410. path: '/webCrawlerListEdit',
  411. component: Layout,
  412. children: [
  413. {
  414. name: '',
  415. path: '',
  416. component: () => import('@/views/crawler/webCrawlerListEdit'),
  417. meta: {
  418. title: '编辑资讯',
  419. hidden: true,
  420. breadcrumb: true
  421. }
  422. }
  423. ]
  424. },
  425. {
  426. path: '/adList',
  427. component: Layout,
  428. children: [
  429. {
  430. name: '',
  431. path: '',
  432. component: () => import('@/views/advertise/advertiseList'),
  433. meta: {
  434. title: '广告列表',
  435. hidden: true,
  436. breadcrumb: true
  437. }
  438. }
  439. ]
  440. },
  441. {
  442. path: '/adPlaceList',
  443. component: Layout,
  444. children: [
  445. {
  446. name: '',
  447. path: '',
  448. component: () => import('@/views/advertise/adPlaceList'),
  449. meta: {
  450. title: '广告位管理',
  451. hidden: true,
  452. breadcrumb: true
  453. }
  454. }
  455. ]
  456. },
  457. // {
  458. // path: '/documentation',
  459. // component: Layout,
  460. // children: [
  461. // {
  462. // path: 'index',
  463. // component: () => import('@/views/documentation/index'),
  464. // name: 'Documentation',
  465. // meta: { title: 'documentation', icon: 'documentation', affix: true }
  466. // }
  467. // ]
  468. // },
  469. // {
  470. // path: '/guide',
  471. // component: Layout,
  472. // redirect: '/guide/index',
  473. // children: [
  474. // {
  475. // path: 'index',
  476. // component: () => import('@/views/guide/index'),
  477. // name: 'Guide',
  478. // meta: { title: 'guide', icon: 'guide', noCache: true }
  479. // }
  480. // ]
  481. // },
  482. {
  483. path: '/profile',
  484. component: Layout,
  485. redirect: '/profile/index',
  486. hidden: true,
  487. children: [
  488. {
  489. path: 'index',
  490. component: () => import('@/views/profile/index'),
  491. name: 'Profile',
  492. meta: {
  493. title: '个人中心',
  494. hidden: true,
  495. breadcrumb: true
  496. }
  497. }
  498. ]
  499. }
  500. ]
  501. /**
  502. * asyncRoutes
  503. * the routes that need to be dynamically loaded based on user roles
  504. */
  505. export const asyncRoutes = [
  506. {
  507. path: '/permission',
  508. component: Layout,
  509. redirect: '/permission/page',
  510. alwaysShow: true, // will always show the root menu
  511. name: 'Permission',
  512. meta: {
  513. title: 'permission',
  514. icon: 'lock',
  515. roles: ['admin', 'editor'] // you can set roles in root nav
  516. },
  517. children: [
  518. {
  519. path: 'page',
  520. component: () => import('@/views/permission/page'),
  521. name: 'PagePermission',
  522. meta: {
  523. title: 'pagePermission',
  524. roles: ['admin'] // or you can only set roles in sub nav
  525. }
  526. },
  527. {
  528. path: 'directive',
  529. component: () => import('@/views/permission/directive'),
  530. name: 'DirectivePermission',
  531. meta: {
  532. title: 'directivePermission'
  533. // if do not set roles, means: this page does not require permission
  534. }
  535. },
  536. {
  537. path: 'role',
  538. component: () => import('@/views/permission/role'),
  539. name: 'RolePermission',
  540. meta: {
  541. title: 'rolePermission',
  542. roles: ['admin']
  543. }
  544. }
  545. ]
  546. },
  547. {
  548. path: '/icon',
  549. component: Layout,
  550. children: [
  551. {
  552. path: 'index',
  553. component: () => import('@/views/icons/index'),
  554. name: 'Icons',
  555. meta: { title: 'icons', icon: 'icon', noCache: true }
  556. }
  557. ]
  558. },
  559. /** when your routing map is too long, you can split it into small modules **/
  560. componentsRouter,
  561. chartsRouter,
  562. nestedRouter,
  563. tableRouter,
  564. {
  565. path: '/example',
  566. component: Layout,
  567. redirect: '/example/list',
  568. name: 'Example',
  569. meta: {
  570. title: 'example',
  571. icon: 'el-icon-s-help'
  572. },
  573. children: [
  574. {
  575. path: 'create',
  576. component: () => import('@/views/example/create'),
  577. name: 'CreateArticle',
  578. meta: { title: 'createArticle', icon: 'edit' }
  579. },
  580. {
  581. path: 'edit/:id(\\d+)',
  582. component: () => import('@/views/example/edit'),
  583. name: 'EditArticle',
  584. meta: { title: 'editArticle', noCache: true, activeMenu: '/example/list' },
  585. hidden: true
  586. },
  587. {
  588. path: 'list',
  589. component: () => import('@/views/example/list'),
  590. name: 'ArticleList',
  591. meta: { title: 'articleList', icon: 'list' }
  592. }
  593. ]
  594. },
  595. {
  596. path: '/tab',
  597. component: Layout,
  598. children: [
  599. {
  600. path: 'index',
  601. component: () => import('@/views/tab/index'),
  602. name: 'Tab',
  603. meta: { title: 'tab', icon: 'tab' }
  604. }
  605. ]
  606. },
  607. {
  608. path: '/error',
  609. component: Layout,
  610. redirect: 'noRedirect',
  611. name: 'ErrorPages',
  612. meta: {
  613. title: 'errorPages',
  614. icon: '404'
  615. },
  616. children: [
  617. {
  618. path: '401',
  619. component: () => import('@/views/error-page/401'),
  620. name: 'Page401',
  621. meta: { title: 'page401', noCache: true }
  622. },
  623. {
  624. path: '404',
  625. component: () => import('@/views/error-page/404'),
  626. name: 'Page404',
  627. meta: { title: 'page404', noCache: true }
  628. }
  629. ]
  630. },
  631. {
  632. path: '/error-log',
  633. component: Layout,
  634. children: [
  635. {
  636. path: 'log',
  637. component: () => import('@/views/error-log/index'),
  638. name: 'ErrorLog',
  639. meta: { title: 'errorLog', icon: 'bug' }
  640. }
  641. ]
  642. },
  643. {
  644. path: '/excel',
  645. component: Layout,
  646. redirect: '/excel/export-excel',
  647. name: 'Excel',
  648. meta: {
  649. title: 'excel',
  650. icon: 'excel'
  651. },
  652. children: [
  653. {
  654. path: 'export-excel',
  655. component: () => import('@/views/excel/export-excel'),
  656. name: 'ExportExcel',
  657. meta: { title: 'exportExcel' }
  658. },
  659. {
  660. path: 'export-selected-excel',
  661. component: () => import('@/views/excel/select-excel'),
  662. name: 'SelectExcel',
  663. meta: { title: 'selectExcel' }
  664. },
  665. {
  666. path: 'export-merge-header',
  667. component: () => import('@/views/excel/merge-header'),
  668. name: 'MergeHeader',
  669. meta: { title: 'mergeHeader' }
  670. },
  671. {
  672. path: 'upload-excel',
  673. component: () => import('@/views/excel/upload-excel'),
  674. name: 'UploadExcel',
  675. meta: { title: 'uploadExcel' }
  676. }
  677. ]
  678. },
  679. {
  680. path: '/zip',
  681. component: Layout,
  682. redirect: '/zip/download',
  683. alwaysShow: true,
  684. name: 'Zip',
  685. meta: { title: 'zip', icon: 'zip' },
  686. children: [
  687. {
  688. path: 'download',
  689. component: () => import('@/views/zip/index'),
  690. name: 'ExportZip',
  691. meta: { title: 'exportZip' }
  692. }
  693. ]
  694. },
  695. {
  696. path: '/pdf',
  697. component: Layout,
  698. redirect: '/pdf/index',
  699. children: [
  700. {
  701. path: 'index',
  702. component: () => import('@/views/pdf/index'),
  703. name: 'PDF',
  704. meta: { title: 'pdf', icon: 'pdf' }
  705. }
  706. ]
  707. },
  708. {
  709. path: '/pdf/download',
  710. component: () => import('@/views/pdf/download'),
  711. hidden: true
  712. },
  713. {
  714. path: '/theme',
  715. component: Layout,
  716. children: [
  717. {
  718. path: 'index',
  719. component: () => import('@/views/theme/index'),
  720. name: 'Theme',
  721. meta: { title: 'theme', icon: 'theme' }
  722. }
  723. ]
  724. },
  725. {
  726. path: '/clipboard',
  727. component: Layout,
  728. children: [
  729. {
  730. path: 'index',
  731. component: () => import('@/views/clipboard/index'),
  732. name: 'ClipboardDemo',
  733. meta: { title: 'clipboardDemo', icon: 'clipboard' }
  734. }
  735. ]
  736. },
  737. {
  738. path: '/i18n',
  739. component: Layout,
  740. children: [
  741. {
  742. path: 'index',
  743. component: () => import('@/views/i18n-demo/index'),
  744. name: 'I18n',
  745. meta: { title: 'i18n', icon: 'international' }
  746. }
  747. ]
  748. },
  749. {
  750. path: 'external-link',
  751. component: Layout,
  752. children: [
  753. {
  754. path: 'https://github.com/PanJiaChen/vue-element-admin',
  755. meta: { title: 'externalLink', icon: 'link' }
  756. }
  757. ]
  758. },
  759. // 404 page must be placed at the end !!!
  760. { path: '*', redirect: '/404', hidden: true }
  761. ]
  762. const createRouter = () => new Router({
  763. // mode: 'history', // require service support
  764. scrollBehavior: () => ({ y: 0 }),
  765. routes: constantRoutes
  766. })
  767. const router = createRouter()
  768. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  769. export function resetRouter() {
  770. const newRouter = createRouter()
  771. router.matcher = newRouter.matcher // reset router
  772. }
  773. export default router