以下推荐一个插件,直接看源码拷贝粘贴就可以用,这块插件包括了 谷歌翻译 腾讯翻译 有道翻译 百度翻译 彩云小译 必应翻译 Papago翻译 阿里翻译 爱词霸翻译 Deepl翻译 腾讯AI翻译 https://greasyfork.org/zh-CN/scripts/378277-翻译机/code 下面是我重写的代码,只移植了部分翻译,完全免费,没有限制 import axios from 'axios' ; import CryptoJS from 'crypto-js' ; /** * 翻译类 */ export class Fanyi { index : number = 0 ; /** * 彩云翻译 配置参数 */ caiyun_id : string = '' ; caiyun_jwt : string = '' ; /** * 翻译, 默认从中文到英文 * @param text * @param from * @param to * @return {Promise<any>} * @private * @memberof Fanyi * */ translates = [ this . translate_icib , // 爱词霸 this . translate_tencentai , // 腾讯云 this . translate_alibaba , // 阿里云 this . translate_caiyun , // 彩云 this . translate_youdao_mobile // 有道 ]; async translate ( text : string ) { const fanyi = this . translates [ this . index % this . translates . length ]( text ); th