Selaa lähdekoodia

refactor(api): 统一接口响应类型为AxiosResponse

yz 2 viikkoa sitten
vanhempi
commit
d73ba11300
2 muutettua tiedostoa jossa 42 lisäystä ja 16 poistoa
  1. 2 2
      src/api/forecast/forecast-summary.js
  2. 40 14
      src/types/global.d.ts

+ 2 - 2
src/api/forecast/forecast-summary.js

@@ -97,7 +97,7 @@ import request from '@/router/axios'
  * @param {number} [current=1] - 当前页码
  * @param {number} [size=10] - 每页数量
  * @param {ForecastSummaryQueryParams} [params={}] - 查询参数
- * @returns {Promise<ApiResponse<ForecastSummaryPageResponse>>} 预测汇总列表响应
+ * @returns {Promise<AxiosResponse<ForecastSummaryPageResponse>>} 预测汇总列表响应
  * @description 获取经销商销售预测汇总列表,支持多条件查询和分页
  * @example
  * // 获取第一页10条数据
@@ -127,7 +127,7 @@ export const getForecastSummaryList = async (current = 1, size = 10, params = {}
 /**
  * 获取预测汇总详情
  * @param {string|number} forecastSummaryId - 预测汇总ID
- * @returns {Promise<ApiResponse<ForecastSummaryItem>>} 预测汇总详情响应
+ * @returns {Promise<AxiosResponse<ForecastSummaryItem>>} 预测汇总详情响应
  * @description 根据ID获取预测汇总的详细信息
  * @example
  * const result = await getForecastSummaryDetail('1954819531796865026')

+ 40 - 14
src/types/global.d.ts

@@ -1,15 +1,41 @@
-declare interface AxiosResponse<T = any> {
-    data: T;
-    status: number;
-    statusText: string;
-    headers: {
-        [key: string]: string;
-        'content-type'?: string;
-    };
-    config: {
-        method?: string;
-        url?: string;
-        params?: Record<string, any>;
-        headers?: Record<string, any>;
-    };
+// types/global.d.ts
+declare global {
+    interface AxiosResponse<T = any> {
+        data: ApiResponseData<T>;
+        status: number;
+        statusText: string;
+        headers: {
+            [key: string]: string;
+            'content-type'?: string;
+        };
+        config: {
+            method?: string;
+            url?: string;
+            params?: Record<string, any>;
+            headers?: Record<string, any>;
+        };
+    }
+
+    interface ApiResponse<T = any> {
+        data: ApiResponseData<T>;
+        status: number;
+        statusText: string;
+        headers: {
+            [key: string]: string;
+            'content-type'?: string;
+        };
+        config: {
+            method?: string;
+            url?: string;
+            params?: Record<string, any>;
+            headers?: Record<string, any>;
+        };
+    }
+
+    interface ApiResponseData<T = any> {
+        code: number;
+        msg: string;
+        success: boolean;
+        data: T;
+    }
 }