From 261d46eac05e3817711ce808babe3e3bdc4ca481 Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Wed, 21 May 2025 09:39:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(http):=20=E6=B7=BB=E5=8A=A0=20PUT=20?= =?UTF-8?q?=E5=92=8C=20DELETE=20=E8=AF=B7=E6=B1=82=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 `httpPut` 和 `httpDelete` 方法,以支持 PUT 和 DELETE 请求,完善 HTTP 工具的功能 --- src/utils/http.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/utils/http.ts b/src/utils/http.ts index d46535a..afa1eaf 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -84,6 +84,41 @@ export const httpPost = ( header, }) } +/** + * PUT 请求 + */ +export const httpPut = ( + url: string, + data?: Record, + query?: Record, + header?: Record, +) => { + return http({ + url, + data, + query, + method: 'PUT', + header, + }) +} + +/** + * DELETE 请求(无请求体,仅 query) + */ +export const httpDelete = ( + url: string, + query?: Record, + header?: Record, +) => { + return http({ + url, + query, + method: 'DELETE', + header, + }) +} http.get = httpGet http.post = httpPost +http.put = httpPut +http.delete = httpDelete