YiAi/YiAiQuickDeploy/dist/modules/fanyi/fanyi.service.js
2024-02-05 23:18:50 +08:00

1 line
4.7 KiB
JavaScript

'use strict';const _0x1c2874=_0x198e;(function(_0x411e16,_0x1a5805){const _0x3dc14b=_0x198e,_0x55b684=_0x411e16();while(!![]){try{const _0x29699e=-parseInt(_0x3dc14b(0xdc))/0x1+-parseInt(_0x3dc14b(0xc5))/0x2*(-parseInt(_0x3dc14b(0xc1))/0x3)+-parseInt(_0x3dc14b(0xbb))/0x4*(-parseInt(_0x3dc14b(0xde))/0x5)+parseInt(_0x3dc14b(0xc3))/0x6*(parseInt(_0x3dc14b(0xbd))/0x7)+-parseInt(_0x3dc14b(0xb7))/0x8*(parseInt(_0x3dc14b(0xdb))/0x9)+parseInt(_0x3dc14b(0xda))/0xa*(parseInt(_0x3dc14b(0xbc))/0xb)+-parseInt(_0x3dc14b(0xc0))/0xc;if(_0x29699e===_0x1a5805)break;else _0x55b684['push'](_0x55b684['shift']());}catch(_0x467fb9){_0x55b684['push'](_0x55b684['shift']());}}}(_0xcb9c,0xd577b));var __decorate=this&&this['__decorate']||function(_0x862edd,_0x49fa0f,_0x558d59,_0x1d3421){const _0x201aad=_0x198e;var _0x52e306=arguments['length'],_0x388c9c=_0x52e306<0x3?_0x49fa0f:_0x1d3421===null?_0x1d3421=Object[_0x201aad(0xdd)](_0x49fa0f,_0x558d59):_0x1d3421,_0x490f48;if(typeof Reflect===_0x201aad(0xca)&&typeof Reflect[_0x201aad(0xc9)]===_0x201aad(0xb5))_0x388c9c=Reflect['decorate'](_0x862edd,_0x49fa0f,_0x558d59,_0x1d3421);else{for(var _0x44405d=_0x862edd[_0x201aad(0xcc)]-0x1;_0x44405d>=0x0;_0x44405d--)if(_0x490f48=_0x862edd[_0x44405d])_0x388c9c=(_0x52e306<0x3?_0x490f48(_0x388c9c):_0x52e306>0x3?_0x490f48(_0x49fa0f,_0x558d59,_0x388c9c):_0x490f48(_0x49fa0f,_0x558d59))||_0x388c9c;}return _0x52e306>0x3&&_0x388c9c&&Object[_0x201aad(0xe1)](_0x49fa0f,_0x558d59,_0x388c9c),_0x388c9c;},__metadata=this&&this['__metadata']||function(_0x109d7e,_0x9b4d4d){const _0x185280=_0x198e;if(typeof Reflect===_0x185280(0xca)&&typeof Reflect[_0x185280(0xb6)]===_0x185280(0xb5))return Reflect[_0x185280(0xb6)](_0x109d7e,_0x9b4d4d);};Object[_0x1c2874(0xe1)](exports,_0x1c2874(0xd4),{'value':!![]}),exports['FanyiService']=void 0x0;const globalConfig_service_1=require(_0x1c2874(0xd1)),common_1=require(_0x1c2874(0xc2)),axios_1=require(_0x1c2874(0xe0)),crypto=require(_0x1c2874(0xc4));function _0x198e(_0x48cc62,_0x454dd0){const _0xcb9ca0=_0xcb9c();return _0x198e=function(_0x198e33,_0x391abc){_0x198e33=_0x198e33-0xb5;let _0x4c4b33=_0xcb9ca0[_0x198e33];return _0x4c4b33;},_0x198e(_0x48cc62,_0x454dd0);}let FanyiService=class FanyiService{constructor(_0x42e55b){const _0x278967=_0x1c2874;this[_0x278967(0xce)]=_0x42e55b;}async[_0x1c2874(0xb8)](_0x488eab){const _0x1bcd7f=_0x1c2874;if(!_0x488eab)throw new common_1[(_0x1bcd7f(0xc8))](_0x1bcd7f(0xc7),common_1['HttpStatus'][_0x1bcd7f(0xdf)]);const {baiduFanyiAppId:_0x56bd4b,baiduFanyiSecret:_0x271774}=await this[_0x1bcd7f(0xce)][_0x1bcd7f(0xd3)]([_0x1bcd7f(0xd0),_0x1bcd7f(0xd2)]);if(!_0x56bd4b||!_0x271774)throw new common_1['HttpException'](_0x1bcd7f(0xe5),common_1[_0x1bcd7f(0xba)]['BAD_REQUEST']);const _0x47b125=Date[_0x1bcd7f(0xb9)]()[_0x1bcd7f(0xd8)](),_0x49e556=crypto[_0x1bcd7f(0xd7)](_0x1bcd7f(0xbe))['update'](_0x56bd4b+_0x488eab+_0x47b125+_0x271774)[_0x1bcd7f(0xbf)](_0x1bcd7f(0xc6)),_0x267252=_0x1bcd7f(0xcd),_0x549c75={'q':_0x488eab[_0x1bcd7f(0xd8)](),'from':'auto','to':'en','appid':_0x56bd4b,'salt':_0x47b125,'sign':_0x49e556},_0xe5cff=await axios_1[_0x1bcd7f(0xe4)][_0x1bcd7f(0xcf)](_0x267252,_0x549c75,{'headers':{'Content-Type':_0x1bcd7f(0xcb)}}),{from:_0x1d1eec,to:_0x300a0a,trans_result:_0x46bb83,error_code:_0x5781e6,error_msg:_0x3b31c8}=_0xe5cff[_0x1bcd7f(0xd9)];if(_0x5781e6){console[_0x1bcd7f(0xe2)](_0x1bcd7f(0xd6),_0xe5cff);throw new common_1[(_0x1bcd7f(0xc8))](_0x1bcd7f(0xe3)+_0x5781e6+']['+_0x3b31c8+']!',common_1[_0x1bcd7f(0xba)][_0x1bcd7f(0xdf)]);}if(!_0x46bb83||!_0x46bb83[_0x1bcd7f(0xcc)]){console[_0x1bcd7f(0xe2)]('res:\x20',_0xe5cff);throw new common_1['HttpException'](_0x1bcd7f(0xe3)+_0x5781e6+']['+_0x3b31c8+']!',common_1['HttpStatus'][_0x1bcd7f(0xdf)]);}else{}return _0x46bb83[0x0]['dst'];}};function _0xcb9c(){const _0x505ea4=['17324ClQVeM','2549195IwuDlH','5927131SnaTLh','md5','digest','33706812HXQOaS','42NFIOTw','@nestjs/common','6pHWick','crypto','241636rHKKvG','hex','请输入要翻译的内容!','HttpException','decorate','object','application/x-www-form-urlencoded','length','https://fanyi-api.baidu.com/api/trans/vip/translate','globalConfigService','post','baiduFanyiAppId','../globalConfig/globalConfig.service','baiduFanyiSecret','getConfigs','__esModule','FanyiService','res:\x20','createHash','toString','data','50EhNhzg','40797cCcrLR','383859mGbSDM','getOwnPropertyDescriptor','1720sKYDGU','BAD_REQUEST','axios','defineProperty','log','翻译失败[','default','当前管理员还未开放翻译服务、请联系管理员开通吧!','function','metadata','1976nUYuRP','convertToEnglish','now','HttpStatus'];_0xcb9c=function(){return _0x505ea4;};return _0xcb9c();}FanyiService=__decorate([(0x0,common_1['Injectable'])(),__metadata('design:paramtypes',[globalConfig_service_1['GlobalConfigService']])],FanyiService),exports[_0x1c2874(0xd5)]=FanyiService;