You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
1.9 KiB

import{r as e}from"./index-DmeeGfre.js";function t(e){if(!e||typeof e!=`object`)throw Error(`列表响应格式无效`);let t=e;if(Array.isArray(t.data)&&typeof t.current_page==`number`){let e=t.data;return{data:e,meta:{current_page:t.current_page,last_page:typeof t.last_page==`number`?t.last_page:1,per_page:typeof t.per_page==`number`?t.per_page:e.length||15,total:typeof t.total==`number`?t.total:e.length}}}let n=t.data??t,r=n.data,i=n.meta;if(Array.isArray(r)&&i&&typeof i==`object`)return{data:r,meta:i};if(Array.isArray(t.data)){let e=t.data;return{data:e,meta:{current_page:1,last_page:1,per_page:e.length,total:e.length}}}throw Error(`列表响应格式无效`)}async function n(n){let{data:r}=await e.get(`/competitions`,{params:n});return t(r)}async function r(t){let{data:n}=await e.get(`/competitions/${t}`),r=n?.data??n;if(!r||typeof r!=`object`)throw Error(`赛事详情无效`);return r}async function i(t){let{data:n}=await e.post(`/competitions`,t),r=n?.data??n;if(!r||typeof r!=`object`)throw Error(`创建响应无效`);return r}async function a(t,n){let{data:r}=await e.put(`/competitions/${t}`,n),i=r?.data??r;if(!i||typeof i!=`object`)throw Error(`更新响应无效`);return i}async function o(t,n){let{data:r}=await e.patch(`/competitions/${t}`,n),i=r?.data??r;if(!i||typeof i!=`object`)throw Error(`更新响应无效`);return i}async function s(t){let{data:n}=await e.get(`/competitions/${t}/tracks`),r=n?.data??n;if(!Array.isArray(r))throw Error(`赛道列表无效`);return r}async function c(t,n){let{data:r}=await e.post(`/competitions/${t}/tracks`,n),i=r?.data??r;if(!i||typeof i!=`object`)throw Error(`创建赛道无效`);return i}async function l(t,n,r){let{data:i}=await e.put(`/competitions/${t}/tracks/${n}`,r),a=i?.data??i;if(!a||typeof a!=`object`)throw Error(`更新赛道无效`);return a}async function u(t,n){await e.delete(`/competitions/${t}/tracks/${n}`)}export{n as a,a as c,r as i,l,c as n,s as o,u as r,o as s,i as t};