Files
juip-web/src/api/dashboard.ts

18 lines
541 B
TypeScript
Raw Normal View History

2026-08-31 14:49:28 +08:00
import type { ApiResponse } from "@/lib/api"
2026-09-04 13:21:47 +08:00
import type { ApiIndexItem } from "@/lib/models/dashboard"
import { callPublic } from "./base"
2026-08-31 14:49:28 +08:00
2026-09-04 13:21:47 +08:00
export async function fetchApiIndex(): Promise<
ApiResponse<ApiIndexItem | null>
2026-08-31 14:49:28 +08:00
> {
2026-09-04 13:21:47 +08:00
const res = await callPublic<ApiIndexItem | ApiIndexItem[]>(
"/user/ApiIndex",
2026-08-31 14:49:28 +08:00
undefined,
"GET",
)
2026-09-04 13:21:47 +08:00
if (!res.success) return res
// 兼容后端返回单对象或数组两种格式
const item = Array.isArray(res.data) ? res.data[0] : res.data
return { success: true, data: item ?? null }
2026-08-31 14:49:28 +08:00
}