index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. import {
  2. createWebHistory,
  3. createRouter
  4. } from 'vue-router'
  5. /* Layout */
  6. import Layout from '@/layout'
  7. import common from '@/views/myfile/components/FileEdit.vue'
  8. import main from '@/layout/components/AppMain.vue'
  9. /**
  10. * Note: 路由配置项
  11. *
  12. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  13. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  14. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  15. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  16. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  17. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  18. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  19. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  20. * roles: ['admin', 'common'] // 访问路由的角色权限
  21. * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
  22. * meta : {
  23. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  24. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  25. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  26. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  27. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  28. }
  29. */
  30. // 公共路由
  31. export const constantRoutes = [{
  32. path: '/redirect',
  33. component: Layout,
  34. hidden: true,
  35. children: [{
  36. path: '/redirect/:path(.*)',
  37. component: () => import('@/views/redirect/index.vue')
  38. }]
  39. },
  40. {
  41. path: '/login',
  42. component: () => import('@/views/login'),
  43. hidden: true
  44. },
  45. {
  46. path: '/register',
  47. component: () => import('@/views/register'),
  48. hidden: true
  49. },
  50. {
  51. path: "/:pathMatch(.*)*",
  52. component: () => import('@/views/error/404'),
  53. hidden: true
  54. },
  55. {
  56. path: '/401',
  57. component: () => import('@/views/error/401'),
  58. hidden: true
  59. }, {
  60. path: "/fileEdit",
  61. name: "fileEdit",
  62. // component: common,
  63. component: () => import("@/views/myfile/components/FileEdit.vue"),
  64. // children: [{
  65. // path: '/fileEdit:docId(\\d+)',
  66. // component: () => import("@/views/myfile/components/FileEdit.vue"),
  67. // name: 'fileEdit',
  68. // meta: {
  69. // title: '文件预览',
  70. // activeMenu: '/fileEdit'
  71. // }
  72. // }]
  73. },
  74. {
  75. path: '',
  76. component: () => import('@/layout/indexCommon.vue'),
  77. redirect: '/index',
  78. hidden: true,
  79. children: [{
  80. path: 'index',
  81. component: () => import('@/views/liveChat/index.vue'),
  82. name: 'index',
  83. meta: {
  84. title: '返回',
  85. icon: 'dashboard',
  86. affix: true
  87. },
  88. },
  89. {
  90. path: 'reindex',
  91. component: () => import('@/views/liveChat/index.vue'),
  92. name: 'reindex',
  93. },
  94. {
  95. path: '/user/profile',
  96. component: () => import('@/views/system/user/profile/index'),
  97. name: 'Profile',
  98. meta: {
  99. title: '个人中心',
  100. icon: 'user'
  101. }
  102. },
  103. {
  104. path: 'swagger',
  105. component: () => import('@/views/tool/swagger/index.vue'),
  106. name: 'swagger',
  107. redirect: 'noredirect',
  108. meta: {
  109. title: '接口',
  110. icon: 'dashboard'
  111. },
  112. },
  113. {
  114. path: 'recent',
  115. component: () => import('@/views/biz/recent/index.vue'),
  116. name: 'recent',
  117. meta: {
  118. title: '最近文件',
  119. icon: 'dashboard'
  120. },
  121. },
  122. {
  123. // path: '/search/:listArr/:searchText',
  124. path: '/search',
  125. component: () => import('@/views/search/index.vue'),
  126. name: 'search',
  127. props: true,
  128. meta: {
  129. title: '全文搜索',
  130. icon: 'dashboard'
  131. },
  132. // props: true
  133. },
  134. // {
  135. // path: "/myfile",
  136. // component: () => import("@/views/myfile/MyFile"),
  137. // name: "myfile",
  138. // meta: {
  139. // title: "我的文件",
  140. // icon: "myfile"
  141. // }
  142. // },
  143. {
  144. path: "/myfile",
  145. component: () => import("@/views/myfile/MyFile"),
  146. name: "myfile",
  147. meta: {
  148. title: "我的文件",
  149. icon: "myfile"
  150. },
  151. children: [{
  152. path: '/myfile:dirId(\\d+)',
  153. component: () => import('@/views/myfile/MyFile'),
  154. name: 'myfile',
  155. meta: {
  156. title: '我的文件',
  157. activeMenu: '/myfile'
  158. }
  159. }]
  160. },
  161. {
  162. path: "/myjoin",
  163. component: () => import("@/views/myjoin/MyJoin"),
  164. name: "myjoin",
  165. meta: {
  166. title: "我的协作",
  167. icon: "myjoin"
  168. }
  169. },
  170. // {
  171. // path: "/department",
  172. // component: () => import("@/views/department/MyFile"),
  173. // name: "department",
  174. // meta: {
  175. // title: "部门文件",
  176. // icon: "department"
  177. // }
  178. // },
  179. {
  180. path: "/department",
  181. component: () => import("@/views/department/MyFile"),
  182. name: "department",
  183. meta: {
  184. title: "部门文件",
  185. icon: "department"
  186. },
  187. children: [{
  188. path: '/department:dirId(\\d+)',
  189. component: () => import('@/views/department/MyFile'),
  190. name: 'department',
  191. meta: {
  192. title: '部门文件',
  193. activeMenu: '/department'
  194. }
  195. }]
  196. },
  197. // {
  198. // path: "/publicment",
  199. // component: () => import("@/views/publicment/MyFile"),
  200. // name: "publicment",
  201. // meta: {
  202. // title: "公共文件",
  203. // icon: "becommon"
  204. // }
  205. // },
  206. {
  207. path: "/publicment",
  208. component: () => import("@/views/publicment/MyFile"),
  209. name: "publicment",
  210. meta: {
  211. title: "公共文件",
  212. icon: "becommon"
  213. },
  214. children: [{
  215. path: '/publicment:dirId(\\d+)',
  216. component: () => import('@/views/publicment/MyFile'),
  217. name: 'publicment',
  218. meta: {
  219. title: '公共文件',
  220. activeMenu: '/publicment'
  221. }
  222. }]
  223. },
  224. {
  225. path: "/collect",
  226. component: () => import("@/views/collect/index.vue"),
  227. name: "collect",
  228. meta: {
  229. title: "收藏文件",
  230. icon: "department"
  231. }
  232. },
  233. {
  234. path: "/ws",
  235. component: () => import("@/views/biz/test/index.vue"),
  236. name: "ws",
  237. meta: {
  238. title: "聊天",
  239. icon: "department"
  240. }
  241. },
  242. {
  243. path: "/transFile",
  244. component: () => import("@/views/transFile/index.vue"),
  245. name: "transFile",
  246. meta: {
  247. title: "聊天",
  248. icon: "department"
  249. }
  250. },
  251. {
  252. path: "/highsearch",
  253. component: () => import("@/views/highSearch/HighSearch.vue"),
  254. name: "highsearch",
  255. meta: {
  256. title: "高级搜索",
  257. icon: "department"
  258. }
  259. }, {
  260. path: "/identifyFont",
  261. component: () => import("@/components/IdentifyFont/IdentifyFont.vue"),
  262. name: "identifyFont",
  263. meta: {
  264. title: "图文识别",
  265. icon: "department"
  266. }
  267. }, {
  268. path: "/iframe/*",
  269. component: () => import("@/layout/iframe.vue"),
  270. name: "iframe",
  271. meta: {
  272. title: "iframe",
  273. icon: "department"
  274. }
  275. }, {
  276. path: "/allback",
  277. component: () => import("@/views/highSearch/SupplierAllBack.vue"),
  278. name: "allback",
  279. meta: { title: "kongbaiye", icon: "department" }
  280. }, {
  281. path: "/admin",
  282. component: Layout,
  283. redirect: '/admin/index',
  284. children: [{
  285. path: 'index',
  286. // component: () => import('@/layout/index.vue'),
  287. name: 'adminIndex',
  288. meta: {
  289. title: '首页',
  290. icon: 'dashboard',
  291. affix: true
  292. },
  293. },]
  294. }
  295. ]
  296. },
  297. {
  298. path: '/admin',
  299. component: Layout,
  300. redirect: '/admin/index',
  301. children: [{
  302. path: 'index',
  303. // component: () => import('@/layout/index.vue'),
  304. name: 'adminIndex',
  305. meta: {
  306. title: '首页',
  307. icon: 'dashboard',
  308. affix: true
  309. },
  310. },
  311. // 其他 admin 下的子路由
  312. {
  313. path: '/onlyoffice/',
  314. component: () => import('@/views/biz/onlyoffice/index'),
  315. name: 'onlyoffice',
  316. meta: {
  317. title: '在线编辑',
  318. icon: 'dashboard'
  319. },
  320. hidden: true
  321. },
  322. ]
  323. },
  324. // {
  325. // path: '/file',
  326. // component: Layout,
  327. // redirect: '/index',
  328. // children: [
  329. // // {
  330. // // path: 'swagger',
  331. // // component: () => import('@/views/tool/swagger/index.vue'),
  332. // // name: 'swagger',
  333. // // meta: { title: '接口', icon: 'dashboard' },
  334. {
  335. path: '/file',
  336. component: Layout,
  337. redirect: '/index',
  338. children: [
  339. // {
  340. // path: 'swagger',
  341. // component: () => import('@/views/tool/swagger/index.vue'),
  342. // name: 'swagger',
  343. // meta: { title: '接口', icon: 'dashboard' },
  344. // },
  345. ]
  346. },
  347. // // },
  348. // // {
  349. // // path: "/myfile",
  350. // // component: () => import("@/views/myfile/MyFile"),
  351. // // name: "myfile",
  352. // // meta: { title: "我的文件", icon: "myfile" }
  353. // // },
  354. // // {
  355. // // path: "/department",
  356. // // component: () => import("@/views/department/Department"),
  357. // // name: "department",
  358. // // meta: { title: "部门文件", icon: "department" }
  359. // // }
  360. // ]
  361. // },
  362. // {
  363. // path: '/indexCommons',
  364. // hidden: true,
  365. // component: () => import('@/views/indexcommon/index'),
  366. // redirect: '/indexCommon',
  367. // children: [
  368. // {
  369. // path: '/indexCommon',
  370. // component: () => import('@/views/indexcommon/hhxx'),
  371. // name: 'Dashboard',
  372. // meta: { title: '会话消息', icon: 'dashboard', affix: true },
  373. // },
  374. // {
  375. // path: "/myfile",
  376. // component: () => import("@/views/myfile/MyFile"),
  377. // name: "myfile",
  378. // meta: { title: "我的文件", icon: "myfile" }
  379. // },
  380. // ]
  381. // },
  382. ]
  383. // 动态路由,基于用户权限动态去加载
  384. export const dynamicRoutes = [{
  385. path: '/system/user-auth',
  386. component: Layout,
  387. hidden: true,
  388. permissions: ['system:user:edit'],
  389. children: [{
  390. path: 'role/:userId(\\d+)',
  391. component: () => import('@/views/system/user/authRole'),
  392. name: 'AuthRole',
  393. meta: {
  394. title: '分配角色',
  395. activeMenu: '/system/user'
  396. }
  397. }]
  398. },
  399. {
  400. path: '/system/role-auth',
  401. component: Layout,
  402. hidden: true,
  403. permissions: ['system:role:edit'],
  404. children: [{
  405. path: 'user/:roleId(\\d+)',
  406. component: () => import('@/views/system/role/authUser'),
  407. name: 'AuthUser',
  408. meta: {
  409. title: '分配用户',
  410. activeMenu: '/system/role'
  411. }
  412. }]
  413. },
  414. {
  415. path: '/system/dict-data',
  416. component: Layout,
  417. hidden: true,
  418. permissions: ['system:dict:list'],
  419. children: [{
  420. path: 'index/:dictId(\\d+)',
  421. component: () => import('@/views/system/dict/data'),
  422. name: 'Data',
  423. meta: {
  424. title: '字典数据',
  425. activeMenu: '/system/dict'
  426. }
  427. }]
  428. },
  429. {
  430. path: '/monitor/job-log',
  431. component: Layout,
  432. hidden: true,
  433. permissions: ['monitor:job:list'],
  434. children: [{
  435. path: 'index/:jobId(\\d+)',
  436. component: () => import('@/views/monitor/job/log'),
  437. name: 'JobLog',
  438. meta: {
  439. title: '调度日志',
  440. activeMenu: '/monitor/job'
  441. }
  442. }]
  443. },
  444. {
  445. path: '/tool/gen-edit',
  446. component: Layout,
  447. hidden: true,
  448. permissions: ['tool:gen:edit'],
  449. children: [{
  450. path: 'index/:tableId(\\d+)',
  451. component: () => import('@/views/tool/gen/editTable'),
  452. name: 'GenEdit',
  453. meta: {
  454. title: '修改生成配置',
  455. activeMenu: '/tool/gen'
  456. }
  457. }]
  458. }
  459. ]
  460. const router = createRouter({
  461. history: createWebHistory(),
  462. routes: constantRoutes,
  463. scrollBehavior(to, from, savedPosition) {
  464. if (savedPosition) {
  465. return savedPosition
  466. } else {
  467. return {
  468. top: 0
  469. }
  470. }
  471. console.log(savedPosition, 'savedPosition');
  472. },
  473. });
  474. export default router;