login.ts 728 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * @Author: fxs bjnsfxs@163.com
  3. * @Date: 2024-08-20 14:32:43
  4. * @LastEditors: fxs bjnsfxs@163.com
  5. * @LastEditTime: 2024-10-10 17:25:25
  6. * @FilePath: \Game-Backstage-Management-System\src\router\login.ts
  7. * @Description:
  8. *
  9. */
  10. import type {NavigationGuardNext, RouteLocationNormalized} from 'vue-router'
  11. import {getLoginState} from '@/utils/localStorage/localStorage'
  12. export default [
  13. {
  14. path: '/login',
  15. name: 'Login',
  16. component: () => import('@/views/Login/LoginView.vue'),
  17. beforeEnter: (
  18. _to: RouteLocationNormalized,
  19. _from: RouteLocationNormalized,
  20. next: NavigationGuardNext
  21. ) => {
  22. if (getLoginState()) {
  23. next('/')
  24. } else {
  25. next()
  26. }
  27. }
  28. }
  29. ]