|
@@ -23,7 +23,7 @@ import {
|
|
|
|
|
|
const error = throttle((msg: string) => ElMessage.error(msg), 2000);
|
|
const error = throttle((msg: string) => ElMessage.error(msg), 2000);
|
|
|
|
|
|
-type Other = { params?: Param; paths?: Param; useResult?: boolean };
|
|
|
|
|
|
+type Other = { params?: Param; paths?: Param; useResult?: boolean, noToken?: boolean };
|
|
export const sendFetch = <T>(
|
|
export const sendFetch = <T>(
|
|
url: string,
|
|
url: string,
|
|
init: RequestInit,
|
|
init: RequestInit,
|
|
@@ -41,6 +41,9 @@ export const sendFetch = <T>(
|
|
sendUrl =
|
|
sendUrl =
|
|
sendUrl + "?" + new URLSearchParams({ ...gParams, ...other.params });
|
|
sendUrl + "?" + new URLSearchParams({ ...gParams, ...other.params });
|
|
}
|
|
}
|
|
|
|
+ if (other.noToken) {
|
|
|
|
+ delete gHeaders.token
|
|
|
|
+ }
|
|
}
|
|
}
|
|
lifeHook.forEach(({ start }) => start());
|
|
lifeHook.forEach(({ start }) => start());
|
|
|
|
|
|
@@ -48,9 +51,9 @@ export const sendFetch = <T>(
|
|
...init,
|
|
...init,
|
|
headers: headers
|
|
headers: headers
|
|
? {
|
|
? {
|
|
- ...headers,
|
|
|
|
- ...gHeaders,
|
|
|
|
- }
|
|
|
|
|
|
+ ...headers,
|
|
|
|
+ ...gHeaders,
|
|
|
|
+ }
|
|
: gHeaders,
|
|
: gHeaders,
|
|
})
|
|
})
|
|
.then((res) => {
|
|
.then((res) => {
|
|
@@ -89,6 +92,13 @@ export const loginFetch = (props: LoginProps) =>
|
|
body: JSON.stringify(props),
|
|
body: JSON.stringify(props),
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ export const loginOutFetch = () =>
|
|
|
|
+ sendFetch<{ user: UserInfo; token: string }>(URL.logout, {
|
|
|
|
+ method: "post",
|
|
|
|
+ body: JSON.stringify({}),
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
export const userInfoFetch = () =>
|
|
export const userInfoFetch = () =>
|
|
sendFetch<UserInfo>(URL.getUserInfo, { method: "post" });
|
|
sendFetch<UserInfo>(URL.getUserInfo, { method: "post" });
|
|
|
|
|