优化验证码 以及跳转部分

This commit is contained in:
lemon橪
2021-07-07 15:59:48 +08:00
parent 346eb13d50
commit 8f942bf01e
6 changed files with 58 additions and 55 deletions

View File

@@ -73,7 +73,7 @@ function cleanStorage() {
storage.setHasLogin(false);
storage.setAccessToken("");
storage.setRefreshToken("");
console.log("清空token")
console.log("清空token");
storage.setUuid("");
storage.setUserInfo({});
@@ -121,7 +121,7 @@ http.interceptors.request.use(
config.params = params;
config.header.accessToken = accessToken;
/**
* jwt 因为安卓以及ios没有window的属性
* window.atob这个函数 base64编码的使用方法就是btoa而用于解码的使用方法是atob
@@ -133,8 +133,11 @@ http.interceptors.request.use(
refresh();
} else {
if (
JSON.parse(atob(accessToken.split(".")[1].replace(/-/g, '+').replace(/_/g, '/'))).exp <
Math.round(new Date() / 1000)
JSON.parse(
atob(
accessToken.split(".")[1].replace(/-/g, "+").replace(/_/g, "/")
)
).exp < Math.round(new Date() / 1000)
) {
refresh();
}
@@ -144,6 +147,7 @@ http.interceptors.request.use(
...config.header,
uuid: storage.getUuid() || uuid.v1(),
};
console.log(config.header);
return config;
},
(config) => {
@@ -151,7 +155,6 @@ http.interceptors.request.use(
}
);
async function refresh() {
// 本地储存的是过期token了重新获取
const getTokenResult = await refreshToken();