index.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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: "/myfile",
  91. component: () => import("@/views/myfile/MyFile"),
  92. name: "myfile",
  93. meta: { title: "我的文件", icon: "myfile" }
  94. },
  95. {
  96. path: "/department",
  97. component: () => import("@/views/department/Department"),
  98. name: "department",
  99. meta: { title: "部门文件", icon: "department" }
  100. },
  101. {
  102. path: "/collect",
  103. component: () => import("@/views/collect/index.vue"),
  104. name: "collect",
  105. meta: { title: "收藏文件", icon: "department" }
  106. },
  107. {
  108. path: "/ws",
  109. component: () => import("@/views/biz/test/index.vue"),
  110. name: "ws",
  111. meta: { title: "聊天", icon: "department" }
  112. },
  113. {
  114. path: "/highsearch",
  115. component: () => import("@/views/highSearch/HighSearch.vue"),
  116. name: "highsearch",
  117. meta: { title: "高级搜索", icon: "department" }
  118. }
  119. ]
  120. },
  121. {
  122. path: '/admin',
  123. component:Layout,
  124. redirect: '/admin/index',
  125. children: [
  126. {
  127. path: 'index',
  128. // component: () => import('@/layout/index.vue'),
  129. name: 'adminIndex',
  130. meta: { title: '首页', icon: 'dashboard', affix: true },
  131. },
  132. // 其他 admin 下的子路由
  133. ]
  134. },
  135. // {
  136. // path: '/file',
  137. // component: Layout,
  138. // redirect: '/index',
  139. // children: [
  140. // // {
  141. // // path: 'swagger',
  142. // // component: () => import('@/views/tool/swagger/index.vue'),
  143. // // name: 'swagger',
  144. // // meta: { title: '接口', icon: 'dashboard' },
  145. {
  146. path: '/file',
  147. component: Layout,
  148. redirect: '/index',
  149. children: [
  150. // {
  151. // path: 'swagger',
  152. // component: () => import('@/views/tool/swagger/index.vue'),
  153. // name: 'swagger',
  154. // meta: { title: '接口', icon: 'dashboard' },
  155. // },
  156. ]
  157. },
  158. // // },
  159. // // {
  160. // // path: "/myfile",
  161. // // component: () => import("@/views/myfile/MyFile"),
  162. // // name: "myfile",
  163. // // meta: { title: "我的文件", icon: "myfile" }
  164. // // },
  165. // // {
  166. // // path: "/department",
  167. // // component: () => import("@/views/department/Department"),
  168. // // name: "department",
  169. // // meta: { title: "部门文件", icon: "department" }
  170. // // }
  171. // ]
  172. // },
  173. {
  174. path: '/user',
  175. component: Layout,
  176. hidden: true,
  177. redirect: 'noredirect',
  178. children: [
  179. {
  180. path: 'profile',
  181. component: () => import('@/views/system/user/profile/index'),
  182. name: 'Profile',
  183. meta: { title: '个人中心', icon: 'user' }
  184. },
  185. ]
  186. },
  187. // {
  188. // path: '/indexCommons',
  189. // hidden: true,
  190. // component: () => import('@/views/indexcommon/index'),
  191. // redirect: '/indexCommon',
  192. // children: [
  193. // {
  194. // path: '/indexCommon',
  195. // component: () => import('@/views/indexcommon/hhxx'),
  196. // name: 'Dashboard',
  197. // meta: { title: '会话消息', icon: 'dashboard', affix: true },
  198. // },
  199. // {
  200. // path: "/myfile",
  201. // component: () => import("@/views/myfile/MyFile"),
  202. // name: "myfile",
  203. // meta: { title: "我的文件", icon: "myfile" }
  204. // },
  205. // ]
  206. // },
  207. ]
  208. // 动态路由,基于用户权限动态去加载
  209. export const dynamicRoutes = [
  210. {
  211. path: '/system/user-auth',
  212. component: Layout,
  213. hidden: true,
  214. permissions: ['system:user:edit'],
  215. children: [
  216. {
  217. path: 'role/:userId(\\d+)',
  218. component: () => import('@/views/system/user/authRole'),
  219. name: 'AuthRole',
  220. meta: { title: '分配角色', activeMenu: '/system/user' }
  221. }
  222. ]
  223. },
  224. {
  225. path: '/system/role-auth',
  226. component: Layout,
  227. hidden: true,
  228. permissions: ['system:role:edit'],
  229. children: [
  230. {
  231. path: 'user/:roleId(\\d+)',
  232. component: () => import('@/views/system/role/authUser'),
  233. name: 'AuthUser',
  234. meta: { title: '分配用户', activeMenu: '/system/role' }
  235. }
  236. ]
  237. },
  238. {
  239. path: '/system/dict-data',
  240. component: Layout,
  241. hidden: true,
  242. permissions: ['system:dict:list'],
  243. children: [
  244. {
  245. path: 'index/:dictId(\\d+)',
  246. component: () => import('@/views/system/dict/data'),
  247. name: 'Data',
  248. meta: { title: '字典数据', activeMenu: '/system/dict' }
  249. }
  250. ]
  251. },
  252. {
  253. path: '/monitor/job-log',
  254. component: Layout,
  255. hidden: true,
  256. permissions: ['monitor:job:list'],
  257. children: [
  258. {
  259. path: 'index/:jobId(\\d+)',
  260. component: () => import('@/views/monitor/job/log'),
  261. name: 'JobLog',
  262. meta: { title: '调度日志', activeMenu: '/monitor/job' }
  263. }
  264. ]
  265. },
  266. {
  267. path: '/tool/gen-edit',
  268. component: Layout,
  269. hidden: true,
  270. permissions: ['tool:gen:edit'],
  271. children: [
  272. {
  273. path: 'index/:tableId(\\d+)',
  274. component: () => import('@/views/tool/gen/editTable'),
  275. name: 'GenEdit',
  276. meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
  277. }
  278. ]
  279. }
  280. ]
  281. const router = createRouter({
  282. history: createWebHistory(),
  283. routes: constantRoutes,
  284. scrollBehavior(to, from, savedPosition) {
  285. if (savedPosition) {
  286. return savedPosition
  287. } else {
  288. return { top: 0 }
  289. }
  290. console.log(savedPosition, 'savedPosition');
  291. },
  292. });
  293. export default router;