UNPKG

@dead_fish/api

Version:

Wechat JsTicket、SendEmail、getImageBase64

2 lines (1 loc) 2.9 kB
function t(t,e,n,r){return new(n||(n=Promise))(function(o,a){function s(t){try{c(r.next(t))}catch(t){a(t)}}function u(t){try{c(r.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,u)}c((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=u(0),s.throw=u(1),s.return=u(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}"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=new(function(){function a(){}return a.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]}})})},a.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]}})})},a.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]}})})},a}());export{a as default};