perf: 优化接口类型

This commit is contained in:
xiaoxian521
2022-08-18 18:35:09 +08:00
parent d6a329a63c
commit a983575b6d
7 changed files with 37 additions and 28 deletions

View File

@@ -1,12 +1,15 @@
import { http } from "../utils/http";
interface postType extends Promise<any> {
data?: object;
type Result = {
data?: {
/** 列表数据 */
list: Array<any>;
};
code?: number;
msg?: string;
}
};
// 卡片列表
export const getCardList = (data?: object): postType => {
return http.request("post", "/getCardList", { data });
export const getCardList = (data?: object) => {
return http.request<Result>("post", "/getCardList", { data });
};

View File

@@ -1,6 +1,11 @@
import { http } from "../utils/http";
type Result = {
code: number;
info: Array<any>;
};
// 地图数据
export const mapJson = (params?: object) => {
return http.request("get", "/getMapInfo", { params });
return http.request<Result>("get", "/getMapInfo", { params });
};

View File

@@ -1,22 +1,27 @@
import { http } from "../utils/http";
interface ResponseType extends Promise<any> {
data?: object;
type Result = {
data?: {
/** 列表数据 */
list: Array<any>;
/** 总数 */
total: number;
};
code?: number;
msg?: string;
}
};
// 获取用户管理列表
export const getUserList = (data?: object): ResponseType => {
return http.request("post", "/user", { data });
export const getUserList = (data?: object) => {
return http.request<Result>("post", "/user", { data });
};
// 获取角色管理列表
export const getRoleList = (data?: object): ResponseType => {
return http.request("post", "/role", { data });
export const getRoleList = (data?: object) => {
return http.request<Result>("post", "/role", { data });
};
// 获取部门管理列表
export const getDeptList = (data?: object): ResponseType => {
return http.request("post", "/dept", { data });
export const getDeptList = (data?: object) => {
return http.request<Result>("post", "/dept", { data });
};

View File

@@ -1,14 +1,14 @@
import { http } from "../utils/http";
interface userType extends Promise<any> {
type Result = {
svg?: string;
code?: number;
info?: object;
}
};
// 获取验证码
export const getVerify = (): userType => {
return http.request("get", "/captcha");
export const getVerify = () => {
return http.request<Result>("get", "/captcha");
};
// 登录