index.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import {autoSaveAuth} from "@/api/AdminAuth"
  4. Vue.use(Router)
  5. /* Layout */
  6. import Layout from '@/layout'
  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',
  73. children: [
  74. {
  75. path: 'dashboard',
  76. component: () => import('@/views/dashboard/index'),
  77. name: 'Dashboard',
  78. meta: { title: '用户首页', icon: 'dashboards', affix: true }
  79. }
  80. ]
  81. },
  82. {
  83. path: '/profile',
  84. component: Layout,
  85. redirect: '/profile/index',
  86. hidden: true,
  87. children: [
  88. {
  89. path: 'index',
  90. component: () => import('@/views/profile/index'),
  91. name: 'Profile',
  92. meta: { title: 'Profile', icon: 'user', noCache: true }
  93. }
  94. ]
  95. },
  96. {
  97. path: '/document/create',
  98. component: () => import('@/views/document/create'),
  99. name: 'documentCreate',
  100. hidden:true,
  101. meta: { title: '创建文档', noCache: true }
  102. },
  103. {
  104. path: '/infoList',
  105. component: () => import('@/views/knowledgeMenu/category/infoList'),
  106. name: 'infoList',
  107. hidden:true,
  108. meta: { title: '解析块', noCache: true }
  109. },
  110. {
  111. path: '/ai',
  112. component: () => import('@/views/login/aiIndex.vue'),
  113. name: 'ai',
  114. hidden:true,
  115. meta: { title: 'ai', noCache: true }
  116. },
  117. {
  118. path: '/error',
  119. component: Layout,
  120. redirect: 'noRedirect',
  121. name: 'ErrorPages',
  122. hidden:true,
  123. meta: {
  124. title: 'Error Pages',
  125. icon: '404'
  126. },
  127. children: [
  128. {
  129. path: '401',
  130. component: () => import('@/views/error-page/401'),
  131. name: 'Page401',
  132. meta: { title: '401', noCache: true }
  133. },
  134. {
  135. path: '404',
  136. component: () => import('@/views/error-page/404'),
  137. name: 'Page404',
  138. meta: { title: '404', noCache: true }
  139. }
  140. ]
  141. }
  142. ]
  143. /**
  144. * asyncRoutes
  145. * the routes that need to be dynamically loaded based on user roles
  146. */
  147. export const asyncRoutes = [
  148. /* {
  149. path: '/project',
  150. component: Layout,
  151. type:1,
  152. meta: {
  153. title: '项目管理',
  154. icon: 'paizhao-01-20',
  155. roles: ['admin']
  156. },
  157. children: [
  158. {
  159. path: 'index',
  160. component: () => import('@/views/project/search'),
  161. name: 'project',
  162. meta: { title: '项目管理', noCache: true,roles: ['admin'] }
  163. },
  164. {
  165. path: 'category',
  166. component: () => import('@/views/project/category/search'),
  167. name: 'projectCategory',
  168. meta: { title: '项目分类', noCache: true ,roles: ['admin']}
  169. }
  170. ]
  171. }, */
  172. {
  173. path: '/customer',
  174. component: Layout,
  175. type:4,
  176. meta: {
  177. title: '客户管理',
  178. icon: 'kehus',
  179. roles: ['admin']
  180. },
  181. children: [
  182. {
  183. path: 'index',
  184. component: () => import('@/views/customer/search'),
  185. name: 'customerIndex',
  186. meta: { title: '客户管理', noCache: true,roles: ['admin'] }
  187. }
  188. ]
  189. },
  190. /* {
  191. path: '/product',
  192. component: Layout,
  193. type:5,
  194. meta: {
  195. title: '产品管理',
  196. icon: 'chanpin',
  197. roles: ['admin']
  198. },
  199. children: [
  200. {
  201. path: 'index',
  202. component: () => import('@/views/product/search'),
  203. name: 'product',
  204. meta: { title: '产品管理', noCache: true ,roles: ['admin']}
  205. },
  206. {
  207. path: 'category',
  208. component: () => import('@/views/product/category/search'),
  209. name: 'productCategory',
  210. meta: { title: '产品分类', noCache: true ,roles: ['admin']}
  211. },
  212. {
  213. path: '/supplier/search',
  214. component: () => import('@/views/product/supplier/search'),
  215. name: 'supplierSearch',
  216. meta: { title: '供应商管理', noCache: true ,roles: ['admin']}
  217. },
  218. {
  219. path: '/brand/search',
  220. component: () => import('@/views/product/brand/search'),
  221. name: 'brandSearch',
  222. meta: { title: '品牌设置', noCache: true ,roles: ['admin']}
  223. }
  224. ]
  225. }, */
  226. {
  227. path: '/document',
  228. component: Layout,
  229. type:10,
  230. meta: {
  231. title: '文档管理',
  232. icon: 'wendangs'
  233. },
  234. children: [
  235. {
  236. path: 'index',
  237. component: () => import('@/views/document/search'),
  238. name: 'documentSearch',
  239. meta: { title: '文档管理', noCache: true }
  240. },
  241. /* {
  242. path: 'new',
  243. redirect: '/document/create',
  244. target:"_blank",
  245. name:"createNewDocument",
  246. meta: { title: '创建文档', noCache: true,hidden:true }
  247. }, */
  248. {
  249. path: 'category/search',
  250. component: () => import('@/views/document/category/search'),
  251. name: 'documentCategory',
  252. meta: { title: '文档分类', noCache: true ,roles: ['admin']}
  253. },
  254. {
  255. path: 'temList',
  256. component: () => import('@/views/document/temList/temList'),
  257. name: 'documentTemList',
  258. meta: { title: '模板列表', noCache: true }
  259. },
  260. {
  261. path: '/template/category/search',
  262. component: () => import('@/views/template/category/search'),
  263. name: 'templateCategory',
  264. meta: { title: '模块分类', noCache: true ,roles: ['admin']}
  265. },
  266. {
  267. path: '/template/search',
  268. component: () => import('@/views/template/search'),
  269. name: 'template',
  270. meta: { title: '模块列表', noCache: true ,roles: ['admin']}
  271. },
  272. /*{
  273. path: 'dataCenter/index',
  274. component: () => import('@/views/dataCenter/search'),
  275. name: 'dataCenter',
  276. meta: { title: '原始数据', noCache: true,roles: ['admin'] }
  277. },
  278. {
  279. path: 'dataCenter/create',
  280. component: () => import('@/views/dataCenter/create'),
  281. name: 'dataCreate',
  282. hidden:true,
  283. meta: { title: '创建原始数据', noCache: true,roles: ['admin'] }
  284. },
  285. {
  286. path: 'dataCenter/info',
  287. component: () => import('@/views/dataCenter/dataView'),
  288. name: 'dataView',
  289. hidden:true,
  290. meta: { title: '预览数据', noCache: true,roles: ['admin'] }
  291. },
  292. {
  293. path: 'dataCenter/category/index',
  294. component: () => import('@/views/dataCenter/category/search'),
  295. name: 'dataCenterCategorySearch',
  296. meta: { title: '原始数据分类', noCache: true,roles: ['admin'] }
  297. }, */
  298. ]
  299. },
  300. {
  301. path: '/knowledge',
  302. component: Layout,
  303. type:32,
  304. meta: {
  305. title: '知识库',
  306. icon: 'zhisk',
  307. roles: ['admin']
  308. },
  309. children: [
  310. {
  311. path: 'knowledgeMenu/index',
  312. component: () => import('@/views/knowledgeMenu/knowledgeList.vue'),
  313. name: 'KBM\n',
  314. meta: { title: '知识库管理', noCache: true,roles: ['admin'] }
  315. },
  316. {
  317. path: 'category/knowledgeSet',
  318. component: () => import('@/views/knowledgeMenu/category/knowledgeSet'),
  319. name: 'KBM\n_setting',
  320. hidden:true,
  321. meta: { title: '知识库配置', noCache: true ,roles: ['admin']}
  322. },
  323. /* {
  324. path: 'category/infoList',
  325. component: () => import('@/views/knowledgeMenu/category/infoList'),
  326. name: 'KBM_info',
  327. hidden:true,
  328. meta: { title: '解析块', noCache: true ,roles: ['admin']}
  329. } */
  330. ]
  331. },
  332. {
  333. path: '/applet',
  334. component: Layout,
  335. type:37,
  336. meta: {
  337. title: '小程序管理',
  338. icon: 'applets',
  339. roles: ['admin']
  340. },
  341. children: [
  342. {
  343. path: 'index',
  344. component: () => import('@/views/applet/index'),
  345. name: 'miniProgram',
  346. meta: { title: '小程序管理', noCache: true,roles: ['admin'] }
  347. },
  348. {
  349. path: 'complaint',
  350. component: () => import('@/views/applet/complaint'),
  351. name: 'complaintAndAdvice',
  352. meta: { title: '投诉建议', noCache: true,roles: ['admin'] }
  353. },
  354. ]
  355. },
  356. {
  357. path: '/system',
  358. component: Layout,
  359. type:21,
  360. meta: {
  361. title: '系统设置',
  362. icon: '系统设置',
  363. roles: ['admin']
  364. },
  365. children: [
  366. {
  367. path: 'user/index',
  368. component: () => import('@/views/user/search'),
  369. name: 'user',
  370. meta: { title: '用户管理', noCache: true,roles: ['admin']}
  371. },
  372. {
  373. path: 'role/index',
  374. component: () => import('@/views/role/search'),
  375. name: 'role',
  376. meta: { title: '角色权限', noCache: true,roles: ['admin'] }
  377. },
  378. {
  379. path: 'role/create',
  380. component: () => import('@/views/role/create'),
  381. name: 'createRole',
  382. hidden:true,
  383. meta: { title: '创建角色', noCache: true,roles: ['admin'] }
  384. },
  385. {
  386. path: 'role/edit',
  387. component: () => import('@/views/role/edit'),
  388. name: 'editRole',
  389. hidden:true,
  390. meta: { title: '修改角色', noCache: true,roles: ['admin'] }
  391. },
  392. /* {
  393. path: 'auth/index',
  394. component: () => import('@/views/auth/search'),
  395. name: 'auth',
  396. meta: { title: '权限配置', noCache: true,roles: ['admin'] }
  397. }, */
  398. // {
  399. // path: 'flow/index',
  400. // component: () => import('@/views/flow/search'),
  401. // name: 'flow',
  402. // meta: { title: '流程设计', noCache: true,roles: ['admin'] }
  403. // },
  404. ]
  405. }
  406. ,
  407. { path: '*', redirect: '/404', hidden: true }
  408. ]
  409. const saveRoute=(route)=>{
  410. let items=route.filter(o=>o.children!=undefined);
  411. let routes=[];
  412. items=items.map(res=>{
  413. res.children.map((subRes)=>{
  414. routes.push({
  415. code:subRes.name,
  416. name:subRes.meta.title,
  417. type:res.type==undefined?0:res.type
  418. });
  419. });
  420. })
  421. /* autoSaveAuth({data:JSON.stringify(routes)}) */
  422. }
  423. saveRoute([...asyncRoutes]);
  424. const createRouter = () => new Router({
  425. mode: 'hash', // require service support
  426. scrollBehavior: () => ({ y: 0 }),
  427. routes: constantRoutes
  428. })
  429. const router = createRouter()
  430. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  431. export function resetRouter() {
  432. const newRouter = createRouter()
  433. router.matcher = newRouter.matcher // reset router
  434. }
  435. /* const createRouter = () => new Router({
  436. mode: 'history', // require service support
  437. scrollBehavior: () => ({ y: 0 }),
  438. routes: constantRoutes
  439. })
  440. const router = createRouter()
  441. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  442. export function resetRouter() {
  443. const newRouter = createRouter()
  444. router.matcher = newRouter.matcher // reset router
  445. } */
  446. export default router