refactor: lots updates

This commit is contained in:
zerosoul
2022-03-14 11:32:00 +08:00
parent 5d363b5a5f
commit 46cfda76d0
83 changed files with 2018 additions and 1486 deletions
+16 -10
View File
@@ -1,9 +1,15 @@
import { fetchBaseQuery } from "@reduxjs/toolkit/query";
import toast from "react-hot-toast";
import dayjs from "dayjs";
import { updateToken, clearAuthData } from "../slices/auth.data";
import { updateToken, resetAuthData } from "../slices/auth.data";
import BASE_URL, { tokenHeader } from "../config";
const whiteList = ["login", "checkInviteTokenValid", "getServer", "getOpenid"];
const whiteList = [
"login",
"checkInviteTokenValid",
"getServer",
"getOpenid",
"getMetamaskNonce",
];
const baseQuery = fetchBaseQuery({
baseUrl: BASE_URL,
prepareHeaders: (headers, { getState, endpoint }) => {
@@ -72,14 +78,14 @@ const baseQueryWithTokenCheck = async (args, api, extraOptions) => {
break;
case 401:
{
if (api.endpoint === "renew") {
// toast.error("token expired, please login again");
api.dispatch(clearAuthData());
location.href = "/#/login";
return;
} else {
toast.error("Not Authenticated");
}
// if (api.endpoint === "renew") {
// toast.error("token expired, please login again");
api.dispatch(resetAuthData());
location.href = "/#/login";
// } else {
toast.error("API Not Authenticated");
return;
// }
}
break;
case 403: