修改范围覆盖mobile/api目录下所有API文件(共9个,包括auth.ts)
统一使用index.ts中的全局axios配置 移除了所有重复的API_BASE_URL定义 简化了所有API调用路径格式 提高了代码一致性和可维护性 确保所有API功能保持正常
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const API_BASE_URL = '/api';
|
||||
|
||||
// 图表数据API接口类型
|
||||
interface ChartDataResponse<T> {
|
||||
message: string;
|
||||
@@ -35,7 +33,7 @@ export const ChartAPI = {
|
||||
// 获取用户活跃度数据
|
||||
getUserActivity: async (): Promise<ChartDataResponse<UserActivityData[]>> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/charts/user-activity`);
|
||||
const response = await axios.get('/charts/user-activity');
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -45,7 +43,7 @@ export const ChartAPI = {
|
||||
// 获取文件上传统计数据
|
||||
getFileUploads: async (): Promise<ChartDataResponse<FileUploadsData[]>> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/charts/file-uploads`);
|
||||
const response = await axios.get('/charts/file-uploads');
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -55,7 +53,7 @@ export const ChartAPI = {
|
||||
// 获取文件类型分布数据
|
||||
getFileTypes: async (): Promise<ChartDataResponse<FileTypesData[]>> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/charts/file-types`);
|
||||
const response = await axios.get('/charts/file-types');
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -65,7 +63,7 @@ export const ChartAPI = {
|
||||
// 获取仪表盘概览数据
|
||||
getDashboardOverview: async (): Promise<ChartDataResponse<DashboardOverviewData>> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/charts/dashboard-overview`);
|
||||
const response = await axios.get('/charts/dashboard-overview');
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user