设置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) // console.log("media",media)
const account = await get("account"); const account = await get("account");
try { try {
const data = await requireAPI("POST", `/api/feedback/create`, { const data = await requireAPI(
body: { "POST",
mid: account.mid, `/api/feedback/create`,
discription: value, {
credentials: media, body: {
mid: account.mid,
discription: value,
credentials: media,
},
}, },
}); false,
100000
);
if (data.ret === -1) { if (data.ret === -1) {
Toast.show({ Toast.show({
icon: "fail", icon: "fail",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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