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) {