index.js 18 KB

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