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 (统一入口)
68 lines
1.4 KiB
TypeScript
68 lines
1.4 KiB
TypeScript
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;
|
|
}
|
|
}
|
|
}; |