创建了api目录并拆分为10个功能模块文件
建立了index.ts统一导出 精简了原api.ts文件
This commit is contained in:
74
client/mobile/api/chart.ts
Normal file
74
client/mobile/api/chart.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const API_BASE_URL = '/api';
|
||||
|
||||
// 图表数据API接口类型
|
||||
interface ChartDataResponse<T> {
|
||||
message: string;
|
||||
data: T;
|
||||
}
|
||||
|
||||
interface UserActivityData {
|
||||
date: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
interface FileUploadsData {
|
||||
month: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
interface FileTypesData {
|
||||
type: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
interface DashboardOverviewData {
|
||||
userCount: number;
|
||||
fileCount: number;
|
||||
articleCount: number;
|
||||
todayLoginCount: number;
|
||||
}
|
||||
|
||||
// 图表数据API
|
||||
export const ChartAPI = {
|
||||
// 获取用户活跃度数据
|
||||
getUserActivity: async (): Promise<ChartDataResponse<UserActivityData[]>> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/charts/user-activity`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
// 获取文件上传统计数据
|
||||
getFileUploads: async (): Promise<ChartDataResponse<FileUploadsData[]>> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/charts/file-uploads`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
// 获取文件类型分布数据
|
||||
getFileTypes: async (): Promise<ChartDataResponse<FileTypesData[]>> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/charts/file-types`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
// 获取仪表盘概览数据
|
||||
getDashboardOverview: async (): Promise<ChartDataResponse<DashboardOverviewData>> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/charts/dashboard-overview`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user