From fcc3daf90469611ecea3f92851466223d37e3f1b Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Mon, 19 Jan 2026 19:15:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor(http):=20=E7=BB=9F=E4=B8=80HTTP?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=91=BD=E5=90=8D=E5=B9=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8F=90=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将大写的HTTP方法改为小写命名以提高一致性 添加带消息提示的HTTP方法变体 --- apps/web-antd/src/utils/http/index.ts | 24 ++++++++++++++++++++---- apps/web-antd/types/alova.d.ts | 13 +++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/apps/web-antd/src/utils/http/index.ts b/apps/web-antd/src/utils/http/index.ts index 6cc3898d..494eba68 100644 --- a/apps/web-antd/src/utils/http/index.ts +++ b/apps/web-antd/src/utils/http/index.ts @@ -326,11 +326,27 @@ const alovaInstance = createAlova({ }, }); +alovaInstance.get = function (url, options) { + return this.Get(url, options); +}; + +alovaInstance.post = function (url, data, config) { + return this.Post(url, data, config); +}; + +alovaInstance.put = function (url, data, config) { + return this.Put(url, data, config); +}; + +alovaInstance.delete = function (url, data, config) { + return this.Delete(url, data, config); +}; + /** 提供xxWithMessage方法,用于请求成功后弹出提示 */ -alovaInstance.GetWithMessage = function (url, options) { +alovaInstance.getWithMsg = function (url, options) { return this.Get(url, { ...options, meta: { @@ -340,7 +356,7 @@ alovaInstance.GetWithMessage = function (url, options) { }); }; -alovaInstance.PostWithMessage = function (url, data, config) { +alovaInstance.postWithMsg = function (url, data, config) { return this.Post(url, data, { ...config, meta: { @@ -350,7 +366,7 @@ alovaInstance.PostWithMessage = function (url, data, config) { }); }; -alovaInstance.PutWithMessage = function (url, data, config) { +alovaInstance.putWithMsg = function (url, data, config) { return this.Put(url, data, { ...config, meta: { @@ -360,7 +376,7 @@ alovaInstance.PutWithMessage = function (url, data, config) { }); }; -alovaInstance.DeleteWithMessage = function (url, data, config) { +alovaInstance.deleteWithMsg = function (url, data, config) { return this.Delete(url, data, { ...config, meta: { diff --git a/apps/web-antd/types/alova.d.ts b/apps/web-antd/types/alova.d.ts index 4ce64688..a5bd4d55 100644 --- a/apps/web-antd/types/alova.d.ts +++ b/apps/web-antd/types/alova.d.ts @@ -49,10 +49,15 @@ declare module 'alova' { * 添加withMessage方法 用于success弹窗 */ interface Alova { - GetWithMessage: GetType; - PostWithMessage: PostType; - PutWithMessage: PutType; - DeleteWithMessage: DeleteType; + get: GetType; + post: PostType; + put: PutType; + delete: DeleteType; + // 添加withMessage方法 用于弹出message提示 + getWithMsg: GetType; + postWithMsg: PostType; + putWithMsg: PutType; + deleteWithMsg: DeleteType; } }