From 967accfd48300579d2538f72edfce761ca2ebfa3 Mon Sep 17 00:00:00 2001 From: "Ray.Hao" <1490493387@qq.com> Date: Sat, 10 Jan 2026 10:50:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor(api):=20:recycle:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E9=A1=B5=E8=AF=B7=E6=B1=82=E5=92=8C?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .stylelintrc.json | 2 +- src/api/user.ts | 9 ++++++--- src/utils/request.ts | 6 +++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.stylelintrc.json b/.stylelintrc.json index 856b1ab..a0e96a5 100644 --- a/.stylelintrc.json +++ b/.stylelintrc.json @@ -9,7 +9,7 @@ "plugins": ["stylelint-prettier"], "overrides": [ { - "files": ["**/*.{vue,html}"], + "files": ["**/*.{vue,html}"], "customSyntax": "postcss-html" }, { diff --git a/src/api/user.ts b/src/api/user.ts index 5167973..63ce38a 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -21,11 +21,14 @@ const UserAPI = { * @param queryParams 查询参数 */ getPage(queryParams: UserPageQuery) { - return request>({ - url: `${USER_BASE_URL}/page`, + return request({ + url: `${USER_BASE_URL}`, method: "GET", data: queryParams, - }); + }).then((res: { data: UserPageVO[]; page?: { total?: number } }) => ({ + list: res.data, + total: res.page?.total ?? 0, + })); }, /** * 添加用户 diff --git a/src/utils/request.ts b/src/utils/request.ts index d9e1e05..fc088ac 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -54,7 +54,11 @@ function request(options: RequestOptions): Promise { success: (res: any) => { // 请求成功 if (res.statusCode >= 200 && res.statusCode < 300) { - resolve(res.data.data); + if (res.data && typeof res.data === "object" && "page" in res.data && res.data.page != null) { + resolve({ data: res.data.data, page: res.data.page } as any); + } else { + resolve(res.data.data); + } } // 未授权错误 else if (res.statusCode === 401) {