From c1f30546441504b0fc436d4273f3e365432f9618 Mon Sep 17 00:00:00 2001 From: hrh Date: Wed, 25 Sep 2024 18:36:22 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E7=8E=B0=E5=9C=A8=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E7=9A=84=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=E4=BC=9A?= =?UTF-8?q?=E9=9A=8F=E7=9D=80=E8=AF=B7=E6=B1=82=E4=BD=93=E5=A2=9E=E5=A4=A7?= =?UTF-8?q?=E8=80=8C=E5=A2=9E=E5=A4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 最小为6s - 每1MB请求体增加6s,向上取整 --- src/utils/utils.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 37531ab9..540453b2 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -61,10 +61,27 @@ export const requestGetJson = (() => { }; })(); +const calculateFormDataSize = (formData) => { + let totalSize = 0; + + for (const [_key, value] of formData.entries()) { + if (typeof value === 'string') { + // 计算字符串的字节大小 + totalSize += new TextEncoder().encode(value).length; + } else if (value instanceof File) { + // 对于文件,直接使用其 size 属性 + totalSize += value.size; + } + // 你可以根据需要处理其他类型 + } + + return Number((totalSize / 1024 / 1024).toFixed(2)); +}; + export const requestPostJson = (() => { let keys = {}; let promise = {}; - return (url, data, params, key) => { + return (url, formdata, params, key) => { if (!key) { key = url; } @@ -73,9 +90,10 @@ export const requestPostJson = (() => { promise[key] = axios({ url, method: 'post', - data, + formdata, params, - timeout: 5000 + // 1MB等6秒 单位ms + timeout: Math.ceil(calculateFormDataSize(formdata)) * 6000 }) .then((resolve) => { return [resolve, null]; From 07358ca97a0d4937b4c6338e7e20eef32cd4bc79 Mon Sep 17 00:00:00 2001 From: SkyBird233 <52884766+SkyBird233@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:40:23 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E5=89=AA=E8=B4=B4=E6=9D=BF=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E4=BD=93=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 540453b2..9eaa2bd3 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -90,7 +90,7 @@ export const requestPostJson = (() => { promise[key] = axios({ url, method: 'post', - formdata, + data: formdata, params, // 1MB等6秒 单位ms timeout: Math.ceil(calculateFormDataSize(formdata)) * 6000 From b78e017d6d5bed2cffa34e70cdca1dedc85ef760 Mon Sep 17 00:00:00 2001 From: SkyBird233 <52884766+SkyBird233@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:05:35 +0800 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20=E7=AE=80=E5=8C=96=E5=89=AA?= =?UTF-8?q?=E8=B4=B4=E6=9D=BF=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E8=A1=A8=E8=BE=BE=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 9eaa2bd3..9280a503 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -75,7 +75,7 @@ const calculateFormDataSize = (formData) => { // 你可以根据需要处理其他类型 } - return Number((totalSize / 1024 / 1024).toFixed(2)); + return totalSize / 1024 / 1024; }; export const requestPostJson = (() => { From 009082e452a4a1af37883f2d180dd6e2381d06cd Mon Sep 17 00:00:00 2001 From: hrh Date: Fri, 27 Sep 2024 11:55:28 +0800 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20=E7=AE=80=E5=8C=96=E5=89=AA?= =?UTF-8?q?=E8=B4=B4=E6=9D=BF=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E8=A1=A8=E8=BE=BE=E5=BC=8F=EF=BC=8CBToMB=20=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E7=94=A8=E6=B3=95=E6=9B=B4=E6=96=B0=EF=BC=8C=E6=9B=B4?= =?UTF-8?q?=E9=80=9A=E7=94=A8=E7=9A=84=E5=A4=84=E7=90=86=E8=BF=9B=E5=88=B6?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新引用了 BToMB 函数的代码入参 --- src/pages/aosc-os/AoscIndex.vue | 1 + src/pages/paste/PasteIndex.vue | 20 +------------------- src/utils/utils.js | 8 +++++--- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/pages/aosc-os/AoscIndex.vue b/src/pages/aosc-os/AoscIndex.vue index f543414d..8a7cc463 100644 --- a/src/pages/aosc-os/AoscIndex.vue +++ b/src/pages/aosc-os/AoscIndex.vue @@ -70,6 +70,7 @@ const docList = reactive([ url: '/' } */ ]); +