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 lines
1003 B
1 lines
1003 B
import{y as p,z as d}from"./ydFS6PsN.js";async function c(s,a,i){const r=p(),n=d(),t={"Content-Type":"application/json"};r.token&&(t.Authorization=r.token),i&&Object.assign(t,i);const o=await fetch(s,{method:"POST",headers:t,body:JSON.stringify(a)});if(!o.ok)throw new Error(`HTTP error: ${o.status}`);const e=await o.json();if(e.code===18)throw r.logout(),n.push("/"),new Error(e.msg||"Unauthorized");if(e.code!==0)throw new Error(e.msg||"Unknown error");return e.data}function h(){const s=p();async function a(n,t){const o={};return s.currentAppId&&(o["X-App-Id"]=String(s.currentAppId)),c(`/web/api/api_${n}`,t??{},o)}async function i(n,t){return c(`/console/api/${n}`,t??{})}async function r(n,t){const o=await a("getcostoken",{path:t}),e=o.upload_url||o.url||"",u=await fetch(e,{method:"PUT",headers:{"Content-Type":n.type||"application/octet-stream"},body:n});if(!u.ok)throw new Error(`Upload failed: ${u.status}`);return e.split("?")[0]}return{webApi:a,consoleApi:i,uploadFile:r}}export{h as u};
|
|
|