Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: remove wild DeepL keys #54

Merged
merged 7 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

### ✨ Features

- Support OpenAI ChatGPT translation.
- Support OpenAI translation.

![OpenAI](https://user-images.githubusercontent.com/25194972/225886686-b99e5a97-6269-489d-b0bb-40be6d7d1d32.png)

Expand Down
20 changes: 10 additions & 10 deletions docs/README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

## Easydict(易词典)

`Easydict` 是一个简洁易用的 Raycast 词典扩展,可轻松优雅地查找单词或翻译文本,特别针对英语和中文单词进行了优化。开箱即用,能自动识别输入文本语言,目前支持 [Linguee](https://www.linguee.com/) 和[有道词典](https://www.youdao.com/)查询,支持 OpenAI ChatGPT, 🍎**苹果系统翻译**,[DeepL](https://www.deepl.com/translator),[谷歌](https://translate.google.com),[Bing](https://www.bing.com/translator), [百度](https://fanyi.baidu.com/),[腾讯](https://fanyi.qq.com/),[火山](https://translate.volcengine.com/translate),[有道](https://fanyi.youdao.com/)和[彩云翻译](https://fanyi.caiyunapp.com/#/)。
`Easydict` 是一个简洁易用的 Raycast 词典扩展,可轻松优雅地查找单词或翻译文本,特别针对英语和中文单词进行了优化。开箱即用,能自动识别输入文本语言,目前支持 [Linguee](https://www.linguee.com/) 和[有道词典](https://www.youdao.com/)查询,支持 OpenAI, 🍎**苹果系统翻译**,[DeepL](https://www.deepl.com/translator),[谷歌](https://translate.google.com),[Bing](https://www.bing.com/translator), [百度](https://fanyi.baidu.com/),[腾讯](https://fanyi.qq.com/),[火山](https://translate.volcengine.com/translate),[有道](https://fanyi.youdao.com/)和[彩云翻译](https://fanyi.caiyunapp.com/#/)。

![easydict-1-1671806758](https://raw.githubusercontent.com/tisfeng/ImageBed/main/uPic/easydict-1-1671806758.png)

Expand All @@ -35,7 +35,7 @@
- [x] 支持系统代理。
- [x] 支持 Linguee 和有道词典查询。
- [x] 支持 macOS 系统翻译。详情请看 [如何在 Easydict 中使用 🍎 macOS 系统翻译?](https://github.com/tisfeng/Raycast-Easydict/blob/main/docs/%E5%A6%82%E4%BD%95%E5%9C%A8Easydict%E4%B8%AD%E4%BD%BF%E7%94%A8macOS%F0%9F%8D%8E%E7%B3%BB%E7%BB%9F%E7%BF%BB%E8%AF%91.md)
- [x] 支持 OpenAI ChatGPT, DeepL,Google,Bing,百度,腾讯,火山,有道和彩云翻译。
- [x] 支持 OpenAI, DeepL,Google,Bing,百度,腾讯,火山,有道和彩云翻译。
- [x] 支持 48+ 种语言。

**如果觉得这个扩展还不错,给个 [Star](https://github.com/tisfeng/Raycast-Easydict) ⭐️ 支持一下吧 (^-^)**
Expand Down Expand Up @@ -66,7 +66,7 @@

![hello-1666060655](https://raw.githubusercontent.com/tisfeng/ImageBed/main/uPic/hello-1666060655.png)

### 有道-现代汉语词典
### 有道 - 现代汉语词典

![xiaxi-1665674049](https://raw.githubusercontent.com/tisfeng/ImageBed/main/uPic/xiaxi-1665674049.png)

Expand Down Expand Up @@ -132,7 +132,7 @@ npm install && npm run dev

## 进阶

实际上,你不需要做任何额外设置它就能工作得很好。 以下是进阶文档,面向那些希望更好地使用 `Easydict` 或想了解该扩展工作原理的用户。
实际上,你不需要做任何额外设置它就能工作得很好。以下是进阶文档,面向那些希望更好地使用 `Easydict` 或想了解该扩展工作原理的用户。

![setting](https://raw.githubusercontent.com/tisfeng/ImageBed/main/uPic/setting-1660917402.png)

Expand All @@ -142,7 +142,7 @@ npm install && npm run dev

#### 语言识别

目前支持百度,腾讯,火山,苹果和 Bing, 总计 5 家语种识别 API。其中苹果语种识别为 macOS 系统功能,但需要安装一个快捷指令才能使用。参考 [如何在 Easydict 中使用 🍎 macOS 系统翻译?](https://github.com/tisfeng/Raycast-Easydict/blob/main/docs/%E5%A6%82%E4%BD%95%E5%9C%A8Easydict%E4%B8%AD%E4%BD%BF%E7%94%A8macOS%F0%9F%8D%8E%E7%B3%BB%E7%BB%9F%E7%BF%BB%E8%AF%91.md)
目前支持百度,腾讯,火山,苹果和 Bing,总计 5 家语种识别 API。其中苹果语种识别为 macOS 系统功能,但需要安装一个快捷指令才能使用。参考 [如何在 Easydict 中使用 🍎 macOS 系统翻译?](https://github.com/tisfeng/Raycast-Easydict/blob/main/docs/%E5%A6%82%E4%BD%95%E5%9C%A8Easydict%E4%B8%AD%E4%BD%BF%E7%94%A8macOS%F0%9F%8D%8E%E7%B3%BB%E7%BB%9F%E7%BF%BB%E8%AF%91.md)

为保护用户隐私,默认只启用了 Bing 语种识别(不需要 App Key,也不会记录任何用户个人数据!),而其他语种识别 API 仅在对应的翻译功能开启时才启用。但注意,通常来说开启的语种识别 API 种类越多,识别文本的准确度会越高,响应速度也会越快。

Expand Down Expand Up @@ -321,7 +321,7 @@ Linguee 默认支持系统代理。
<details> <summary> 查询单词后自动播放单词发音,默认开启。 </summary>

<p>
注意,当该选项开始时,仅当查询的内容被判定为 `is_Word` 且为英语时才会自动播放语音,例如 `good`, `look for` 等。 其他查询内容,可通过快捷键 `Cmd + S` 播放语音。
注意,当该选项开始时,仅当查询的内容被判定为 `is_Word` 且为英语时才会自动播放语音,例如 `good`, `look for` 等。其他查询内容,可通过快捷键 `Cmd + S` 播放语音。
播放语音的内容:英语单词优先采用在线的有道词典发音,其他则使用有道翻译的 TTS 服务(若有有道 App Key)。长文本播放使用 say 命令。
</p>

Expand Down Expand Up @@ -364,9 +364,9 @@ Linguee 默认支持系统代理。

### 支持系统代理

开启该功能后,`Easydict` 会尝试获取 Mac 系统代理,若成功,则后续的网络请求都会通过系统代理发送。默认关闭。 此功能是为了对抗 IP 封锁(某些服务如 Linguee 对 IP 有频率限制),**但开启后会使请求响应速度变慢,因此请仅在有需要时启用。**
开启该功能后,`Easydict` 会尝试获取 Mac 系统代理,若成功,则后续的网络请求都会通过系统代理发送。默认关闭。此功能是为了对抗 IP 封锁(某些服务如 Linguee 对 IP 有频率限制),**但开启后会使请求响应速度变慢,因此请仅在有需要时启用。**

> 注意 ⚠️:请不要在使用抓包工具 MitM 的情况下开启 `Use System Proxy`,否则部分服务请求会报证书错误,例如 https://github.com/tisfeng/Raycast-Easydict/issues/18
> 注意 ⚠️:请不要在使用抓包工具 MitM 的情况下开启 `Use System Proxy`,否则部分服务请求会报证书错误,例如 https://github.com/tisfeng/Raycast-Easydict/issues/18。

### PopClip 调用

Expand All @@ -382,15 +382,15 @@ Linguee 默认支持系统代理。
key combo: command E
```

> 参考: https://github.com/pilotmoon/PopClip-Extensions#extension-snippets-examples
> 参考https://github.com/pilotmoon/PopClip-Extensions#extension-snippets-examples

### 翻译服务

为了方便使用,我们提供了一些内置翻译服务的 appId 和 appKey,但这些服务本身是有请求频率限制的。如果许多人同时使用它们,它可能会变慢甚至停止。因此,为了获得更好的使用体验,您最好申请自己的 appId 和 appKey,替换内置的服务。

别担心,这些翻译服务有免费配额。一般来说个人使用足够了。

下列申请教程来自 [`Bob`](https://bobtranslate.com/guide/advance/service.html), 跟随教程应该很快就能完成申请。
下列申请教程来自 [`Bob`](https://bobtranslate.com/guide/advance/service.html),跟随教程应该很快就能完成申请。

- [有道翻译](https://bobtranslate.com/service/translate/youdao.html):服务需勾选 `文本翻译` 和 `语音合成`。(注:有道向每个账户赠送 50 元体验金,目测可免费使用 1 年以上~)

Expand Down
19 changes: 14 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://www.raycast.com/schemas/extension.json",
"name": "easydict",
"title": "Easy Dictionary",
"description": "Easily look up words or translate text, support 48+ languages, support Linguee and Youdao dictionary, support OpenAI ChatGPT, DeepL, Google, Bing, Apple, Baidu, Tencent, Volcano, Youdao and Caiyun translation.",
"description": "Easily look up words or translate text, support 48+ languages, support Linguee and Youdao dictionary, support OpenAI, DeepL, Google, Bing, Apple, Baidu, Tencent, Volcano, Youdao and Caiyun translation.",
"icon": "Eudic.png",
"author": "isfeng",
"license": "MIT",
Expand Down Expand Up @@ -50,7 +50,7 @@
"baidu",
"tencent",
"eudic",
"chatgpt"
"openai"
],
"dependencies": {
"@raycast/api": "^1.68.0",
Expand Down Expand Up @@ -669,7 +669,7 @@
"default": false
},
{
"title": "Display Order",
"title": "Service List Order",
"name": "servicesOrder",
"type": "textfield",
"required": false,
Expand All @@ -690,8 +690,8 @@
"name": "openAIAPIURL",
"type": "textfield",
"required": false,
"description": "Your OpenAI Endpoint",
"default": "https://api.openai.com/v1/chat/completions"
"description": "Custom OpenAI API URL",
"placeholder": "https://api.openai.com/v1/chat/completions"
},
{
"title": "OpenAI Model",
Expand All @@ -709,6 +709,15 @@
"description": "Your DeepL Auth Key",
"default": ""
},
{
"title": "DeepL API URL",
"name": "deepLEndpoint",
"type": "textfield",
"required": false,
"description": "Custom DeepL API URL",
"placeholder": "https://api-free.deepl.com/v2/translate",
"default": ""
},
{
"title": "Baidu App ID",
"name": "baiduAppId",
Expand Down
15 changes: 7 additions & 8 deletions src/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface MyPreferences {

enableDeepLTranslate: boolean;
deepLAuthKey: string;
deepLEndpoint: string;

enableGoogleTranslate: boolean;

Expand Down Expand Up @@ -74,13 +75,13 @@ export interface MyPreferences {
* * NOTE: Please apply for your own keys as much as possible. Please do not abuse them, otherwise I have to revoke them 😑。
*/
export class AppKeyStore {
static defaultEncryptedDeepLAuthKey =
"U2FsdGVkX190UMu/gorJ/qgwhayFJilCPE5kSfOutkELsUnylfAZEtJGVPin3njGRwC2odphwTigbCzEcJ4kAw==";
private static defaultDeepLAuthKey = myDecrypt(this.defaultEncryptedDeepLAuthKey);
static deepLAuthKey = myPreferences.deepLAuthKey.trim();
static deepLEndpoint = myPreferences.deepLEndpoint.trim();

// This is a official test token from https://open.caiyunapp.com/%E4%BA%94%E5%88%86%E9%92%9F%E5%AD%A6%E4%BC%9A%E5%BD%A9%E4%BA%91%E5%B0%8F%E8%AF%91_API
private static defaultEncryptedCaiyunToken = "U2FsdGVkX1+RTgfMmgZgkD1Phn4FyvzMiMed5BvxnjoqS8QIJ/AFjUJdfC7OqjU3";
private static defaultCaiyunToken = myDecrypt(this.defaultEncryptedCaiyunToken);
static caiyunToken = myPreferences.caiyunToken.trim() || this.defaultCaiyunToken;

// youdao app id and appsecret
static youdaoAppId = myPreferences.youdaoAppId.trim();
Expand All @@ -94,15 +95,13 @@ export class AppKeyStore {
static tencentSecretId = myPreferences.tencentSecretId.trim();
static tencentSecretKey = myPreferences.tencentSecretKey.trim();

static userDeepLAuthKey = myPreferences.deepLAuthKey.trim();

static caiyunToken = myPreferences.caiyunToken.trim() || this.defaultCaiyunToken;

static volcanoSecretId = myPreferences.volcanoAccessKeyId.trim();
static volcanoSecretKey = myPreferences.volcanoAccessKeySecret.trim();

static openAIAPIKey = myPreferences.openAIAPIKey.trim();
static openAIEndpoint = myPreferences.openAIAPIURL.trim() || "https://api.openai.com/v1/chat/completions";

static openAIAPIURL = myPreferences.openAIAPIURL.trim() || "https://api.openai.com/v1/chat/completions";

static openAIModel = myPreferences.openAIModel.trim() || "gpt-3.5-turbo";
}

Expand Down
2 changes: 1 addition & 1 deletion src/releaseVersion/versionInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class Easydict {

## 推荐

我另一个免费开源项目,[Easydict](https://github.com/tisfeng/Easydict) ,一个简洁优雅的词典翻译 macOS App。开箱即用,支持离线 OCR 识别,支持有道词典,🍎 苹果系统词典,🍎 苹果系统翻译,ChatGPT,DeepL,Google,Bing,腾讯,百度,阿里,小牛,彩云和火山翻译。
我另一个免费开源项目,[Easydict](https://github.com/tisfeng/Easydict) ,一个简洁优雅的词典翻译 macOS App。开箱即用,支持离线 OCR 识别,支持有道词典,🍎 苹果系统词典,🍎 苹果系统翻译,OpenAI,DeepL,Google,Bing,腾讯,百度,阿里,小牛,彩云和火山翻译。

![iShot_2023-03-17_18.01.22_11zon-1679050206](https://raw.githubusercontent.com/tisfeng/ImageBed/main/uPic/iShot_2023-03-17_18.01.22_11zon-1679050206.jpg)

Expand Down
Loading
Loading