Skip to content

Commit

Permalink
fix: ctx window global
Browse files Browse the repository at this point in the history
  • Loading branch information
afeiship committed Mar 9, 2021
1 parent eff504d commit 69f1731
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* description: Baidu fangyi api wrapper.
* homepage: https://github.com/afeiship/next-baidu-fanyi
* version: 1.0.0
* date: 2020-11-22 18:01:43
* date: 2021-03-09 09:14:30
* license: MIT
*/

(function () {
var global = global || this || window || Function('return this')();
var global = typeof window !== 'undefined' ? window : this || Function('return this')();
var nx = global.nx || require('@jswork/next');
var fetch = require('node-fetch');
var nxDelay = require('@jswork/next-delay');
Expand All @@ -34,7 +34,7 @@
var res = {
from: _from,
to: _to,
trans_result: nx.map(items, function (index, value) {
trans_result: nx.map(items, function (_, value) {
return { src: value, dst: value };
})
};
Expand Down
4 changes: 2 additions & 2 deletions dist/index.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* description: Baidu fangyi api wrapper.
* homepage: https://github.com/afeiship/next-baidu-fanyi
* version: 1.0.0
* date: 2020-11-22 18:01:43
* date: 2021-03-09 09:14:30
* license: MIT
*/
!function(){var a=(this||window||Function("return this")()).nx||require("@jswork/next"),o=require("node-fetch"),u=require("@jswork/next-delay"),s=a.fangyiApiSign||require("@jswork/next-fanyi-api-sign"),d=a.param||require("@jswork/next-param"),f={from:"zh",to:"en",delay:1e3},n=a.declare("nx.BaiduFanyi",{statics:{translate:function(n){var e=a.mix(null,f,s(n)),n="http://api.fanyi.baidu.com/api/trans/vip/translate?"+d(e),r=e.from,t=e.to,i=e.q;return r===t?new Promise(function(n){var e=i.split("\n");n({from:r,to:t,trans_result:a.map(e,function(n,e){return{src:e,dst:e}})})}):o(n).then(u(e.delay)).then(function(n){return n.json()})}}});"undefined"!=typeof module&&module.exports&&(module.exports=n)}();
!function(){var o=("undefined"!=typeof window?window:this||Function("return this")()).nx||require("@jswork/next"),a=require("node-fetch"),u=require("@jswork/next-delay"),s=o.fangyiApiSign||require("@jswork/next-fanyi-api-sign"),d=o.param||require("@jswork/next-param"),f={from:"zh",to:"en",delay:1e3},n=o.declare("nx.BaiduFanyi",{statics:{translate:function(n){var e=o.mix(null,f,s(n)),n="http://api.fanyi.baidu.com/api/trans/vip/translate?"+d(e),r=e.from,t=e.to,i=e.q;return r===t?new Promise(function(n){var e=i.split("\n");n({from:r,to:t,trans_result:o.map(e,function(n,e){return{src:e,dst:e}})})}):a(n).then(u(e.delay)).then(function(n){return n.json()})}}});"undefined"!=typeof module&&module.exports&&(module.exports=n)}();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
"fanyi",
"api"
]
}
}
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function () {
var global = global || this || window || Function('return this')();
var global = typeof window !== 'undefined' ? window : this || Function('return this')();
var nx = global.nx || require('@jswork/next');
var fetch = require('node-fetch');
var nxDelay = require('@jswork/next-delay');
Expand All @@ -25,7 +25,7 @@
var res = {
from: _from,
to: _to,
trans_result: nx.map(items, function (index, value) {
trans_result: nx.map(items, function (_, value) {
return { src: value, dst: value };
})
};
Expand Down

0 comments on commit 69f1731

Please sign in to comment.