fix: upload size too large tip

This commit is contained in:
Tristan Yang
2022-12-15 19:38:21 +08:00
parent 3df055a248
commit 160e9678fe
3 changed files with 18 additions and 3 deletions
+9 -2
View File
@@ -4,6 +4,7 @@ import dayjs from "dayjs";
import { updateToken, resetAuthData } from "../slices/auth.data";
import BASE_URL, { tokenHeader } from "../config";
import { RootState } from "../store";
import { getLocalAuthData } from "../../common/utils";
const whiteList = [
"guestLogin",
@@ -43,8 +44,9 @@ const baseQueryWithTokenCheck = async (args, api, extraOptions) => {
if (waitingForRenew) {
await waitingForRenew;
}
// 先检查token是否过期,过期则renew
const { token, refreshToken, expireTime = +new Date() } = api.getState().authData;
// 先检查token是否过期,过期则renew [从localstorage取]
const { token, refreshToken, expireTime } = getLocalAuthData();
let result = null;
// console.log("base check", whiteList.includes(api.endpoint), api.endpoint);
if (!whiteList.includes(api.endpoint) && dayjs().isAfter(new Date(expireTime - 20 * 1000))) {
@@ -102,6 +104,11 @@ const baseQueryWithTokenCheck = async (args, api, extraOptions) => {
}
}
break;
case 413:
{
toast.error("File size too large");
}
break;
case 451:
{
// 证书错误