lrf 1 year ago
parent
commit
e0e90f1791
3 changed files with 4 additions and 3 deletions
  1. 1 1
      src/router/guard.js
  2. 2 1
      src/router/index.js
  3. 1 1
      src/utils/checkResult.js

+ 1 - 1
src/router/guard.js

@@ -2,7 +2,7 @@ import { AxiosWrapper } from '@/utils/axios-wrapper'
 import { checkResult } from '@/utils/checkResult'
 import { UserStore } from '@/store/user'
 
-export const beforeRouter = (router) => {
+export const registerBeforeRouter = (router) => {
   router.beforeEach(async (to, from, next) => {
     const userStore = UserStore()
     const axios = new AxiosWrapper()

+ 2 - 1
src/router/index.js

@@ -1,4 +1,5 @@
 import { createRouter, createWebHistory } from 'vue-router'
+import { registerBeforeRouter } from './guard'
 export const homeIndex = () => import('@/views/home/index.vue')
 
 const router = createRouter({
@@ -24,5 +25,5 @@ const router = createRouter({
     }
   ]
 })
-
+registerBeforeRouter(router)
 export default router

+ 1 - 1
src/utils/checkResult.js

@@ -1,4 +1,4 @@
-import { isFunction, isString } from 'lodash'
+import { isFunction, isString } from 'lodash-es'
 import { ElMessage } from 'element-plus'
 export const checkResult = (res, okText, errText) => {
   const { errcode = 0, errmsg } = res || {}