generated from VLADIMIR/template_frontend
add result
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
import{a as e,o as t}from"./HeaderMenu-BCz0PYuC.js";function n(){let t=e();return r(t.refreshTokenAction,t.getToken)}function r(e,n){async function r(r,i){let a={},o=n();o&&(a.Authorization=`Bearer ${o}`);let s=await fetch(`${t()}/${r}`,{...i,headers:{...a,...i.headers}});if(s.status==401){await e();let o=n();o&&(a.Authorization=`Bearer ${o}`),s=await fetch(`${t()}/${r}`,{...i,headers:{...a,...i.headers}})}return s}async function o(e){let t=await r(`api/scenarios/${e}/archive`,{method:`GET`});if(!t.ok)throw Error(await a(t));return{blob:await t.blob(),filename:i(t.headers.get(`Content-Disposition`))||`scenario-${e}.zip`}}async function s(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:o,uploadScenarioArchive:s}}function i(e){if(!e)return``;let t=e.match(/filename="?([^";]+)"?/i);return(t?t[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