2213980799@qq.com há 1 ano atrás
pai
commit
62f7abf103
1 ficheiros alterados com 17 adições e 6 exclusões
  1. 17 6
      src/router/index.js

+ 17 - 6
src/router/index.js

@@ -122,16 +122,27 @@ router.roleChange = ({ menus, homePath, authoritiesRouter }) => {
     router.addRoute(
       getMenuRoutes([...menus, ...authoritiesRouter], homePath)
     );
-
-    router.push({
-      path: menus[0].redirect || menus[0].path,
-    }).then(res => {
+    if (router.currentRoute.path == (menus[0].redirect || menus[0].path)) {
       changeRole({ groupId: store.state.user.info.currentGroupId, roleId: store.state.user.info.currentRoleId }).then(res => {
         setToken(res)
-        window.location.reload()
+        setTimeout(() => {
+          window.location.reload()
+        }, 100);
+      })
+    } else {
+      router.replace({
+        path: menus[0].redirect || menus[0].path,
+      }).then(res => {
+        changeRole({ groupId: store.state.user.info.currentGroupId, roleId: store.state.user.info.currentRoleId }).then(res => {
+          setToken(res)
+          setTimeout(() => {
+            window.location.reload()
+          }, 100);
+        })
+
       })
+    }
 
-    })
   }
 
   // next({ ...to, replace: true });