index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import AppIndex from '../views/home/AppIndex'
  4. import RouterView from '../views/home/RouterView'
  5. import {vaildJWT} from "../utils/service/jwt";
  6. import {getCookie, setCookie} from "../utils/service/cookie";
  7. Vue.use(Router)
  8. const defaultRouter = new Router({
  9. routes: [
  10. {
  11. path: '/index',
  12. name: 'AppIndex',
  13. component: AppIndex,
  14. children: [
  15. {
  16. path: '/home',
  17. name: 'Home',
  18. component: () => import('../views/homePage/Index'),
  19. meta: { title: '首页', icon: 'icon-menu icon-home', menuKey: "sy" },
  20. },
  21. {
  22. path: '/userManage',
  23. name: 'UserManage',
  24. component: RouterView,
  25. meta: { title: '用户管理', icon: 'icon-menu icon-yhgl', menuKey: "yhgl" },
  26. children: [
  27. {
  28. path: 'userList',
  29. name: 'UserList',
  30. component: () => import('../views/userManage/UserList'),
  31. meta: { title: '用户列表', menuKey: "yhlb" },
  32. },
  33. {
  34. path: 'userListDetail/:id',
  35. name: 'UserListDetail',
  36. component: () => import('../views/userManage/UserListDetail'),
  37. meta: { menuKey: "yhlb" },
  38. hidden: true
  39. },
  40. {
  41. path: 'userListEdit/:id',
  42. name: 'UserListEdit',
  43. component: () => import('../views/userManage/UserListDetail'),
  44. meta: { menuKey: "yhlb" },
  45. hidden: true
  46. },
  47. {
  48. path: 'userListAdd',
  49. name: 'UserListAdd',
  50. component: () => import('../views/userManage/UserListDetail'),
  51. meta: { menuKey: "yhlb" },
  52. hidden: true
  53. },
  54. {
  55. path: 'userApproval',
  56. name: 'UserApproval',
  57. component: () => import('../views/userManage/UserApproval'),
  58. meta: { title: '用户审批', menuKey: "yhsp" },
  59. hidden: true
  60. },
  61. {
  62. path: 'authManage',
  63. name: 'AuthManage',
  64. component: () => import('../views/userManage/AuthManage'),
  65. meta: { title: '权限管理', menuKey: "qxgl" },
  66. },
  67. {
  68. path: 'authManageAdd',
  69. name: 'AuthManageAdd',
  70. component: () => import('../views/userManage/AuthManageEdit'),
  71. meta: { menuKey: "qxgl" },
  72. hidden: true
  73. },
  74. {
  75. path: 'authManageDetail/:id',
  76. name: 'AuthManageDetail',
  77. component: () => import('../views/userManage/AuthManageEdit'),
  78. meta: { menuKey: "qxgl" },
  79. hidden: true
  80. },
  81. {
  82. path: 'authManageEdit/:id',
  83. name: 'AuthManageEdit',
  84. component: () => import('../views/userManage/AuthManageEdit'),
  85. meta: { menuKey: "qxgl" },
  86. hidden: true
  87. }
  88. ]
  89. },
  90. {
  91. path: '/logManage',
  92. name: 'LogManage',
  93. component: RouterView,
  94. meta: { title: '日志管理', icon: 'icon-menu icon-rzgl', menuKey: "rzgl" },
  95. children: [
  96. {
  97. path: 'userLoginLogs',
  98. name: 'UserLoginLogs',
  99. component: () => import('../views/logManage/UserLoginLogs'),
  100. meta: { title: '用户登录日志', menuKey: "yhdlrz" },
  101. },
  102. {
  103. path: 'sysOperationLog',
  104. name: 'SysOperationLog',
  105. component: () => import('../views/logManage/SysOperationLog'),
  106. meta: { title: '系统操作日志', menuKey: "xtczrz" },
  107. }
  108. ]
  109. },
  110. {
  111. path: '/sysConfigs',
  112. name: 'SysConfigs',
  113. component: RouterView,
  114. meta: { title: '系统设置', icon: 'icon-menu icon-xtsz', menuKey: "xtsz" },
  115. children: [
  116. {
  117. path: 'orgConfig',
  118. name: 'OrgConfig',
  119. component: () => import('../views/sysConfigs/OrgConfig'),
  120. meta: { title: '单位设置', menuKey: "dwsz" },
  121. },
  122. ]
  123. }
  124. ]
  125. },
  126. {
  127. path: '/',
  128. redirect: '/home',
  129. }
  130. ]
  131. })
  132. defaultRouter.beforeEach((to, from, next) => {
  133. // console.log("to:", to, "from:", from)
  134. vaildJWT(getCookie("m_token")).then(res=>{
  135. if (res.code==="200") {
  136. setCookie('name', res.data.name, 1)
  137. next()
  138. }else {
  139. window.open(
  140. `http://47.101.207.123:8080/platform-rk/#/login?url=http://47.101.207.123:8080/user_authentication/#/home`,
  141. "_self",
  142. "",
  143. true
  144. )
  145. // location.href = "http://47.101.207.123:8080/platform-rk/#/login?url=http://47.101.207.123:8080/user_authentication/#/home"
  146. }
  147. },error=>{
  148. window.open(
  149. `http://47.101.207.123:8080/platform-rk/#/login?url=http://47.101.207.123:8080/user_authentication/#/home`,
  150. "_self",
  151. "",
  152. true
  153. )
  154. // location.href = "http://47.101.207.123:8080/platform-rk/#/login?url=http://47.101.207.123:8080/user_authentication/#/home"
  155. })
  156. // next()
  157. })
  158. export default defaultRouter