2213980799@qq.com hai 1 ano
pai
achega
98900506aa
Modificáronse 1 ficheiros con 18 adicións e 5 borrados
  1. 18 5
      src/router/index.js

+ 18 - 5
src/router/index.js

@@ -88,14 +88,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 });