修改范围覆盖mobile/api目录下所有API文件(共9个,包括auth.ts)
统一使用index.ts中的全局axios配置 移除了所有重复的API_BASE_URL定义 简化了所有API调用路径格式 提高了代码一致性和可维护性 确保所有API功能保持正常
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import axios from 'axios';
|
||||
import type {
|
||||
import type {
|
||||
LoginLocation, LoginLocationDetail,
|
||||
} from '../../share/types.ts';
|
||||
|
||||
const API_BASE_URL = '/api';
|
||||
|
||||
|
||||
// 地图相关API的接口类型定义
|
||||
export interface LoginLocationResponse {
|
||||
@@ -31,7 +29,7 @@ export const MapAPI = {
|
||||
userId?: number
|
||||
}): Promise<LoginLocationResponse> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/map/markers`, { params });
|
||||
const response = await axios.get('/map/markers', { params });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -41,7 +39,7 @@ export const MapAPI = {
|
||||
// 获取登录位置详情
|
||||
getLocationDetail: async (locationId: number): Promise<LoginLocationDetailResponse> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/map/location/${locationId}`);
|
||||
const response = await axios.get(`/map/location/${locationId}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -55,7 +53,7 @@ export const MapAPI = {
|
||||
location_name?: string;
|
||||
}): Promise<LoginLocationUpdateResponse> => {
|
||||
try {
|
||||
const response = await axios.put(`${API_BASE_URL}/map/location/${locationId}`, data);
|
||||
const response = await axios.put(`/map/location/${locationId}`, data);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user