mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-07 00:47:19 +08:00
perf: 优化接口类型
This commit is contained in:
parent
d6a329a63c
commit
a983575b6d
@ -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 });
|
||||
};
|
||||
|
@ -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 });
|
||||
};
|
||||
|
@ -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 });
|
||||
};
|
||||
|
@ -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");
|
||||
};
|
||||
|
||||
// 登录
|
||||
|
@ -19,10 +19,6 @@ defineOptions({
|
||||
name: "Amap"
|
||||
});
|
||||
|
||||
type resultType = {
|
||||
info: Array<undefined>;
|
||||
};
|
||||
|
||||
let MarkerCluster;
|
||||
let map: MapConfigureInter;
|
||||
|
||||
@ -96,8 +92,8 @@ onBeforeMount(() => {
|
||||
|
||||
// 获取模拟车辆信息
|
||||
mapJson()
|
||||
.then((res: resultType) => {
|
||||
let points: object = res.info.map((v: any) => {
|
||||
.then(({ info }) => {
|
||||
let points: object = info.map(v => {
|
||||
return {
|
||||
lnglat: [v.lng, v.lat],
|
||||
...v
|
||||
|
@ -1,8 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { useColumns } from "./columns";
|
||||
import { handleTree } from "@pureadmin/utils";
|
||||
import { getDeptList } from "/@/api/system";
|
||||
import { FormInstance } from "element-plus";
|
||||
import { handleTree } from "@pureadmin/utils";
|
||||
import { reactive, ref, onMounted } from "vue";
|
||||
import { TableProBar } from "/@/components/ReTable";
|
||||
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
|
||||
@ -37,7 +37,7 @@ function handleSelectionChange(val) {
|
||||
async function onSearch() {
|
||||
loading.value = true;
|
||||
let { data } = await getDeptList();
|
||||
dataList.value = handleTree(data);
|
||||
dataList.value = handleTree(data as any);
|
||||
setTimeout(() => {
|
||||
loading.value = false;
|
||||
}, 500);
|
||||
|
@ -64,7 +64,7 @@ watch(searchValue, val => {
|
||||
|
||||
onMounted(async () => {
|
||||
let { data } = await getDeptList();
|
||||
treeData.value = handleTree(data);
|
||||
treeData.value = handleTree(data as any);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user