From 6f291d4155e26b10a13a28d059694e1c00ee2c99 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 23 Apr 2025 13:17:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=E6=94=AF=E6=8C=81=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E6=8F=90=E4=BA=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/wwwroot/modules/ajax.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/BootstrapBlazor/wwwroot/modules/ajax.js b/src/BootstrapBlazor/wwwroot/modules/ajax.js index 793d042c6b4..921e9dfbd29 100644 --- a/src/BootstrapBlazor/wwwroot/modules/ajax.js +++ b/src/BootstrapBlazor/wwwroot/modules/ajax.js @@ -4,6 +4,7 @@ url: null, data: null, toJson: true, + headers: { 'Content-Type': 'application/json; charset=utf-8' }, ...option } @@ -14,13 +15,19 @@ let result = null; try { - const { toJson, url, method, data } = option; + const { toJson, url, method, data, headers } = option; + if (headers['Content-Type'] === void 0) { + headers['Content-Type'] = 'application/json; charset=utf-8' + } + const contentType = headers['Content-Type']; + let postData = JSON.stringify(data); + if (contentType.indexOf('application/x-www-form-urlencoded') > -1) { + postData = new URLSearchParams(data).toString(); + } result = await fetch(url, { method: method, - headers: { - 'Content-Type': 'application/json' - }, - body: method === 'POST' ? JSON.stringify(data) : null + headers: headers, + body: postData }); if (toJson === true) { result = await result.json() From b304e7dca3541a0aaf69ab0c20bd8684e7f5493b Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 23 Apr 2025 13:21:06 +0800 Subject: [PATCH 2/2] chore: bump version 9.5.10 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index fe980211a17..d9e7de776b5 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@  - 9.5.9 + 9.5.10