index.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. import { createWebHistory, createRouter } from 'vue-router'
  2. /* Layout */
  3. import Layout from '@/layout'
  4. import main from '@/layout/components/AppMain.vue'
  5. /**
  6. * Note: 路由配置项
  7. *
  8. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  9. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  10. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  11. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  12. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  13. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  14. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  15. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  16. * roles: ['admin', 'common'] // 访问路由的角色权限
  17. * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
  18. * meta : {
  19. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  20. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  21. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  22. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  23. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  24. }
  25. */
  26. // 公共路由
  27. export const constantRoutes = [
  28. {
  29. path: '/redirect',
  30. component: Layout,
  31. hidden: true,
  32. children: [
  33. {
  34. path: '/redirect/:path(.*)',
  35. component: () => import('@/views/redirect/index.vue')
  36. }
  37. ]
  38. },
  39. {
  40. path: '/login',
  41. component: () => import('@/views/login'),
  42. hidden: true
  43. },
  44. {
  45. path: '/register',
  46. component: () => import('@/views/register'),
  47. hidden: true
  48. },
  49. {
  50. path: "/:pathMatch(.*)*",
  51. component: () => import('@/views/error/404'),
  52. hidden: true
  53. },
  54. {
  55. path: '/401',
  56. component: () => import('@/views/error/401'),
  57. hidden: true
  58. },
  59. {
  60. path: '',
  61. component: () => import('@/layout/indexCommon.vue'),
  62. redirect: '/index',
  63. hidden:true,
  64. children: [
  65. {
  66. path: 'index',
  67. component: () => import('@/views/liveChat/index.vue'),
  68. name: 'index',
  69. meta: { title: '首页', icon: 'dashboard', affix: true }
  70. },
  71. {
  72. path:'swagger',
  73. component:() => import('@/views/tool/swagger/index.vue'),
  74. name:'swagger',
  75. meta:{ title:'接口',icon: 'dashboard' },
  76. },
  77. {
  78. path:'recent',
  79. component:() => import('@/views/biz/recent/index.vue'),
  80. name:'recent',
  81. meta:{ title:'最近文件',icon: 'dashboard' },
  82. },
  83. {
  84. path:'search',
  85. component:() => import('@/views/search/index.vue'),
  86. name:'search',
  87. meta:{ title:'全文搜索',icon: 'dashboard' },
  88. },
  89. {
  90. path: 'swagger',
  91. component: () => import('@/views/tool/swagger/index.vue'),
  92. name: 'swagger',
  93. meta: { title: '接口', icon: 'dashboard' },
  94. },
  95. {
  96. path: "/myfile",
  97. component: () => import("@/views/myfile/MyFile"),
  98. name: "myfile",
  99. meta: { title: "我的文件", icon: "myfile" }
  100. },
  101. {
  102. path: "/department",
  103. component: () => import("@/views/department/Department"),
  104. name: "department",
  105. meta: { title: "部门文件", icon: "department" }
  106. },
  107. {
  108. path: "/collect",
  109. component: () => import("@/views/collect/index.vue"),
  110. name: "collect",
  111. meta: { title: "收藏文件", icon: "department" }
  112. }
  113. ]
  114. },
  115. {
  116. path: '/admin',
  117. component:Layout,
  118. component: Layout,
  119. redirect: '/admin/index',
  120. children: [
  121. {
  122. path: 'index',
  123. // component: () => import('@/layout/index.vue'),
  124. name: 'adminIndex',
  125. meta: { title: '首页', icon: 'dashboard', affix: true },
  126. },
  127. // 其他 admin 下的子路由
  128. ]
  129. },
  130. // {
  131. // path: '/file',
  132. // component: Layout,
  133. // redirect: '/index',
  134. // children: [
  135. // // {
  136. // // path: 'swagger',
  137. // // component: () => import('@/views/tool/swagger/index.vue'),
  138. // // name: 'swagger',
  139. // // meta: { title: '接口', icon: 'dashboard' },
  140. {
  141. path: '/file',
  142. component: Layout,
  143. redirect: '/index',
  144. children: [
  145. // {
  146. // path: 'swagger',
  147. // component: () => import('@/views/tool/swagger/index.vue'),
  148. // name: 'swagger',
  149. // meta: { title: '接口', icon: 'dashboard' },
  150. // },
  151. ]
  152. },
  153. // // },
  154. // // {
  155. // // path: "/myfile",
  156. // // component: () => import("@/views/myfile/MyFile"),
  157. // // name: "myfile",
  158. // // meta: { title: "我的文件", icon: "myfile" }
  159. // // },
  160. // // {
  161. // // path: "/department",
  162. // // component: () => import("@/views/department/Department"),
  163. // // name: "department",
  164. // // meta: { title: "部门文件", icon: "department" }
  165. // // }
  166. // ]
  167. // },
  168. {
  169. path: '/user',
  170. component: Layout,
  171. hidden: true,
  172. redirect: 'noredirect',
  173. children: [
  174. {
  175. path: 'profile',
  176. component: () => import('@/views/system/user/profile/index'),
  177. name: 'Profile',
  178. meta: { title: '个人中心', icon: 'user' }
  179. },
  180. ]
  181. },
  182. // {
  183. // path: '/indexCommons',
  184. // hidden: true,
  185. // component: () => import('@/views/indexcommon/index'),
  186. // redirect: '/indexCommon',
  187. // children: [
  188. // {
  189. // path: '/indexCommon',
  190. // component: () => import('@/views/indexcommon/hhxx'),
  191. // name: 'Dashboard',
  192. // meta: { title: '会话消息', icon: 'dashboard', affix: true },
  193. // },
  194. // {
  195. // path: "/myfile",
  196. // component: () => import("@/views/myfile/MyFile"),
  197. // name: "myfile",
  198. // meta: { title: "我的文件", icon: "myfile" }
  199. // },
  200. // ]
  201. // },
  202. ]
  203. // 动态路由,基于用户权限动态去加载
  204. export const dynamicRoutes = [
  205. {
  206. path: '/system/user-auth',
  207. component: Layout,
  208. hidden: true,
  209. permissions: ['system:user:edit'],
  210. children: [
  211. {
  212. path: 'role/:userId(\\d+)',
  213. component: () => import('@/views/system/user/authRole'),
  214. name: 'AuthRole',
  215. meta: { title: '分配角色', activeMenu: '/system/user' }
  216. }
  217. ]
  218. },
  219. {
  220. path: '/system/role-auth',
  221. component: Layout,
  222. hidden: true,
  223. permissions: ['system:role:edit'],
  224. children: [
  225. {
  226. path: 'user/:roleId(\\d+)',
  227. component: () => import('@/views/system/role/authUser'),
  228. name: 'AuthUser',
  229. meta: { title: '分配用户', activeMenu: '/system/role' }
  230. }
  231. ]
  232. },
  233. {
  234. path: '/system/dict-data',
  235. component: Layout,
  236. hidden: true,
  237. permissions: ['system:dict:list'],
  238. children: [
  239. {
  240. path: 'index/:dictId(\\d+)',
  241. component: () => import('@/views/system/dict/data'),
  242. name: 'Data',
  243. meta: { title: '字典数据', activeMenu: '/system/dict' }
  244. }
  245. ]
  246. },
  247. {
  248. path: '/monitor/job-log',
  249. component: Layout,
  250. hidden: true,
  251. permissions: ['monitor:job:list'],
  252. children: [
  253. {
  254. path: 'index/:jobId(\\d+)',
  255. component: () => import('@/views/monitor/job/log'),
  256. name: 'JobLog',
  257. meta: { title: '调度日志', activeMenu: '/monitor/job' }
  258. }
  259. ]
  260. },
  261. {
  262. path: '/tool/gen-edit',
  263. component: Layout,
  264. hidden: true,
  265. permissions: ['tool:gen:edit'],
  266. children: [
  267. {
  268. path: 'index/:tableId(\\d+)',
  269. component: () => import('@/views/tool/gen/editTable'),
  270. name: 'GenEdit',
  271. meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
  272. }
  273. ]
  274. }
  275. ]
  276. const router = createRouter({
  277. history: createWebHistory(),
  278. routes: constantRoutes,
  279. scrollBehavior(to, from, savedPosition) {
  280. if (savedPosition) {
  281. return savedPosition
  282. } else {
  283. return { top: 0 }
  284. }
  285. console.log(savedPosition, 'savedPosition');
  286. },
  287. });
  288. export default router;