合作页面的内容
This commit is contained in:
@@ -734,16 +734,23 @@ export interface RecentActivity {
|
||||
}
|
||||
|
||||
// 仪表盘API
|
||||
export const getDashboardStats = async (): Promise<DashboardStats> => {
|
||||
export const getDashboardStats = async (startDate?: string, endDate?: string): Promise<DashboardStats> => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/admin/dashboard/stats`, {
|
||||
let url = `${API_BASE}/admin/dashboard/stats`
|
||||
const params = new URLSearchParams()
|
||||
if (startDate) params.append('startDate', startDate)
|
||||
if (endDate) params.append('endDate', endDate)
|
||||
if (params.toString()) url += `?${params.toString()}`
|
||||
|
||||
const response = await fetch(url, {
|
||||
headers: getAuthHeaders()
|
||||
})
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json()
|
||||
throw new Error(errorData.error || '获取仪表盘统计数据失败')
|
||||
}
|
||||
return await response.json()
|
||||
const data = await response.json()
|
||||
return data.result // 适配新的统一响应结构
|
||||
} catch (error) {
|
||||
console.error('Get dashboard stats error:', error)
|
||||
throw error
|
||||
|
||||
Reference in New Issue
Block a user