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
2.0 KiB
1 lines
2.0 KiB
import{e as y,aa as h,ab as w,A as g,j as d,k as b}from"./6O01ZZML.js";const k="$s";function A(...t){const s=typeof t[t.length-1]=="string"?t.pop():void 0;typeof t[0]!="string"&&t.unshift(s);const[a,o]=t;if(!a||typeof a!="string")throw new TypeError("[nuxt] [useState] key must be a string: "+a);if(o!==void 0&&typeof o!="function")throw new Error("[nuxt] [useState] init must be a function: "+o);const i=k+a,r=y(),n=h(r.payload.state,i);if(o&&(r._state[i]??={_default:o}),n.value===void 0&&o){const e=o();if(w(e))return r.payload.state[i]=e,e;n.value=e}return n}function m(){const t=A("app:loading",()=>0),s=g(()=>t.value>0);function a(){t.value++}function o(){t.value=Math.max(0,t.value-1)}return{count:t,loading:s,begin:a,end:o}}async function f(t,s,a){const o=d(),i=b(),r={"Content-Type":"application/json"};o.token&&(r.Authorization=o.token),a&&Object.assign(r,a);const n=await fetch(t,{method:"POST",headers:r,body:JSON.stringify(s)});if(!n.ok)throw new Error(`HTTP error: ${n.status}`);const e=await n.json();if(e.code===18)throw o.logout(),i.push("/"),new Error(e.msg||"Unauthorized");if(e.code!==0)throw new Error(e.msg||"Unknown error");return e.data}const S=/^(get|list|load|query|fetch|search|count|stat|export|check)/i;function v(t){return!S.test(t)}function x(){const t=d(),{begin:s,end:a}=m();async function o(n,e){const u={};if(t.currentAppId&&(u["X-App-Id"]=String(t.currentAppId)),!v(n))return f(`/web/api/api_${n}`,e??{},u);s();try{return await f(`/web/api/api_${n}`,e??{},u)}finally{a()}}async function i(n,e){return f(`/console/api/${n}`,e??{})}async function r(n,e){const u=n.type||"application/octet-stream",c=await o("getcostoken",{path:e,filename:n.name,content_type:u}),p=c.upload_url||c.url||"";if(!p)throw new Error("未获取到上传地址:请确认已在【第三方服务配置→存储】配置并启用「阿里云 OSS」");const l=await fetch(p,{method:"PUT",headers:{"Content-Type":u},body:n});if(!l.ok)throw new Error(`Upload failed: ${l.status}`);return c.url||p.split("?")[0]}return{webApi:o,consoleApi:i,uploadFile:r}}export{m as a,A as b,x as u};
|
|
|