index.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  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: '/documentation',
  460. // component: Layout,
  461. // children: [
  462. // {
  463. // path: 'index',
  464. // component: () => import('@/views/documentation/index'),
  465. // name: 'Documentation',
  466. // meta: { title: 'documentation', icon: 'documentation', affix: true }
  467. // }
  468. // ]
  469. // },
  470. // {
  471. // path: '/guide',
  472. // component: Layout,
  473. // redirect: '/guide/index',
  474. // children: [
  475. // {
  476. // path: 'index',
  477. // component: () => import('@/views/guide/index'),
  478. // name: 'Guide',
  479. // meta: { title: 'guide', icon: 'guide', noCache: true }
  480. // }
  481. // ]
  482. // },
  483. {
  484. path: '/profile',
  485. component: Layout,
  486. redirect: '/profile/index',
  487. hidden: true,
  488. children: [
  489. {
  490. path: 'index',
  491. component: () => import('@/views/profile/index'),
  492. name: 'Profile',
  493. meta: {
  494. title: '个人中心',
  495. hidden: true,
  496. breadcrumb: true
  497. }
  498. }
  499. ]
  500. }
  501. ]
  502. /**
  503. * asyncRoutes
  504. * the routes that need to be dynamically loaded based on user roles
  505. */
  506. export const asyncRoutes = [
  507. {
  508. path: '/permission',
  509. component: Layout,
  510. redirect: '/permission/page',
  511. alwaysShow: true, // will always show the root menu
  512. name: 'Permission',
  513. meta: {
  514. title: 'permission',
  515. icon: 'lock',
  516. roles: ['admin', 'editor'] // you can set roles in root nav
  517. },
  518. children: [
  519. {
  520. path: 'page',
  521. component: () => import('@/views/permission/page'),
  522. name: 'PagePermission',
  523. meta: {
  524. title: 'pagePermission',
  525. roles: ['admin'] // or you can only set roles in sub nav
  526. }
  527. },
  528. {
  529. path: 'directive',
  530. component: () => import('@/views/permission/directive'),
  531. name: 'DirectivePermission',
  532. meta: {
  533. title: 'directivePermission'
  534. // if do not set roles, means: this page does not require permission
  535. }
  536. },
  537. {
  538. path: 'role',
  539. component: () => import('@/views/permission/role'),
  540. name: 'RolePermission',
  541. meta: {
  542. title: 'rolePermission',
  543. roles: ['admin']
  544. }
  545. }
  546. ]
  547. },
  548. {
  549. path: '/icon',
  550. component: Layout,
  551. children: [
  552. {
  553. path: 'index',
  554. component: () => import('@/views/icons/index'),
  555. name: 'Icons',
  556. meta: { title: 'icons', icon: 'icon', noCache: true }
  557. }
  558. ]
  559. },
  560. /** when your routing map is too long, you can split it into small modules **/
  561. componentsRouter,
  562. chartsRouter,
  563. nestedRouter,
  564. tableRouter,
  565. {
  566. path: '/example',
  567. component: Layout,
  568. redirect: '/example/list',
  569. name: 'Example',
  570. meta: {
  571. title: 'example',
  572. icon: 'el-icon-s-help'
  573. },
  574. children: [
  575. {
  576. path: 'create',
  577. component: () => import('@/views/example/create'),
  578. name: 'CreateArticle',
  579. meta: { title: 'createArticle', icon: 'edit' }
  580. },
  581. {
  582. path: 'edit/:id(\\d+)',
  583. component: () => import('@/views/example/edit'),
  584. name: 'EditArticle',
  585. meta: { title: 'editArticle', noCache: true, activeMenu: '/example/list' },
  586. hidden: true
  587. },
  588. {
  589. path: 'list',
  590. component: () => import('@/views/example/list'),
  591. name: 'ArticleList',
  592. meta: { title: 'articleList', icon: 'list' }
  593. }
  594. ]
  595. },
  596. {
  597. path: '/tab',
  598. component: Layout,
  599. children: [
  600. {
  601. path: 'index',
  602. component: () => import('@/views/tab/index'),
  603. name: 'Tab',
  604. meta: { title: 'tab', icon: 'tab' }
  605. }
  606. ]
  607. },
  608. {
  609. path: '/error',
  610. component: Layout,
  611. redirect: 'noRedirect',
  612. name: 'ErrorPages',
  613. meta: {
  614. title: 'errorPages',
  615. icon: '404'
  616. },
  617. children: [
  618. {
  619. path: '401',
  620. component: () => import('@/views/error-page/401'),
  621. name: 'Page401',
  622. meta: { title: 'page401', noCache: true }
  623. },
  624. {
  625. path: '404',
  626. component: () => import('@/views/error-page/404'),
  627. name: 'Page404',
  628. meta: { title: 'page404', noCache: true }
  629. }
  630. ]
  631. },
  632. {
  633. path: '/error-log',
  634. component: Layout,
  635. children: [
  636. {
  637. path: 'log',
  638. component: () => import('@/views/error-log/index'),
  639. name: 'ErrorLog',
  640. meta: { title: 'errorLog', icon: 'bug' }
  641. }
  642. ]
  643. },
  644. {
  645. path: '/excel',
  646. component: Layout,
  647. redirect: '/excel/export-excel',
  648. name: 'Excel',
  649. meta: {
  650. title: 'excel',
  651. icon: 'excel'
  652. },
  653. children: [
  654. {
  655. path: 'export-excel',
  656. component: () => import('@/views/excel/export-excel'),
  657. name: 'ExportExcel',
  658. meta: { title: 'exportExcel' }
  659. },
  660. {
  661. path: 'export-selected-excel',
  662. component: () => import('@/views/excel/select-excel'),
  663. name: 'SelectExcel',
  664. meta: { title: 'selectExcel' }
  665. },
  666. {
  667. path: 'export-merge-header',
  668. component: () => import('@/views/excel/merge-header'),
  669. name: 'MergeHeader',
  670. meta: { title: 'mergeHeader' }
  671. },
  672. {
  673. path: 'upload-excel',
  674. component: () => import('@/views/excel/upload-excel'),
  675. name: 'UploadExcel',
  676. meta: { title: 'uploadExcel' }
  677. }
  678. ]
  679. },
  680. {
  681. path: '/zip',
  682. component: Layout,
  683. redirect: '/zip/download',
  684. alwaysShow: true,
  685. name: 'Zip',
  686. meta: { title: 'zip', icon: 'zip' },
  687. children: [
  688. {
  689. path: 'download',
  690. component: () => import('@/views/zip/index'),
  691. name: 'ExportZip',
  692. meta: { title: 'exportZip' }
  693. }
  694. ]
  695. },
  696. {
  697. path: '/pdf',
  698. component: Layout,
  699. redirect: '/pdf/index',
  700. children: [
  701. {
  702. path: 'index',
  703. component: () => import('@/views/pdf/index'),
  704. name: 'PDF',
  705. meta: { title: 'pdf', icon: 'pdf' }
  706. }
  707. ]
  708. },
  709. {
  710. path: '/pdf/download',
  711. component: () => import('@/views/pdf/download'),
  712. hidden: true
  713. },
  714. {
  715. path: '/theme',
  716. component: Layout,
  717. children: [
  718. {
  719. path: 'index',
  720. component: () => import('@/views/theme/index'),
  721. name: 'Theme',
  722. meta: { title: 'theme', icon: 'theme' }
  723. }
  724. ]
  725. },
  726. {
  727. path: '/clipboard',
  728. component: Layout,
  729. children: [
  730. {
  731. path: 'index',
  732. component: () => import('@/views/clipboard/index'),
  733. name: 'ClipboardDemo',
  734. meta: { title: 'clipboardDemo', icon: 'clipboard' }
  735. }
  736. ]
  737. },
  738. {
  739. path: '/i18n',
  740. component: Layout,
  741. children: [
  742. {
  743. path: 'index',
  744. component: () => import('@/views/i18n-demo/index'),
  745. name: 'I18n',
  746. meta: { title: 'i18n', icon: 'international' }
  747. }
  748. ]
  749. },
  750. {
  751. path: 'external-link',
  752. component: Layout,
  753. children: [
  754. {
  755. path: 'https://github.com/PanJiaChen/vue-element-admin',
  756. meta: { title: 'externalLink', icon: 'link' }
  757. }
  758. ]
  759. },
  760. // 404 page must be placed at the end !!!
  761. { path: '*', redirect: '/404', hidden: true }
  762. ]
  763. const createRouter = () => new Router({
  764. // mode: 'history', // require service support
  765. scrollBehavior: () => ({ y: 0 }),
  766. routes: constantRoutes
  767. })
  768. const router = createRouter()
  769. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  770. export function resetRouter() {
  771. const newRouter = createRouter()
  772. router.matcher = newRouter.matcher // reset router
  773. }
  774. export default router