From 13acebda12a9fec5c2b5c1ff3c9d095274583238 Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Sat, 18 Feb 2023 23:35:29 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E7=99=BE=E5=BA=A6=E7=BF=BB=E8=AF=91=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 6 +++++- config/tools.yaml | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index ab83ff3..2784217 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -87,6 +87,9 @@ export class tools extends plugin { this.proxyPort = this.toolsConfig.proxyPort; this.myProxy = `http://${this.proxyAddr}:${this.proxyPort}`; // console.log(this.myProxy) + // 加载百度翻译配置 + this.translateAppId = this.toolsConfig.translateAppId; + this.translateSecret = this.toolsConfig.translateSecret; } // 翻译插件 @@ -105,7 +108,8 @@ export class tools extends plugin { // let url = `http://api.fanyi.baidu.com/api/trans/vip/translate?from=auto&to=${ transMap[language[1]] }&appid=APP ID&salt=自定义&sign=${ md5("APP ID" + place + "自定义" + "密钥") }&q=${ place }`; let url = `http://api.fanyi.baidu.com/api/trans/vip/translate?from=auto&to=${ transMap[language[1]] - }&appid=&salt=&sign=${md5("" + place + "" + "")}&q=${place}`; + }&appid=${this.translateAppId}&salt=rconsole&sign=${md5(this.translateAppId + place + "rconsole" + this.translateSecret)}&q=${place}`; + // console.log(url) await fetch(url) .then(resp => resp.json()) .then(text => text.trans_result) diff --git a/config/tools.yaml b/config/tools.yaml index e1b3e7b..387d4ae 100644 --- a/config/tools.yaml +++ b/config/tools.yaml @@ -1,3 +1,6 @@ defaultPath: './data/rcmp4/' # 保存视频的位置 proxyAddr: '127.0.0.1' # 魔法地址 -proxyPort: '7890' # 魔法端口 \ No newline at end of file +proxyPort: '7890' # 魔法端口 + +translateAppId: '' # 百度翻译APP ID +translateSecret: '' # 百度翻译密匙 \ No newline at end of file