index.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. import { createWebHistory, createRouter, RouteRecordRaw } from 'vue-router';
  2. /* Layout */
  3. import Layout from '@/layout/index.vue';
  4. /**
  5. * Note: 路由配置项
  6. *
  7. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  8. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  9. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  10. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  11. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  12. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  13. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  14. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  15. * roles: ['admin', 'common'] // 访问路由的角色权限
  16. * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
  17. * meta : {
  18. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  19. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  20. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  21. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  22. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  23. }
  24. */
  25. // 公共路由
  26. export const constantRoutes: RouteRecordRaw[] = [
  27. {
  28. path: '/redirect',
  29. component: Layout,
  30. hidden: true,
  31. children: [
  32. {
  33. path: '/redirect/:path(.*)',
  34. component: () => import('@/views/redirect/index.vue')
  35. }
  36. ]
  37. },
  38. {
  39. path: '/social-callback',
  40. hidden: true,
  41. component: () => import('@/layout/components/SocialCallback/index.vue')
  42. },
  43. {
  44. path: '/login',
  45. component: () => import('@/views/login.vue'),
  46. hidden: true
  47. },
  48. {
  49. path: '/register',
  50. component: () => import('@/views/register.vue'),
  51. hidden: true
  52. },
  53. {
  54. path: '/:pathMatch(.*)*',
  55. component: () => import('@/views/error/404.vue'),
  56. hidden: true
  57. },
  58. {
  59. path: '/401',
  60. component: () => import('@/views/error/401.vue'),
  61. hidden: true
  62. },
  63. {
  64. path: '',
  65. component: Layout,
  66. redirect: '/index',
  67. children: [
  68. {
  69. path: '/index',
  70. component: () => import('@/views/index.vue'),
  71. name: 'Index',
  72. meta: { title: '首页', icon: 'dashboard', affix: true }
  73. }
  74. ]
  75. },
  76. {
  77. path: '/user',
  78. component: Layout,
  79. hidden: true,
  80. redirect: 'noredirect',
  81. children: [
  82. {
  83. path: 'profile',
  84. component: () => import('@/views/system/user/profile/index.vue'),
  85. name: 'Profile',
  86. meta: { title: '个人中心', icon: 'user' }
  87. }
  88. ]
  89. }
  90. ];
  91. // 动态路由,基于用户权限动态去加载
  92. export const dynamicRoutes: RouteRecordRaw[] = [
  93. {
  94. path: '/system',
  95. component: Layout,
  96. hidden: true,
  97. redirect: 'noredirect',
  98. name: 'System',
  99. meta: { title: '系统管理', icon: 'system' },
  100. children: [
  101. {
  102. path: 'user',
  103. component: () => import('@/views/system/user/index.vue'),
  104. name: 'SystemUser',
  105. meta: { title: '用户管理', icon: 'user', permissions: ['system:user:list'] }
  106. },
  107. {
  108. path: 'role',
  109. component: () => import('@/views/system/role/index.vue'),
  110. name: 'SystemRole',
  111. meta: { title: '角色管理', icon: 'peoples', permissions: ['system:role:list'] }
  112. },
  113. {
  114. path: 'menu',
  115. component: () => import('@/views/system/menu/index.vue'),
  116. name: 'SystemMenu',
  117. meta: { title: '菜单管理', icon: 'tree-table', permissions: ['system:menu:list'] }
  118. },
  119. {
  120. path: 'dept',
  121. component: () => import('@/views/system/dept/index.vue'),
  122. name: 'SystemDept',
  123. meta: { title: '部门管理', icon: 'tree', permissions: ['system:dept:list'] }
  124. },
  125. {
  126. path: 'post',
  127. component: () => import('@/views/system/post/index.vue'),
  128. name: 'SystemPost',
  129. meta: { title: '岗位管理', icon: 'post', permissions: ['system:post:list'] }
  130. },
  131. {
  132. path: 'dict',
  133. component: () => import('@/views/system/dict/index.vue'),
  134. name: 'SystemDict',
  135. meta: { title: '字典管理', icon: 'dict', permissions: ['system:dict:list'] }
  136. },
  137. {
  138. path: 'config',
  139. component: () => import('@/views/system/config/index.vue'),
  140. name: 'SystemConfig',
  141. meta: { title: '参数设置', icon: 'edit', permissions: ['system:config:list'] }
  142. },
  143. {
  144. path: 'notice',
  145. component: () => import('@/views/system/notice/index.vue'),
  146. name: 'SystemNotice',
  147. meta: { title: '通知公告', icon: 'message', permissions: ['system:notice:list'] }
  148. },
  149. {
  150. path: 'client',
  151. component: () => import('@/views/system/client/index.vue'),
  152. name: 'SystemClient',
  153. meta: { title: '客户端管理', icon: 'tab', permissions: ['system:client:list'] }
  154. },
  155. {
  156. path: 'oss',
  157. component: () => import('@/views/system/oss/index.vue'),
  158. name: 'SystemOss',
  159. meta: { title: '对象存储', icon: 'upload', permissions: ['system:oss:list'] }
  160. },
  161. {
  162. path: 'tenant',
  163. component: () => import('@/views/system/tenant/index.vue'),
  164. name: 'SystemTenant',
  165. meta: { title: '租户管理', icon: 'chart', permissions: ['system:tenant:list'] }
  166. }
  167. ]
  168. },
  169. {
  170. path: '/monitor',
  171. component: Layout,
  172. hidden: true,
  173. redirect: 'noredirect',
  174. name: 'Monitor',
  175. meta: { title: '系统监控', icon: 'monitor' },
  176. children: [
  177. {
  178. path: 'online',
  179. component: () => import('@/views/monitor/online/index.vue'),
  180. name: 'MonitorOnline',
  181. meta: { title: '在线用户', icon: 'online', permissions: ['monitor:online:list'] }
  182. },
  183. {
  184. path: 'operlog',
  185. component: () => import('@/views/monitor/operlog/index.vue'),
  186. name: 'MonitorOperlog',
  187. meta: { title: '操作日志', icon: 'form', permissions: ['monitor:operlog:list'] }
  188. },
  189. {
  190. path: 'logininfor',
  191. component: () => import('@/views/monitor/logininfor/index.vue'),
  192. name: 'MonitorLogininfor',
  193. meta: { title: '登录日志', icon: 'logininfor', permissions: ['monitor:logininfor:list'] }
  194. },
  195. {
  196. path: 'cache',
  197. component: () => import('@/views/monitor/cache/index.vue'),
  198. name: 'MonitorCache',
  199. meta: { title: '缓存监控', icon: 'redis', permissions: ['monitor:cache:list'] }
  200. },
  201. {
  202. path: 'snailjob',
  203. component: () => import('@/views/monitor/snailjob/index.vue'),
  204. name: 'MonitorSnailjob',
  205. meta: { title: '任务调度', icon: 'job', permissions: ['monitor:snailjob:list'] }
  206. },
  207. {
  208. path: 'admin',
  209. component: () => import('@/views/monitor/admin/index.vue'),
  210. name: 'MonitorAdmin',
  211. meta: { title: '服务监控', icon: 'server', permissions: ['monitor:admin:list'] }
  212. }
  213. ]
  214. },
  215. {
  216. path: 'tool',
  217. component: Layout,
  218. hidden: true,
  219. redirect: 'noredirect',
  220. name: 'Tool',
  221. meta: { title: '系统工具', icon: 'tool' },
  222. children: [
  223. {
  224. path: 'gen',
  225. component: () => import('@/views/tool/gen/index.vue'),
  226. name: 'ToolGen',
  227. meta: { title: '代码生成', icon: 'code', permissions: ['tool:gen:list'] }
  228. }
  229. ]
  230. },
  231. {
  232. path: 'demo',
  233. component: Layout,
  234. hidden: true,
  235. redirect: 'noredirect',
  236. name: 'Demo',
  237. meta: { title: '演示菜单', icon: 'star' },
  238. children: [
  239. {
  240. path: 'demo',
  241. component: () => import('@/views/demo/demo/index.vue'),
  242. name: 'DemoDemo',
  243. meta: { title: '演示单表', icon: 'build', permissions: ['demo:demo:list'] }
  244. },
  245. {
  246. path: 'tree',
  247. component: () => import('@/views/demo/tree/index.vue'),
  248. name: 'DemoTree',
  249. meta: { title: '演示树表', icon: 'tree-table', permissions: ['demo:tree:list'] }
  250. }
  251. ]
  252. },
  253. {
  254. path: '/risk',
  255. component: Layout,
  256. redirect: 'noredirect',
  257. name: 'Risk',
  258. meta: { title: '风控平台', icon: 'warning' },
  259. children: [
  260. {
  261. path: 'hiddenDanger',
  262. component: () => import('@/views/risk/hiddenDanger/index.vue'),
  263. name: 'RiskHiddenDanger',
  264. meta: { title: '安全隐患', icon: 'warning', permissions: ['risk:hiddenDanger:list'] }
  265. },
  266. {
  267. path: 'dangerSource',
  268. component: () => import('@/views/risk/dangerSource/index.vue'),
  269. name: 'RiskDangerSource',
  270. meta: { title: '危险源上报', icon: 'guide', permissions: ['risk:dangerSource:list'] }
  271. },
  272. {
  273. path: 'workReport',
  274. component: () => import('@/views/risk/workReport/index.vue'),
  275. name: 'RiskWorkReport',
  276. meta: { title: '作业上报', icon: 'documentation', permissions: ['risk:workReport:list'] }
  277. },
  278. {
  279. path: 'personnel',
  280. component: () => import('@/views/risk/personnel/index.vue'),
  281. name: 'RiskPersonnel',
  282. meta: { title: '人员信息', icon: 'peoples', permissions: ['risk:personnel:list'] }
  283. },
  284. {
  285. path: 'personnelChange',
  286. component: () => import('@/views/risk/personnelChange/index.vue'),
  287. name: 'RiskPersonnelChange',
  288. meta: { title: '审计工作', icon: 'log', permissions: ['risk:personnelChange:list'] }
  289. },
  290. {
  291. path: 'warning',
  292. component: () => import('@/views/risk/warning/index.vue'),
  293. name: 'RiskWarning',
  294. meta: { title: '风险警示', icon: 'message', permissions: ['risk:warning:list'] }
  295. },
  296. {
  297. path: 'specialEquipment',
  298. component: () => import('@/views/risk/specialEquipment/index.vue'),
  299. name: 'RiskSpecialEquipment',
  300. meta: { title: '特种设备', icon: 'tree', permissions: ['risk:specialEquipment:list'] }
  301. },
  302. {
  303. path: 'publicOpinion',
  304. component: () => import('@/views/risk/publicOpinion/index.vue'),
  305. name: 'RiskPublicOpinion',
  306. meta: { title: '舆情推送', icon: 'email', permissions: ['risk:publicOpinion:list'] }
  307. },
  308. {
  309. path: 'accident',
  310. component: () => import('@/views/risk/accident/index.vue'),
  311. name: 'RiskAccident',
  312. meta: { title: '事故上报', icon: 'bug', permissions: ['risk:accident:list'] }
  313. },
  314. {
  315. path: 'inspectionTask',
  316. component: () => import('@/views/risk/inspectionTask/index.vue'),
  317. name: 'RiskInspectionTask',
  318. meta: { title: '巡检任务', icon: 'list', permissions: ['risk:inspectionTask:list'] }
  319. },
  320. {
  321. path: 'qualityInspectionTask',
  322. component: () => import('@/views/risk/qualityInspectionTask/index.vue'),
  323. name: 'RiskQualityInspectionTask',
  324. meta: { title: '品控巡检', icon: 'list', permissions: ['risk:qualityInspectionTask:list'] }
  325. },
  326. {
  327. path: 'factoryVisit',
  328. component: () => import('@/views/risk/factoryVisit/index.vue'),
  329. name: 'RiskFactoryVisit',
  330. meta: { title: '品控访厂', icon: 'guide', permissions: ['risk:factoryVisit:list'] }
  331. },
  332. {
  333. path: 'bigScreen',
  334. component: () => import('@/views/risk/bigScreen/index.vue'),
  335. name: 'RiskBigScreen',
  336. meta: { title: '风控大屏', icon: 'data-board', permissions: ['risk:bigScreen:view'] }
  337. }
  338. ]
  339. }
  340. ];
  341. /**
  342. * 创建路由
  343. */
  344. const router = createRouter({
  345. history: createWebHistory(import.meta.env.VITE_APP_CONTEXT_PATH),
  346. routes: constantRoutes,
  347. // 刷新时,滚动条位置还原
  348. scrollBehavior(to, from, savedPosition) {
  349. if (savedPosition) {
  350. return savedPosition;
  351. }
  352. return { top: 0 };
  353. }
  354. });
  355. export default router;import { createWebHistory, createRouter, RouteRecordRaw } from 'vue-router';
  356. /* Layout */
  357. import Layout from '@/layout/index.vue';
  358. /**
  359. * Note: 路由配置项
  360. *
  361. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  362. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  363. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  364. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  365. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  366. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  367. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  368. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  369. * roles: ['admin', 'common'] // 访问路由的角色权限
  370. * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
  371. * meta : {
  372. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  373. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  374. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  375. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  376. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  377. }
  378. */
  379. // 公共路由