|
@@ -91,7 +91,8 @@ export default {
|
|
|
if (toExpiresTime < 5*60 * 1000) {
|
|
|
this.getRefreshToken()
|
|
|
}else{
|
|
|
- this.$router.push({ path: "/mainPage" });
|
|
|
+ this.getUserInfo();
|
|
|
+ // this.$router.push({ path: "/mainPage" });
|
|
|
}
|
|
|
|
|
|
} else {
|
|
@@ -119,17 +120,41 @@ export default {
|
|
|
localStorage.setItem("refreshToken", refreshToken);
|
|
|
localStorage.setItem("expiresTime", expiresTime);
|
|
|
|
|
|
- this.$router.push({ path: "/mainPage" });
|
|
|
+ this.getUserInfo();
|
|
|
+ // this.$router.push({ path: "/mainPage" });
|
|
|
|
|
|
} else {
|
|
|
this.$message.error(res.message || "获取refresh_token失败");
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ getUserInfo() {
|
|
|
+ this.$axios({
|
|
|
+ method: "POST",
|
|
|
+ url: this.$api.common.getCurrentUserInfo,
|
|
|
+ data: {},
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.code == 200 && res.info) {
|
|
|
+ this.$store.commit("getUserId", res.info.id);
|
|
|
+ this.$store.commit("getUsername", res.info.username);
|
|
|
+ this.$store.commit("getRoleCode", res.info.roleCode);
|
|
|
+ this.$store.commit("getUseType", res.info.useType);
|
|
|
+
|
|
|
+ this.$router.push({ path: "/mainPage" });
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message || "获取用户信息失败");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
localStorage.clear();
|
|
|
+
|
|
|
+ this.$store.commit("getUserId", "");
|
|
|
+ this.$store.commit("getUsername", "");
|
|
|
+ this.$store.commit("getRoleCode", "");
|
|
|
+ this.$store.commit("getUseType","");
|
|
|
},
|
|
|
|
|
|
beforeRouteLeave (to, from, next) {
|