feat(utils): 优化请求函数URL拼接逻辑

- 在request函数中将请求拦截改为先拼接完整URL
- 支持相对路径自动补全baseUrl
- 删除原有请求拦截中url未处理的问题
This commit is contained in:
2026-07-01 12:17:39 +08:00
parent e6c7ffa46c
commit 38c8026d4f

View File

@@ -289,8 +289,8 @@ const executeRequest = <T>(config: RequestConfig): Promise<T> => {
// 主请求函数 // 主请求函数
export async function request<T>(options: RequestConfig): Promise<T> { export async function request<T>(options: RequestConfig): Promise<T> {
try { try {
// 请求拦截 // 拼接完整URL相对路径自动补上 baseUrl
const config = requestInterceptor({ ...DEFAULT_CONFIG, ...options }); const config = requestInterceptor({ ...DEFAULT_CONFIG, ...options, url: buildUrl(options.url) });
// 执行请求(带重试) // 执行请求(带重试)
const result = await retryRequest<T>(config); const result = await retryRequest<T>(config);