import type { RequestResponse } from '@/types' import { absoluteLinkReg } from '@/utils/regular' import { notification } from 'antd' import { request as _request } from 'umi' type _Request = typeof _request export const request = (...args: Parameters<_Request>) => { let [url, options = {}] = args if (!url) { notification.warn({ message: '请求 url 错误', description: '未指定请求 url', }) } if (options?.method?.toUpperCase() === 'POST' && !options.data) { options.data = {} } // 请求地址为绝对路径取消前缀 if (absoluteLinkReg.test(url)) options.prefix = undefined return _request>(url, options) }