mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 01:17:23 +08:00
perf: 优化接口类型
This commit is contained in:
parent
d6a329a63c
commit
a983575b6d
@ -1,12 +1,15 @@
|
|||||||
import { http } from "../utils/http";
|
import { http } from "../utils/http";
|
||||||
|
|
||||||
interface postType extends Promise<any> {
|
type Result = {
|
||||||
data?: object;
|
data?: {
|
||||||
|
/** 列表数据 */
|
||||||
|
list: Array<any>;
|
||||||
|
};
|
||||||
code?: number;
|
code?: number;
|
||||||
msg?: string;
|
msg?: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
// 卡片列表
|
// 卡片列表
|
||||||
export const getCardList = (data?: object): postType => {
|
export const getCardList = (data?: object) => {
|
||||||
return http.request("post", "/getCardList", { data });
|
return http.request<Result>("post", "/getCardList", { data });
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
import { http } from "../utils/http";
|
import { http } from "../utils/http";
|
||||||
|
|
||||||
|
type Result = {
|
||||||
|
code: number;
|
||||||
|
info: Array<any>;
|
||||||
|
};
|
||||||
|
|
||||||
// 地图数据
|
// 地图数据
|
||||||
export const mapJson = (params?: object) => {
|
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";
|
import { http } from "../utils/http";
|
||||||
|
|
||||||
interface ResponseType extends Promise<any> {
|
type Result = {
|
||||||
data?: object;
|
data?: {
|
||||||
|
/** 列表数据 */
|
||||||
|
list: Array<any>;
|
||||||
|
/** 总数 */
|
||||||
|
total: number;
|
||||||
|
};
|
||||||
code?: number;
|
code?: number;
|
||||||
msg?: string;
|
msg?: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
// 获取用户管理列表
|
// 获取用户管理列表
|
||||||
export const getUserList = (data?: object): ResponseType => {
|
export const getUserList = (data?: object) => {
|
||||||
return http.request("post", "/user", { data });
|
return http.request<Result>("post", "/user", { data });
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取角色管理列表
|
// 获取角色管理列表
|
||||||
export const getRoleList = (data?: object): ResponseType => {
|
export const getRoleList = (data?: object) => {
|
||||||
return http.request("post", "/role", { data });
|
return http.request<Result>("post", "/role", { data });
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取部门管理列表
|
// 获取部门管理列表
|
||||||
export const getDeptList = (data?: object): ResponseType => {
|
export const getDeptList = (data?: object) => {
|
||||||
return http.request("post", "/dept", { data });
|
return http.request<Result>("post", "/dept", { data });
|
||||||
};
|
};
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { http } from "../utils/http";
|
import { http } from "../utils/http";
|
||||||
|
|
||||||
interface userType extends Promise<any> {
|
type Result = {
|
||||||
svg?: string;
|
svg?: string;
|
||||||
code?: number;
|
code?: number;
|
||||||
info?: object;
|
info?: object;
|
||||||
}
|
};
|
||||||
|
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
export const getVerify = (): userType => {
|
export const getVerify = () => {
|
||||||
return http.request("get", "/captcha");
|
return http.request<Result>("get", "/captcha");
|
||||||
};
|
};
|
||||||
|
|
||||||
// 登录
|
// 登录
|
||||||
|
@ -19,10 +19,6 @@ defineOptions({
|
|||||||
name: "Amap"
|
name: "Amap"
|
||||||
});
|
});
|
||||||
|
|
||||||
type resultType = {
|
|
||||||
info: Array<undefined>;
|
|
||||||
};
|
|
||||||
|
|
||||||
let MarkerCluster;
|
let MarkerCluster;
|
||||||
let map: MapConfigureInter;
|
let map: MapConfigureInter;
|
||||||
|
|
||||||
@ -96,8 +92,8 @@ onBeforeMount(() => {
|
|||||||
|
|
||||||
// 获取模拟车辆信息
|
// 获取模拟车辆信息
|
||||||
mapJson()
|
mapJson()
|
||||||
.then((res: resultType) => {
|
.then(({ info }) => {
|
||||||
let points: object = res.info.map((v: any) => {
|
let points: object = info.map(v => {
|
||||||
return {
|
return {
|
||||||
lnglat: [v.lng, v.lat],
|
lnglat: [v.lng, v.lat],
|
||||||
...v
|
...v
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useColumns } from "./columns";
|
import { useColumns } from "./columns";
|
||||||
import { handleTree } from "@pureadmin/utils";
|
|
||||||
import { getDeptList } from "/@/api/system";
|
import { getDeptList } from "/@/api/system";
|
||||||
import { FormInstance } from "element-plus";
|
import { FormInstance } from "element-plus";
|
||||||
|
import { handleTree } from "@pureadmin/utils";
|
||||||
import { reactive, ref, onMounted } from "vue";
|
import { reactive, ref, onMounted } from "vue";
|
||||||
import { TableProBar } from "/@/components/ReTable";
|
import { TableProBar } from "/@/components/ReTable";
|
||||||
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
|
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
|
||||||
@ -37,7 +37,7 @@ function handleSelectionChange(val) {
|
|||||||
async function onSearch() {
|
async function onSearch() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
let { data } = await getDeptList();
|
let { data } = await getDeptList();
|
||||||
dataList.value = handleTree(data);
|
dataList.value = handleTree(data as any);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}, 500);
|
}, 500);
|
||||||
|
@ -64,7 +64,7 @@ watch(searchValue, val => {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
let { data } = await getDeptList();
|
let { data } = await getDeptList();
|
||||||
treeData.value = handleTree(data);
|
treeData.value = handleTree(data as any);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user