Files
yourname ba64ad96ed 修改范围覆盖mobile/api目录下所有API文件(共9个,包括auth.ts)
统一使用index.ts中的全局axios配置
移除了所有重复的API_BASE_URL定义
简化了所有API调用路径格式
提高了代码一致性和可维护性
确保所有API功能保持正常
2025-05-13 09:31:30 +00:00

62 lines
1.4 KiB
TypeScript

import axios from 'axios';
import type {
LoginLocation, LoginLocationDetail,
} from '../../share/types.ts';
// 地图相关API的接口类型定义
export interface LoginLocationResponse {
message: string;
data: LoginLocation[];
}
export interface LoginLocationDetailResponse {
message: string;
data: LoginLocationDetail;
}
export interface LoginLocationUpdateResponse {
message: string;
data: LoginLocationDetail;
}
// 地图相关API
export const MapAPI = {
// 获取地图标记点数据
getMarkers: async (params?: {
startTime?: string;
endTime?: string;
userId?: number
}): Promise<LoginLocationResponse> => {
try {
const response = await axios.get('/map/markers', { params });
return response.data;
} catch (error) {
throw error;
}
},
// 获取登录位置详情
getLocationDetail: async (locationId: number): Promise<LoginLocationDetailResponse> => {
try {
const response = await axios.get(`/map/location/${locationId}`);
return response.data;
} catch (error) {
throw error;
}
},
// 更新登录位置信息
updateLocation: async (locationId: number, data: {
longitude: number;
latitude: number;
location_name?: string;
}): Promise<LoginLocationUpdateResponse> => {
try {
const response = await axios.put(`/map/location/${locationId}`, data);
return response.data;
} catch (error) {
throw error;
}
}
};