index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. const Home = () => import('@/views/Home.vue')
  4. const register = ()=>import('@/views/register.vue')
  5. const login = ()=>import('@/views/Login.vue')
  6. const userinfo = ()=>import('@/views/userinfo.vue')
  7. const edit = ()=>import('@/views/Edit.vue')
  8. const article = ()=>import('@/views/Article.vue')
  9. const editcategory = ()=>import('@/views/EditCategory.vue')
  10. const workbench = ()=>import('@/views/workbench.vue')
  11. const cwAttendanceDec = ()=>import('@/views/cwAttendanceDec.vue')
  12. const user = ()=>import('@/views/user.vue')
  13. const leave = ()=>import('@/views/leave.vue')
  14. const approval = ()=>import('@/views/approval.vue')
  15. const details = ()=>import('@/views/details.vue')
  16. const record = ()=>import('@/views/record.vue')
  17. const ecord = ()=>import('@/views/ecord.vue')
  18. const ubmit = ()=>import('@/views/ubmit.vue')
  19. const lock = ()=>import('@/views/lock.vue')
  20. const ttendance = ()=>import('@/views/ttendance.vue')
  21. const set = ()=>import('@/views/set.vue')
  22. const number = ()=>import('@/views/number.vue')
  23. const assword = ()=>import('@/views/assword.vue')
  24. const nformation = ()=>import('@/views/nformation.vue')
  25. const ord = ()=>import('@/views/ord.vue')
  26. const proval = ()=>import('@/views/proval.vue')
  27. Vue.use(VueRouter)
  28. const routes = [
  29. {
  30. path:'/',
  31. component:Home,
  32. meta:{
  33. keepalive:true
  34. }
  35. },
  36. {
  37. path:'/home',
  38. component:Home,
  39. meta:{
  40. keepalive:true
  41. }
  42. },
  43. {
  44. path:'/register',
  45. component:register
  46. },
  47. {
  48. path:'/login',
  49. component:login
  50. },
  51. {
  52. path:'/userinfo',
  53. component:userinfo,
  54. meta:{
  55. istoken:true
  56. }
  57. },
  58. {
  59. path:'/user',
  60. component:user
  61. },
  62. {
  63. path:'/edit',
  64. component:edit,
  65. meta:{
  66. istoken:true
  67. }
  68. },
  69. {
  70. path:'/article/:id',
  71. component:article
  72. },
  73. {
  74. path:'/editcategory',
  75. component:editcategory
  76. },
  77. {
  78. path:'/workbench',
  79. component:workbench
  80. },
  81. {
  82. path:'/cwAttendanceDec',
  83. component:cwAttendanceDec
  84. },{
  85. path:'/leave',
  86. component:leave
  87. },
  88. {
  89. path:'/approval',
  90. component:approval
  91. },
  92. {
  93. path:'/details',
  94. component:details
  95. },
  96. {
  97. path:'/record',
  98. component:record
  99. },
  100. {
  101. path:'/ecord',
  102. component:ecord
  103. },
  104. {
  105. path:'/ubmit',
  106. component:ubmit
  107. },
  108. {
  109. path:'/lock',
  110. component:lock
  111. },
  112. {
  113. path:'/ttendance',
  114. component:ttendance
  115. },
  116. {
  117. path:'/set',
  118. component:set
  119. },
  120. {
  121. path:'/number',
  122. component:number
  123. },
  124. {
  125. path:'/assword',
  126. component:assword
  127. },
  128. {
  129. path:'/nformation',
  130. component:nformation
  131. },
  132. {
  133. path:'/ord',
  134. component:ord
  135. },
  136. {
  137. path:'/proval',
  138. component:proval
  139. }
  140. ]
  141. const router = new VueRouter({
  142. routes,
  143. mode:'history'
  144. })
  145. router.beforeEach((to,from,next) => {
  146. if((!localStorage.getItem('token') || !localStorage.getItem('id'))&&to.meta.istoken == true){
  147. router.push('/login')
  148. Vue.prototype.$msg.fail('请重新登录')
  149. return
  150. }
  151. next()
  152. })
  153. export default router