完整API模块结构:
client/admin/api/ ├── auth.ts (认证API) ├── users.ts (用户API) ├── files.ts (文件API) ├── theme.ts (主题API) ├── charts.ts (图表API) ├── messages.ts (消息API) ├── sys.ts (系统API) ├── know_info.ts (知识库API) ├── maps.ts (地图API) └── index.ts (统一入口)
This commit is contained in:
68
client/admin/api/charts.ts
Normal file
68
client/admin/api/charts.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const API_BASE_URL = '/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;
|
||||
}
|
||||
|
||||
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