export type GetApiApiV1DashboardPanelsArgs = {group: number, endpoint: string}; export type GetApiApiV1DashboardPanelsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * 页面通用接口 : 获取panels * * GET /api/v1/dashboard/panels */ export const getApiApiV1DashboardPanels = async (args: GetApiApiV1DashboardPanelsArgs, options: GetApiApiV1DashboardPanelsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.group != null) query.append("group", String(args.group)) if (args.endpoint != null) query.append("endpoint", String(args.endpoint)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/dashboard/panels${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };