UNPKG

@dead_fish/api

Version:

Wechat JsTicket、SendEmail、getImageBase64、 UploadTencentOssFile

2 lines (1 loc) 3.58 kB
function t(t,e,n,r){return new(n||(n=Promise))(function(o,a){function s(t){try{u(r.next(t))}catch(t){a(t)}}function c(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,c)}u((r=r.apply(t,e||[])).next())})}function e(t,e){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=c(0),s.throw=c(1),s.return=c(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}"function"==typeof SuppressedError&&SuppressedError;var n="https://api.roxmotor.top/freeApi/jsTicket",r="https://api.roxmotor.top/freeApi/mail",o="https://api.roxmotor.top/freeApi/image2Base64",a="https://api.roxmotor.top/freeApi/upload",s=new(function(){function s(){}return s.prototype.wxSign=function(r){return t(this,void 0,void 0,function(){var t;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t="".concat(n,"?url=").concat(null==r?void 0:r.url),[4,fetch(t,{mode:"cors"}).then(function(t){return t.json()})];case 1:return[2,e.sent()];case 2:return[2,{status:!1,message:e.sent().message,data:null}];case 3:return[2]}})})},s.prototype.sendEmail=function(n){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,fetch(r,{mode:"cors",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then(function(t){return t.json()})];case 1:return[2,t.sent()];case 2:return[2,{status:!1,message:t.sent().message,data:null}];case 3:return[2]}})})},s.prototype.getImageBase64=function(n,r){return t(this,void 0,void 0,function(){var t;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t="".concat(o,"?url=").concat(n),r&&(t+="&referer=".concat(r)),[4,fetch(t,{mode:"cors"}).then(function(t){return t.json()})];case 1:return[2,e.sent()];case 2:return[2,{status:!1,message:e.sent().message,data:null}];case 3:return[2]}})})},s.prototype.uploadTencentOSS=function(n){return t(this,void 0,void 0,function(){var t,r;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t="".concat(a,"?id=").concat(n.secredId,"&key=").concat(n.secretKey,"&bucket=").concat(n.bucket,"&region=").concat(n.region),n.destination&&(t+="&destination=".concat(n.destination)),t+="&preserveFilename=".concat(n.syncFilename?"1":"0"),(r=new FormData).append("file",n.file),[4,fetch(t,{mode:"cors",method:"POST",body:r}).then(function(t){return t.json()})];case 1:return[2,e.sent()];case 2:return[2,{status:!1,message:e.sent().message,data:{url:""}}];case 3:return[2]}})})},s}());export{s as default};