index.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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. meta: {
  94. title: '返回',
  95. icon: 'dashboard',
  96. affix: true
  97. },
  98. },
  99. {
  100. path: 'swagger',
  101. component: () => import('@/views/tool/swagger/index.vue'),
  102. name: 'swagger',
  103. redirect: 'noredirect',
  104. meta: {
  105. title: '接口',
  106. icon: 'dashboard'
  107. },
  108. },
  109. {
  110. path: 'recent',
  111. component: () => import('@/views/biz/recent/index.vue'),
  112. name: 'recent',
  113. meta: {
  114. title: '最近文件',
  115. icon: 'dashboard'
  116. },
  117. },
  118. {
  119. path: '/search/:searchData/:searchText',
  120. component: () => import('@/views/search/index.vue'),
  121. name: 'search',
  122. meta: {
  123. title: '全文搜索',
  124. icon: 'dashboard'
  125. },
  126. },
  127. // {
  128. // path: "/myfile",
  129. // component: () => import("@/views/myfile/MyFile"),
  130. // name: "myfile",
  131. // meta: {
  132. // title: "我的文件",
  133. // icon: "myfile"
  134. // }
  135. // },
  136. {
  137. path: "/myfile",
  138. component: () => import("@/views/myfile/MyFile"),
  139. name: "myfile",
  140. meta: {
  141. title: "我的文件",
  142. icon: "myfile"
  143. },
  144. children: [{
  145. path: '/myfile:dirId(\\d+)',
  146. component: () => import('@/views/myfile/MyFile'),
  147. name: 'myfile',
  148. meta: {
  149. title: '我的文件',
  150. activeMenu: '/myfile'
  151. }
  152. }]
  153. },
  154. {
  155. path: "/myjoin",
  156. component: () => import("@/views/myjoin/MyJoin"),
  157. name: "myjoin",
  158. meta: {
  159. title: "我的协作",
  160. icon: "myjoin"
  161. }
  162. },
  163. // {
  164. // path: "/department",
  165. // component: () => import("@/views/department/MyFile"),
  166. // name: "department",
  167. // meta: {
  168. // title: "部门文件",
  169. // icon: "department"
  170. // }
  171. // },
  172. {
  173. path: "/department",
  174. component: () => import("@/views/department/MyFile"),
  175. name: "department",
  176. meta: {
  177. title: "部门文件",
  178. icon: "department"
  179. },
  180. children: [{
  181. path: '/department:dirId(\\d+)',
  182. component: () => import('@/views/department/MyFile'),
  183. name: 'department',
  184. meta: {
  185. title: '部门文件',
  186. activeMenu: '/department'
  187. }
  188. }]
  189. },
  190. // {
  191. // path: "/publicment",
  192. // component: () => import("@/views/publicment/MyFile"),
  193. // name: "publicment",
  194. // meta: {
  195. // title: "公共文件",
  196. // icon: "becommon"
  197. // }
  198. // },
  199. {
  200. path: "/publicment",
  201. component: () => import("@/views/publicment/MyFile"),
  202. name: "publicment",
  203. meta: {
  204. title: "公共文件",
  205. icon: "becommon"
  206. },
  207. children: [{
  208. path: '/publicment:dirId(\\d+)',
  209. component: () => import('@/views/publicment/MyFile'),
  210. name: 'publicment',
  211. meta: {
  212. title: '公共文件',
  213. activeMenu: '/publicment'
  214. }
  215. }]
  216. },
  217. {
  218. path: "/collect",
  219. component: () => import("@/views/collect/index.vue"),
  220. name: "collect",
  221. meta: {
  222. title: "收藏文件",
  223. icon: "department"
  224. }
  225. },
  226. {
  227. path: "/ws",
  228. component: () => import("@/views/biz/test/index.vue"),
  229. name: "ws",
  230. meta: {
  231. title: "聊天",
  232. icon: "department"
  233. }
  234. },
  235. {
  236. path: "/transFile",
  237. component: () => import("@/views/transFile/index.vue"),
  238. name: "transFile",
  239. meta: {
  240. title: "聊天",
  241. icon: "department"
  242. }
  243. },
  244. {
  245. path: "/highsearch",
  246. component: () => import("@/views/highSearch/HighSearch.vue"),
  247. name: "highsearch",
  248. meta: {
  249. title: "高级搜索",
  250. icon: "department"
  251. }
  252. }, {
  253. path: "/identifyFont",
  254. component: () => import("@/components/IdentifyFont/IdentifyFont.vue"),
  255. name: "identifyFont",
  256. meta: {
  257. title: "图文识别",
  258. icon: "department"
  259. }
  260. }, {
  261. path: "/iframe/*",
  262. component: () => import("@/layout/iframe.vue"),
  263. name: "iframe",
  264. meta: {
  265. title: "iframe",
  266. icon: "department"
  267. }
  268. }, {
  269. path: "/allback",
  270. component: () => import("@/views/highSearch/SupplierAllBack.vue"),
  271. name: "allback",
  272. meta: { title: "kongbaiye", icon: "department" }
  273. }, {
  274. path: "/admin",
  275. component: Layout,
  276. redirect: '/admin/index',
  277. children: [{
  278. path: 'index',
  279. // component: () => import('@/layout/index.vue'),
  280. name: 'adminIndex',
  281. meta: {
  282. title: '首页',
  283. icon: 'dashboard',
  284. affix: true
  285. },
  286. },]
  287. }
  288. ]
  289. },
  290. {
  291. path: '/admin',
  292. component: Layout,
  293. redirect: '/admin/index',
  294. children: [{
  295. path: 'index',
  296. // component: () => import('@/layout/index.vue'),
  297. name: 'adminIndex',
  298. meta: {
  299. title: '首页',
  300. icon: 'dashboard',
  301. affix: true
  302. },
  303. },
  304. // 其他 admin 下的子路由
  305. {
  306. path: '/onlyoffice/',
  307. component: () => import('@/views/biz/onlyoffice/index'),
  308. name: 'onlyoffice',
  309. meta: {
  310. title: '在线编辑',
  311. icon: 'dashboard'
  312. },
  313. hidden: true
  314. },
  315. ]
  316. },
  317. // {
  318. // path: '/file',
  319. // component: Layout,
  320. // redirect: '/index',
  321. // children: [
  322. // // {
  323. // // path: 'swagger',
  324. // // component: () => import('@/views/tool/swagger/index.vue'),
  325. // // name: 'swagger',
  326. // // meta: { title: '接口', icon: 'dashboard' },
  327. {
  328. path: '/file',
  329. component: Layout,
  330. redirect: '/index',
  331. children: [
  332. // {
  333. // path: 'swagger',
  334. // component: () => import('@/views/tool/swagger/index.vue'),
  335. // name: 'swagger',
  336. // meta: { title: '接口', icon: 'dashboard' },
  337. // },
  338. ]
  339. },
  340. // // },
  341. // // {
  342. // // path: "/myfile",
  343. // // component: () => import("@/views/myfile/MyFile"),
  344. // // name: "myfile",
  345. // // meta: { title: "我的文件", icon: "myfile" }
  346. // // },
  347. // // {
  348. // // path: "/department",
  349. // // component: () => import("@/views/department/Department"),
  350. // // name: "department",
  351. // // meta: { title: "部门文件", icon: "department" }
  352. // // }
  353. // ]
  354. // },
  355. {
  356. path: '/user',
  357. component: Layout,
  358. hidden: true,
  359. redirect: 'noredirect',
  360. children: [{
  361. path: 'profile',
  362. component: () => import('@/views/system/user/profile/index'),
  363. name: 'Profile',
  364. meta: {
  365. title: '个人中心',
  366. icon: 'user'
  367. }
  368. },]
  369. },
  370. // {
  371. // path: '/indexCommons',
  372. // hidden: true,
  373. // component: () => import('@/views/indexcommon/index'),
  374. // redirect: '/indexCommon',
  375. // children: [
  376. // {
  377. // path: '/indexCommon',
  378. // component: () => import('@/views/indexcommon/hhxx'),
  379. // name: 'Dashboard',
  380. // meta: { title: '会话消息', icon: 'dashboard', affix: true },
  381. // },
  382. // {
  383. // path: "/myfile",
  384. // component: () => import("@/views/myfile/MyFile"),
  385. // name: "myfile",
  386. // meta: { title: "我的文件", icon: "myfile" }
  387. // },
  388. // ]
  389. // },
  390. ]
  391. // 动态路由,基于用户权限动态去加载
  392. export const dynamicRoutes = [{
  393. path: '/system/user-auth',
  394. component: Layout,
  395. hidden: true,
  396. permissions: ['system:user:edit'],
  397. children: [{
  398. path: 'role/:userId(\\d+)',
  399. component: () => import('@/views/system/user/authRole'),
  400. name: 'AuthRole',
  401. meta: {
  402. title: '分配角色',
  403. activeMenu: '/system/user'
  404. }
  405. }]
  406. },
  407. {
  408. path: '/system/role-auth',
  409. component: Layout,
  410. hidden: true,
  411. permissions: ['system:role:edit'],
  412. children: [{
  413. path: 'user/:roleId(\\d+)',
  414. component: () => import('@/views/system/role/authUser'),
  415. name: 'AuthUser',
  416. meta: {
  417. title: '分配用户',
  418. activeMenu: '/system/role'
  419. }
  420. }]
  421. },
  422. {
  423. path: '/system/dict-data',
  424. component: Layout,
  425. hidden: true,
  426. permissions: ['system:dict:list'],
  427. children: [{
  428. path: 'index/:dictId(\\d+)',
  429. component: () => import('@/views/system/dict/data'),
  430. name: 'Data',
  431. meta: {
  432. title: '字典数据',
  433. activeMenu: '/system/dict'
  434. }
  435. }]
  436. },
  437. {
  438. path: '/monitor/job-log',
  439. component: Layout,
  440. hidden: true,
  441. permissions: ['monitor:job:list'],
  442. children: [{
  443. path: 'index/:jobId(\\d+)',
  444. component: () => import('@/views/monitor/job/log'),
  445. name: 'JobLog',
  446. meta: {
  447. title: '调度日志',
  448. activeMenu: '/monitor/job'
  449. }
  450. }]
  451. },
  452. {
  453. path: '/tool/gen-edit',
  454. component: Layout,
  455. hidden: true,
  456. permissions: ['tool:gen:edit'],
  457. children: [{
  458. path: 'index/:tableId(\\d+)',
  459. component: () => import('@/views/tool/gen/editTable'),
  460. name: 'GenEdit',
  461. meta: {
  462. title: '修改生成配置',
  463. activeMenu: '/tool/gen'
  464. }
  465. }]
  466. }
  467. ]
  468. const router = createRouter({
  469. history: createWebHistory(),
  470. routes: constantRoutes,
  471. scrollBehavior(to, from, savedPosition) {
  472. if (savedPosition) {
  473. return savedPosition
  474. } else {
  475. return {
  476. top: 0
  477. }
  478. }
  479. console.log(savedPosition, 'savedPosition');
  480. },
  481. });
  482. export default router;