完善个人中心页面

This commit is contained in:
Eamon
2026-09-04 13:21:47 +08:00
parent 6d6d300203
commit f59e929843
27 changed files with 614 additions and 414 deletions

View File

@@ -1,41 +1,17 @@
import type { ApiResponse } from "@/lib/api"
import { callByUser } from "./base"
import { fetchHttpBalance } from "./http"
import type { ApiIndexItem } from "@/lib/models/dashboard"
import { callPublic } from "./base"
// ==================== 仪表盘 ====================
// 余额走 php-api,订单/消费统计走 .NET;账号信息与 IP 统计接口待后端确认。
export async function fetchDashboardBalance(): Promise<ApiResponse<number>> {
return fetchHttpBalance()
}
export async function fetchDashboardConsumption(
params: Record<string, unknown>,
): Promise<ApiResponse<Record<string, unknown>>> {
return await callByUser<Record<string, unknown>>(
"/api/course/v1/order/UserConsumeStatistics",
params,
"GET",
)
}
// TODO: 账号信息/IP 统计接口路径待后端确认
export async function fetchDashboardAccountInfo(): Promise<
ApiResponse<Record<string, unknown>>
export async function fetchApiIndex(): Promise<
ApiResponse<ApiIndexItem | null>
> {
return await callByUser<Record<string, unknown>>(
"/api/baseinfo/v1/user/Info",
undefined,
"GET",
)
}
export async function fetchDashboardIpStats(): Promise<
ApiResponse<Record<string, unknown>>
> {
return await callByUser<Record<string, unknown>>(
"/api/course/v1/order/IpAccountStatistics",
const res = await callPublic<ApiIndexItem | ApiIndexItem[]>(
"/user/ApiIndex",
undefined,
"GET",
)
if (!res.success) return res
// 兼容后端返回单对象或数组两种格式
const item = Array.isArray(res.data) ? res.data[0] : res.data
return { success: true, data: item ?? null }
}