let s="https://www.dingdangbox.com/api/";s="https://www.dingdangbox.com/api/";const h="网络连接异常，请稍后再试",o={activate:e=>{e.url=s+"v1/licenses/validate",e.method="post",d(e)},checkLicense:e=>{e.url=s+"v1/licenses/validate",e.method="post",d(e)},signIn:e=>{e.url=s+"login/",e.method="post",d(e)},getData:e=>{e.url=s+"getData/",e.method="get",d(e)},submitByBackground:e=>{e.background=!0,e.url=s+"submit/",e.method="post",d(e)}};function d(e){e.background?m(e):r(e)}function r(e){e.data===void 0&&(e.data={}),e.method=e.method||"post";let t={},u=null;e.formData?(u=new FormData,Object.keys(e.data).forEach(function(a){u.append(a,e.data[a])})):(t["Content-Type"]="application/json;charset=UTF-8",u=JSON.stringify(e.data));let l={method:e.method,headers:t,body:u};fetch(e.url,l).then(a=>a.json()).then(a=>{e.done&&e.done(),e.success&&e.success(a)}).catch(()=>{e.done&&e.done(),e.fail&&e.fail(h)})}function m(e){chrome&&chrome.runtime?chrome.runtime.sendMessage({contentRequest:"apiRequest",config:e},t=>{e.done&&e.done(),t.result==="succ"?e.success&&e.success(t):e.fail&&e.fail(t.msg)}):console.log("未找到chrome API")}export{o as a};
