From 75bc050fa1eed3615edd23fdff07a64509f76d3c Mon Sep 17 00:00:00 2001 From: al Date: Thu, 14 Nov 2024 18:11:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE100000ms=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=97=B6=E9=95=BF=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/my/setting/feedback/page.js | 18 +++++++++++------ .../completeStreamerInformation/page.jsx | 4 +++- .../joinStreamer/page.jsx | 3 ++- app/space/createImagePost/page.jsx | 12 ++++++++--- app/space/createVideoPost/page.jsx | 12 ++++++++--- app/space/editSpacePost/[zid]/page.jsx | 12 ++++++++--- .../editStreamerMedia/page.jsx | 3 ++- app/streamerPosts/createPost/page.jsx | 3 ++- utils/requireAPI.js | 20 ++++++++++++++----- 9 files changed, 63 insertions(+), 24 deletions(-) diff --git a/app/my/setting/feedback/page.js b/app/my/setting/feedback/page.js index a6c2bb2..15e68bb 100644 --- a/app/my/setting/feedback/page.js +++ b/app/my/setting/feedback/page.js @@ -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`, { - body: { - mid: account.mid, - discription: value, - credentials: media, + 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", diff --git a/app/my/streamerVerification/completeStreamerInformation/page.jsx b/app/my/streamerVerification/completeStreamerInformation/page.jsx index 684660b..1aed6a7 100644 --- a/app/my/streamerVerification/completeStreamerInformation/page.jsx +++ b/app/my/streamerVerification/completeStreamerInformation/page.jsx @@ -444,7 +444,9 @@ export default function CompleteStreamerInformation() { "/api/streamer_auth_approval/create_details", { body, - } + }, + false, + 100000 ); if (streamerData.ret === -1) { Toast.show({ diff --git a/app/my/streamerVerification/joinStreamer/page.jsx b/app/my/streamerVerification/joinStreamer/page.jsx index 8b69513..1d5a8f5 100644 --- a/app/my/streamerVerification/joinStreamer/page.jsx +++ b/app/my/streamerVerification/joinStreamer/page.jsx @@ -63,7 +63,8 @@ export default function JoinStreamer() { { body, }, - true + true, + 10000 ); if (streamerData.ret === -1) { Toast.show({ diff --git a/app/space/createImagePost/page.jsx b/app/space/createImagePost/page.jsx index 4f75f5a..c472a5b 100644 --- a/app/space/createImagePost/page.jsx +++ b/app/space/createImagePost/page.jsx @@ -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", { - body, - }); + const data = await requireAPI( + "POST", + "/api/zone_moment/create", + { + body, + }, + false, + 100000 + ); if (data.ret === -1) { Toast.show({ icon: "fail", diff --git a/app/space/createVideoPost/page.jsx b/app/space/createVideoPost/page.jsx index 35c37aa..ddeb6d2 100644 --- a/app/space/createVideoPost/page.jsx +++ b/app/space/createVideoPost/page.jsx @@ -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", { - body, - }); + const data = await requireAPI( + "POST", + "/api/zone_moment/create", + { + body, + }, + false, + 100000 + ); if (data.ret === -1) { Toast.show({ icon: "fail", diff --git a/app/space/editSpacePost/[zid]/page.jsx b/app/space/editSpacePost/[zid]/page.jsx index 3f5087e..83282d0 100644 --- a/app/space/editSpacePost/[zid]/page.jsx +++ b/app/space/editSpacePost/[zid]/page.jsx @@ -181,9 +181,15 @@ export default function EditSpacePost() { paid_text: isCreatingPaidText && price > 0 ? paidText : null, }; - const _data = await requireAPI("POST", "/api/zone_moment/update", { - body, - }); + const _data = await requireAPI( + "POST", + "/api/zone_moment/update", + { + body, + }, + false, + 100000 + ); if (_data.ret === -1) { Toast.show({ icon: "fail", diff --git a/app/space/setting/spaceIntroSetting/editStreamerMedia/page.jsx b/app/space/setting/spaceIntroSetting/editStreamerMedia/page.jsx index 2e65d9f..2cd232e 100644 --- a/app/space/setting/spaceIntroSetting/editStreamerMedia/page.jsx +++ b/app/space/setting/spaceIntroSetting/editStreamerMedia/page.jsx @@ -169,7 +169,8 @@ export default function EditStreamerMedia() { album: album, }, }, - true + true, + 100000 ); if (streamerData.ret === -1) { Toast.show({ diff --git a/app/streamerPosts/createPost/page.jsx b/app/streamerPosts/createPost/page.jsx index 3e206a0..0665ec8 100644 --- a/app/streamerPosts/createPost/page.jsx +++ b/app/streamerPosts/createPost/page.jsx @@ -89,7 +89,8 @@ export default function CreatePost() { { body, }, - true + true, + 100000 ); if (data.ret === -1) { Toast.show({ diff --git a/utils/requireAPI.js b/utils/requireAPI.js index d6f2946..05540af 100644 --- a/utils/requireAPI.js +++ b/utils/requireAPI.js @@ -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(() => { - controller.abort("Request timed out"); - }, 15000); + + let timeout = null; + if (timeoutValue) { + timeout = setTimeout(() => { + controller.abort("Request timed out"); + }, 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);