From 02e4b92927472e8eb8536a6795674e0e8ea630d9 Mon Sep 17 00:00:00 2001 From: Kris <2893855659@qq.com> Date: Sat, 20 Jun 2026 22:17:45 +0800 Subject: [PATCH] feat(apis): add PATCH request related API functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增了通用PATCH请求API以及管理员、超管理员权限的PATCH请求封装函数,完善API请求方法覆盖范围 --- web/src/apis/base.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/web/src/apis/base.js b/web/src/apis/base.js index 9ee3cc8f..1df6aee4 100644 --- a/web/src/apis/base.js +++ b/web/src/apis/base.js @@ -225,6 +225,38 @@ export function apiSuperAdminPut(url, data = {}, options = {}, responseType = 'j return apiPut(url, data, options, true, responseType) } +/** + * 发送PATCH请求 + * @param {string} url - API端点 + * @param {Object} data - 请求体数据 + * @param {Object} options - 其他请求选项 + * @param {boolean} requiresAuth - 是否需要认证 + * @param {string} responseType - 响应类型: 'json' | 'text' | 'blob' + * @returns {Promise} - 请求结果 + */ +export function apiPatch(url, data = {}, options = {}, requiresAuth = true, responseType = 'json') { + return apiRequest( + url, + { + method: 'PATCH', + body: data instanceof FormData ? data : JSON.stringify(data), + ...options + }, + requiresAuth, + responseType + ) +} + +export function apiAdminPatch(url, data = {}, options = {}, responseType = 'json') { + checkAdminPermission() + return apiPatch(url, data, options, true, responseType) +} + +export function apiSuperAdminPatch(url, data = {}, options = {}, responseType = 'json') { + checkSuperAdminPermission() + return apiPatch(url, data, options, true, responseType) +} + /** * 发送DELETE请求 * @param {string} url - API端点