generated from VLADIMIR/template_frontend
fix
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
import{r as e,t}from"./auth-Dlv0TZH7.js";function n(){let e=t();return r(e.refreshTokenAction,e.getToken)}function r(t,n){async function r(r,i){let a={},o=n();o&&(a.Authorization=`Bearer ${o}`);let s=await fetch(`${e()}/${r}`,{...i,headers:{...a,...i.headers}});if(s.status==401){await t();let o=n();o&&(a.Authorization=`Bearer ${o}`),s=await fetch(`${e()}/${r}`,{...i,headers:{...a,...i.headers}})}return s}async function o(e,t){let n=await r(e,{method:`GET`});if(!n.ok)throw Error(await a(n));return{blob:await n.blob(),filename:i(n.headers.get(`Content-Disposition`))||t}}function s(e){return o(`api/scenarios/${e}/archive`,`scenario-${e}.zip`)}function c(e){return o(`api/games/${e}/teams/qr.pdf`,`game-${e}.pdf`)}async function l(e){let t=await r(`api/scenarios/archive`,{method:`POST`,headers:{"Content-Type":e.type||`application/zip`},body:e}),n=await t.json().catch(()=>null);if(!t.ok)return{id:null,error:n?.message||`Ошибка сервера (${t.status})`};let i=typeof n?.error==`string`&&n.error!==``?n.error:null;return{id:typeof n?.id==`number`?n.id:null,error:i}}return{downloadScenarioArchive:s,downloadTeamQR:c,uploadScenarioArchive:l}}function i(e){if(!e)return``;let t=e.match(/filename\*=UTF-8''([^;]+)/i);if(t)try{return decodeURIComponent(t[1].trim()).replace(/[\\/:*?"<>|]/g,`_`)}catch{}let n=e.match(/filename="?([^";]+)"?/i);return(n?n[1]:``).replace(/[\\/:*?"<>|]/g,`_`)}async function a(e){let t=await e.json().catch(()=>null);return t&&typeof t.message==`string`&&t.message!==``?t.message:`Ошибка сервера (${e.status})`}export{n as t};
|
||||
Reference in New Issue
Block a user