设置100000ms请求时长监听

This commit is contained in:
al 2024-11-14 18:11:09 +08:00
parent ad5881a987
commit 75bc050fa1
9 changed files with 63 additions and 24 deletions

View File

@ -32,13 +32,19 @@ export default function Feedback() {
// console.log("media",media)
const account = await get("account");
try {
const data = await requireAPI("POST", `/api/feedback/create`, {
const data = await requireAPI(
"POST",
`/api/feedback/create`,
{
body: {
mid: account.mid,
discription: value,
credentials: media,
},
});
},
false,
100000
);
if (data.ret === -1) {
Toast.show({
icon: "fail",

View File

@ -444,7 +444,9 @@ export default function CompleteStreamerInformation() {
"/api/streamer_auth_approval/create_details",
{
body,
}
},
false,
100000
);
if (streamerData.ret === -1) {
Toast.show({

View File

@ -63,7 +63,8 @@ export default function JoinStreamer() {
{
body,
},
true
true,
10000
);
if (streamerData.ret === -1) {
Toast.show({

View File

@ -173,9 +173,15 @@ export default function CreateImagePost() {
is_creating_paid_text: isCreatingPaidText && price > 0 ? 1 : 0,
paid_text: isCreatingPaidText && price > 0 ? paidText : null,
};
const data = await requireAPI("POST", "/api/zone_moment/create", {
const data = await requireAPI(
"POST",
"/api/zone_moment/create",
{
body,
});
},
false,
100000
);
if (data.ret === -1) {
Toast.show({
icon: "fail",

View File

@ -144,9 +144,15 @@ export default function CreateVideoPost() {
is_creating_paid_text: isCreatingPaidText && price > 0 ? 1 : 0,
paid_text: isCreatingPaidText && price > 0 ? paidText : null,
};
const data = await requireAPI("POST", "/api/zone_moment/create", {
const data = await requireAPI(
"POST",
"/api/zone_moment/create",
{
body,
});
},
false,
100000
);
if (data.ret === -1) {
Toast.show({
icon: "fail",

View File

@ -181,9 +181,15 @@ export default function EditSpacePost() {
paid_text: isCreatingPaidText && price > 0 ? paidText : null,
};
const _data = await requireAPI("POST", "/api/zone_moment/update", {
const _data = await requireAPI(
"POST",
"/api/zone_moment/update",
{
body,
});
},
false,
100000
);
if (_data.ret === -1) {
Toast.show({
icon: "fail",

View File

@ -169,7 +169,8 @@ export default function EditStreamerMedia() {
album: album,
},
},
true
true,
100000
);
if (streamerData.ret === -1) {
Toast.show({

View File

@ -89,7 +89,8 @@ export default function CreatePost() {
{
body,
},
true
true,
100000
);
if (data.ret === -1) {
Toast.show({

View File

@ -5,14 +5,24 @@ import { Toast } from "antd-mobile";
// import webviewBaseRequest from "@/utils/webviewBaseRequest";
// 创建一个封装 fetch 的函数
export default function customFetch(method, url, options = {}, needMid) {
export default function customFetch(
method,
url,
options = {},
needMid,
timeoutValue = 0
) {
const controller = new AbortController();
const signal = controller.signal;
// 设置超时
const timeout = setTimeout(() => {
let timeout = null;
if (timeoutValue) {
timeout = setTimeout(() => {
controller.abort("Request timed out");
}, 15000);
}, timeoutValue);
}
const base = baseRequest();
// 默认选项
const defaultOptions = {
@ -41,7 +51,7 @@ export default function customFetch(method, url, options = {}, needMid) {
return new Promise((resolve, reject) => {
fetch(url, mergedOptions)
.then((response) => {
clearTimeout(timeout);
if (timeout) clearTimeout(timeout);
// // 检查响应状态码
if (!response.ok) {
throw new Error("Network response was not ok " + response.statusText);