🎈 perf: 简化百度翻译配置

This commit is contained in:
zhiyu1998 2023-02-18 23:35:29 +08:00
parent 9f5c55b269
commit 13acebda12
2 changed files with 9 additions and 2 deletions

View File

@ -87,6 +87,9 @@ export class tools extends plugin {
this.proxyPort = this.toolsConfig.proxyPort; this.proxyPort = this.toolsConfig.proxyPort;
this.myProxy = `http://${this.proxyAddr}:${this.proxyPort}`; this.myProxy = `http://${this.proxyAddr}:${this.proxyPort}`;
// console.log(this.myProxy) // 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=APP ID&salt=自定义&sign=${ md5("APP ID" + place + "自定义" + "密钥") }&q=${ place }`;
let url = `http://api.fanyi.baidu.com/api/trans/vip/translate?from=auto&to=${ let url = `http://api.fanyi.baidu.com/api/trans/vip/translate?from=auto&to=${
transMap[language[1]] 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) await fetch(url)
.then(resp => resp.json()) .then(resp => resp.json())
.then(text => text.trans_result) .then(text => text.trans_result)

View File

@ -1,3 +1,6 @@
defaultPath: './data/rcmp4/' # 保存视频的位置 defaultPath: './data/rcmp4/' # 保存视频的位置
proxyAddr: '127.0.0.1' # 魔法地址 proxyAddr: '127.0.0.1' # 魔法地址
proxyPort: '7890' # 魔法端口 proxyPort: '7890' # 魔法端口
translateAppId: '' # 百度翻译APP ID
translateSecret: '' # 百度翻译密匙