index.js 13 KB

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