- Spring Boot 后端服务 (hss-home-service) - delivery-miniapp 配送小程序 - website 官网 (Nuxt) - docs 架构设计文档 - Docker 容器化部署配置 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2 lines
1.0 KiB
JavaScript
2 lines
1.0 KiB
JavaScript
const s=typeof window<"u"?window.location.protocol+"//"+window.location.host+"/api/hss":"/api/hss";function i(){function r(o){const e={"Content-Type":"application/json","X-Tenant-Id":"1","X-Org-Id":"1"};if(typeof window<"u"){const n=localStorage.getItem("hss_platform_user");if(n)try{const t=JSON.parse(n);e["X-User-Id"]=t.userId,e["X-User-Role"]=t.userRole,e["X-Tenant-Id"]=t.tenantId,e["X-Org-Id"]=t.orgId}catch{}}return{...e,...o}}async function a(o){const e=await $fetch(s+o,{headers:r()});if(typeof e.code=="string"?e.code!=="200"&&e.code!=="SUCCESS":e.code!==200)throw new Error(e.message||"API error");return e.data}async function c(o,e){const n=r();e&&(n["Idempotency-Key"]="web-"+Date.now()+"-"+Math.random().toString(36).slice(2,8));const t=await $fetch(s+o,{method:"POST",headers:n,body:e?JSON.stringify(e):void 0});if(typeof t.code=="string"?t.code!=="200"&&t.code!=="SUCCESS":t.code!==200)throw new Error(t.message||"API error");return t.data}async function d(o){return await $fetch(s+o,{headers:r()})}return{get:a,post:c,rawGet:d}}export{i as u};
|