From 9f597548ae81e63952962f56d48b363138d28871 Mon Sep 17 00:00:00 2001 From: tisfeng Date: Sun, 25 Feb 2024 11:47:15 +0800 Subject: [PATCH 1/4] docs: update README --- README.md | 26 ++++++++++++++++++++------ README_EN.md | 26 ++++++++++++++++++++------ 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0f311a085..8915474d6 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ ## Easydict -`Easydict` 是一个简洁易用的词典翻译 macOS App,能够轻松优雅地查找单词或翻译文本。Easydict 开箱即用,能自动识别输入文本语言,支持输入翻译,划词翻译和 OCR 截图翻译,可同时查询多个翻译服务结果,目前支持 [有道词典](https://www.youdao.com/),[**🍎 苹果系统词典**](./docs/How-to-use-macOS-system-dictionary-in-Easydict-zh.md),[🍎 **苹果系统翻译**](./docs/How-to-use-macOS-system-translation-in-Easydict-zh.md),[OpenAI (ChatGPT)](https://chat.openai.com/),[DeepL](https://www.deepl.com/translator),[Google](https://translate.google.com),[腾讯](https://fanyi.qq.com/),[Bing](https://www.bing.com/translator),[百度](https://fanyi.baidu.com/),[小牛翻译](https://niutrans.com/),[彩云小译](https://fanyi.caiyunapp.com/),[阿里翻译](https://translate.alibaba.com/) 和 [火山翻译](https://translate.volcengine.com/translate)。 +`Easydict` 是一个简洁易用的词典翻译 macOS App,能够轻松优雅地查找单词或翻译文本。Easydict 开箱即用,能自动识别输入文本语言,支持输入翻译,划词翻译和 OCR 截图翻译,可同时查询多个翻译服务结果,目前支持 [有道词典](https://www.youdao.com/),[**🍎 苹果系统词典**](./docs/How-to-use-macOS-system-dictionary-in-Easydict-zh.md),[🍎 **苹果系统翻译**](./docs/How-to-use-macOS-system-translation-in-Easydict-zh.md),[OpenAI (ChatGPT)](https://chat.openai.com/),[Gemini](https://gemini.google.com/),[DeepL](https://www.deepl.com/translator),[Google](https://translate.google.com),[腾讯](https://fanyi.qq.com/),[Bing](https://www.bing.com/translator),[百度](https://fanyi.baidu.com/),[小牛翻译](https://niutrans.com/),[彩云小译](https://fanyi.caiyunapp.com/),[阿里翻译](https://translate.alibaba.com/) 和 [火山翻译](https://translate.volcengine.com/translate)。 ![Log](https://raw.githubusercontent.com/tisfeng/ImageBed/main/uPic/Log-1688378715.png) @@ -42,7 +42,7 @@ - [x] 支持系统 TTS,支持 Bing,Google,有道和百度在线 TTS 服务。 - [x] 支持 [🍎 苹果系统词典](./docs/How-to-use-macOS-system-dictionary-in-Easydict-zh.md),支持第三方词典,可手动导入 mdict 词典。 - [x] 支持 macOS 系统翻译。详情请看 [如何在 Easydict 中使用 🍎 macOS 系统翻译?](./docs/How-to-use-macOS-system-translation-in-Easydict-zh.md) -- [x] 支持有道词典,OpenAI (ChatGPT),DeepL,Google,Bing,腾讯,百度,小牛,彩云,阿里和火山翻译。 +- [x] 支持有道词典,OpenAI (ChatGPT),Gemini,DeepL,Google,Bing,腾讯,百度,小牛,彩云,阿里和火山翻译。 - [x] 支持 48 种语言。 **如果觉得这个应用还不错,给个 [Star](https://github.com/tisfeng/Easydict) ⭐️ 支持一下吧 (^-^)** @@ -74,10 +74,11 @@ - [查询服务](#查询服务) - [🍎 苹果系统词典](#-苹果系统词典) - [OpenAI(ChatGPT)翻译](#openaichatgpt翻译) - - [使用内置 Gemini key](#使用内置-gemini-key) + - [使用内置 APIKey](#使用内置-apikey) - [配置个人的 APIKey](#配置个人的-apikey) - [OpenAI 查询模式](#openai-查询模式) - [OpenAI 自定义参数](#openai-自定义参数) + - [Gemini 翻译](#gemini-翻译) - [DeepL 翻译](#deepl-翻译) - [配置 AuthKey](#配置-authkey) - [自定义 DeepL 接口地址](#自定义-deepl-接口地址) @@ -350,11 +351,16 @@ Easydict 自动支持词典 App 中系统自带的词典,如牛津英汉汉英 例如 [one-api](https://github.com/songquanpeng/one-api),one-api 是一个很好的 OpenAI 接口管理开源项目,支持多家 LLM 接口,包括 Azure、Anthropic Claude、Google PaLM 2 & Gemini、智谱 ChatGLM、百度文心一言、讯飞星火认知、阿里通义千问、360 智脑以及腾讯混元等,可用于二次分发管理 key,仅单可执行文件,已打包好 Docker 镜像,一键部署,开箱即用。 -目前 GUI 方式配置 API key 功能还在开发中 [[#227](https://github.com/tisfeng/Easydict/issues/227)],暂时需要在 Easydict 的输入框中使用命令方式配置。 +[2.6.0](https://github.com/tisfeng/Easydict/releases) 版本实现了新的 SwiftUI 设置页(支持 macOS 13+),支持 GUI 方式配置服务 API key,其他则需要在 Easydict 的输入框中使用命令方式配置。 -#### 使用内置 Gemini key +> [!NOTE] +> 如果电脑硬件支持的话,建议升级到最新的 macOS 系统,以享受更好的用户体验。 + +![](https://github.com/tisfeng/Easydict/assets/25194972/5b8f2785-b0ee-4a9e-bd41-1a9dd56b0231) -目前 Google 的 Gemini API 免费,实测下来翻译效果不错,由于项目对 Gemini 支持 [#270](https://github.com/tisfeng/Easydict/issues/270) 还在开发中,可能需要一点时间,因此我内置了一个 key,方便用户直接使用 Gemini 模型来翻译。但请注意,这个 key 有一定使用限制且不稳定,因此如果有能力部署 one-api,建议优先使用自己的 APIKey。 +#### 使用内置 APIKey + +目前 Google 的 Gemini API 免费,实测下来翻译效果不错,为方便用户使用,我内置了一个 key。但请注意,这个 key 有一定使用限制且不稳定,因此如果有能力部署 one-api,建议优先使用自己的 APIKey。 在 Beta 模式下,并且没有设置自己的 APIKey,这样就会自动使用内置的 Gemini key。 @@ -425,6 +431,14 @@ easydict://writeKeyValue?EZOpenAIModelKey=xxx 由于 OpenAI 官方接口对用户 IP 有限制,因此如果你需要反向代理,可以参考这个反代项目 [cloudflare-reverse-proxy](https://github.com/gaboolic/cloudflare-reverse-proxy) +### Gemini 翻译 + +[Gemini 翻译](https://gemini.google.com/) 需要 API key,可在官网[控制台](https://makersuite.google.com/app/apikey)免费获取。 + +```bash +easydict://writeKeyValue?EZGeminiAPIKey=xxx +``` + ### DeepL 翻译 DeepL 免费版网页 API 对用户单个 IP 有频率限制,频繁使用会触发 429 too many requests 报错,因此 1.3.0 版本增加了对 DeepL 官方 API 的支持,暂时还没写界面,需通过命令方式启用。 diff --git a/README_EN.md b/README_EN.md index b841325fa..cddaf1576 100644 --- a/README_EN.md +++ b/README_EN.md @@ -20,7 +20,7 @@ ## Easydict -`Easydict` is a concise and easy-to-use translation dictionary macOS App that allows you to easily and elegantly look up words or translate text. Easydict is ready to use out of the box, can automatically recognize the language of the input text, supports input translate, select translate, and OCR screenshot translate, and can query multiple translation services results at the same time. Currently, it supports [Youdao Dictionary](https://www.youdao.com/), [**🍎 Apple System Dictionary**](./docs/How-to-use-macOS-system-dictionary-in-Easydict-en.md), [**🍎 macOS System Translation**](./docs/How-to-use-macOS-system-dictionary-in-Easydict-zh.md), [OpenAI(ChatGPT)](https://chat.openai.com/), [DeepL](https://www.deepl.com/translator), [Google](https://translate.google.com/), [Tencent](https://fanyi.qq.com/), [Bing](https://www.bing.com/translator), [Baidu](https://fanyi.baidu.com/), [Niutrans](https://niutrans.com/), [Lingocloud](https://fanyi.caiyunapp.com/#/), [Ali Translate](https://translate.alibaba.com/) and [Volcano Translation](https://translate.volcengine.com/translate). +`Easydict` is a concise and easy-to-use translation dictionary macOS App that allows you to easily and elegantly look up words or translate text. Easydict is ready to use out of the box, can automatically recognize the language of the input text, supports input translate, select translate, and OCR screenshot translate, and can query multiple translation services results at the same time. Currently, it supports [Youdao Dictionary](https://www.youdao.com/), [**🍎 Apple System Dictionary**](./docs/How-to-use-macOS-system-dictionary-in-Easydict-en.md), [**🍎 macOS System Translation**](./docs/How-to-use-macOS-system-dictionary-in-Easydict-zh.md), [OpenAI(ChatGPT)](https://chat.openai.com/), [Gemini](https://gemini.google.com/), [DeepL](https://www.deepl.com/translator), [Google](https://translate.google.com/), [Tencent](https://fanyi.qq.com/), [Bing](https://www.bing.com/translator), [Baidu](https://fanyi.baidu.com/), [Niutrans](https://niutrans.com/), [Lingocloud](https://fanyi.caiyunapp.com/#/), [Ali Translate](https://translate.alibaba.com/) and [Volcano Translation](https://translate.volcengine.com/translate). ![Log](https://raw.githubusercontent.com/tisfeng/ImageBed/main/uPic/Log-1688378715.png) @@ -41,7 +41,7 @@ - [x] Support system TTS, along with online services from Bing, Google, Youdao and Baidu Cloud. - [x] Support [🍎 Apple System Dictionary](./docs/How-to-use-macOS-system-dictionary-in-Easydict-en.md), support third-party dictionaries with manual mdict dictionaries import functionalities. - [x] Support macOS system translation. (_Please see [How to use 🍎 macOS system translation in Easydict?](./docs/How-to-use-macOS-system-dictionary-in-Easydict-en.md)_) -- [x] Support Youdao Dictionary, DeepL, OpenAI (ChatGPT), Google, Tencent, Bing, Baidu, Niutrans, Lingocloud, Ali and Volcano Translate. +- [x] Support Youdao Dictionary, DeepL, OpenAI (ChatGPT), Gemini, Google, Tencent, Bing, Baidu, Niutrans, Lingocloud, Ali and Volcano Translate. - [x] Support for 48 languages. **If you like this app, please consider giving it a [Star](https://github.com/tisfeng/Easydict) ⭐️, thanks! (^-^)** @@ -73,10 +73,11 @@ We plan to refactor the project with Swift. If you are interested in this open s - [Translation Services](#translation-services) - [🍎 Apple System Dictionary](#-apple-system-dictionary) - [OpenAI (ChatGPT) Translation](#openai-chatgpt-translation) - - [Use the built-in Gemini key](#use-the-built-in-gemini-key) + - [Using the built-in APIKey](#using-the-built-in-apikey) - [Configure Personal APIKey](#configure-personal-apikey) - [OpenAI Query Mode](#openai-query-mode) - [OpenAI Custom Settings](#openai-custom-settings) + - [Gemini Translate](#gemini-translate) - [DeepL Translate](#deepl-translate) - [Configure AuthKey](#configure-authkey) - [Configure API endpoint](#configure-api-endpoint) @@ -348,11 +349,16 @@ If you don't have your own OpenAI APIKey, you can use some open source projects For example, [one-api](https://github.com/songquanpeng/one-api), one-api is a good open source project for OpenAI interface management, which supports multiple LLM interfaces, including Azure, Anthropic Claude, Google PaLM 2 & Gemini, Zhupu ChatGLM, Baidu Wenxin Yiyu, Xunfei Xinghuo cognition, Ali Tongyi Qianwen, 360 Zhinao and Tencent Hunyuan, etc., which can be used for secondary distribution management key, only single executable file, Docker image has been packaged, one-click deployment, out of the box. -Currently, the GUI method of configuring API key is still under development [#227](https://github.com/tisfeng/Easydict/issues/227), so you need to configure it in the input box of Easydict in command mode for the time being. +The [2.6.0](https://github.com/tisfeng/Easydict/releases) version implements a new SwiftUI settings page (macOS 13+ support), which supports configuring the service API key in a GUI way, other system verions need to be configured using commands in Easydict's input box. -#### Use the built-in Gemini key +> [!NOTE] +> If your computer hardware supports it, it is recommended to upgrade to the latest macOS system to enjoy a better user experience. + +![](https://github.com/tisfeng/Easydict/assets/25194972/5b8f2785-b0ee-4a9e-bd41-1a9dd56b0231) -Currently, Google's Gemini API is free, and the translation effect is good. Since the project's support for Gemini [#270](https://github.com/tisfeng/Easydict/issues/270), it may take some time, so I have built in a key to facilitate users to use the Gemini model directly for translation. However, please note that this key has certain usage restrictions and is unstable, so if you have the ability to deploy one-api, it is recommended to use your own APIKey first. +#### Using the built-in APIKey + +Currently Google's Gemini API is free, the translation effect is good, in order to facilitate the use of users, I built-in a key, but please note that the use of this key has some limitations and is not stable, so if you have the ability to deploy one-api, it is recommended to prioritize the use of their own APIKey. In Beta mode, and no APIKey is set, so the built-in Gemini key will be used automatically. @@ -423,6 +429,14 @@ easydict://writeKeyValue?EZOpenAIModelKey=xxx Since the official OpenAI interface has restrictions on user IPs, if you need a reverse proxy, you can refer to this project [cloudflare-reverse-proxy](https://github.com/gaboolic/cloudflare-reverse-proxy) +### Gemini Translate ## + +[Gemini Translation](https://gemini.google.com/) requires an API key, which can be obtained for free on the official website [Console](https://makersuite.google.com/app/apikey). + +```bash +easydict://writeKeyValue?EZGeminiAPIKey=xxx +``` + ### DeepL Translate DeepL free version web API has a frequency limit for single IP, frequent use will trigger 429 too many requests error, so version 1.3.0 adds support for DeepL official API, but the interface has not been written yet, and needs to be enabled through command. From 74389fd918b86e06445755d83223f10e70b56083 Mon Sep 17 00:00:00 2001 From: tisfeng Date: Sun, 25 Feb 2024 12:28:49 +0800 Subject: [PATCH 2/4] docs: remove Signature Problem --- README.md | 31 ------------------------------- README_EN.md | 31 ------------------------------- 2 files changed, 62 deletions(-) diff --git a/README.md b/README.md index 8915474d6..d9d4f692d 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,6 @@ - [2. Homebrew 安装](#2-homebrew-安装) - [开发者构建](#开发者构建) - [构建环境](#构建环境) - - [签名问题 ⚠️](#签名问题-️) - [使用](#使用) - [鼠标划词](#鼠标划词) - [关于权限](#关于权限) @@ -161,36 +160,6 @@ Xcode 13+, macOS Big Sur 11.3+。为避免不必要的问题,建议使用最 -### 签名问题 ⚠️ - -Easydict 是开源软件,本身是安全的,但由于苹果严格的检查机制,打开时可能会遇到警告拦截。 - -常见问题 - -1. 如果遇到下面 [无法打开 Easydict 问题](https://github.com/tisfeng/Easydict/issues/2),请参考苹果使用手册 [打开来自身份不明开发者的 Mac App](https://support.apple.com/zh-cn/guide/mac-help/mh40616/mac) - -> 无法打开“Easydict.dmg”,因为它来自身份不明的开发者。 - -
- - - -
- -
- -
- -2. 如果提示应用已损坏,请参考 [macOS 绕过公证和应用签名方法](https://www.5v13.com/sz/31695.html) - -> “Easydict”已损坏,无法打开。 - -在终端里输入以下命令,并输入密码即可。 - -```bash -sudo xattr -rd com.apple.quarantine /Applications/Easydict.app -``` - --- ## 使用 diff --git a/README_EN.md b/README_EN.md index cddaf1576..b059cd222 100644 --- a/README_EN.md +++ b/README_EN.md @@ -63,7 +63,6 @@ We plan to refactor the project with Swift. If you are interested in this open s - [2. Homebrew](#2-homebrew) - [Developer Build](#developer-build) - [Build Environment](#build-environment) - - [Signature Problem ⚠️](#signature-problem-️) - [Usage](#usage) - [Select text by Mouse](#select-text-by-mouse) - [About Permissions](#about-permissions) @@ -160,36 +159,6 @@ If the run encounters the following error, try updating CocoaPods and then `pod -### Signature Problem ⚠️ - -Easydict is open source software and is inherently secure, but due to Apple's strict checking mechanism, you may encounter warning blocks when opening it. - -FAQ: - -1. If you encounter the following [Cannot open Easydict problem](https://github.com/tisfeng/Easydict/issues/2), please refer to [Open Mac App from an unidentified developer](https://support.apple.com/en-us/guide/mac-help/mh40616/mac) - -> Cannot open "Easydict.dmg" because Apple cannot check to see if it contains malware. - -
- - - -
- -
- -
- -2. If it indicates that the app is corrupted, please refer to [macOS Bypassing Notary and App Signing Methods](https://www.5v13.com/sz/31695.html) - -> "Easydict" is corrupted and cannot be opened. - -Just type the following command in the terminal and enter the password. - -```bash -sudo xattr -rd com.apple.quarantine /Applications/Easydict.app -``` - --- ## Usage From 288837968030595bed01f59ca77b563fca082695 Mon Sep 17 00:00:00 2001 From: phlpsong <103433299+phlpsong@users.noreply.github.com> Date: Sun, 25 Feb 2024 13:08:26 +0800 Subject: [PATCH 3/4] fix: service toggle issue after switch focus (#424) * fix: service toggle issue after switch focus * fix: onChange modifier issue --------- Co-authored-by: Tisfeng --- .../View/SettingView/Tabs/ServiceTab.swift | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/Easydict/NewApp/View/SettingView/Tabs/ServiceTab.swift b/Easydict/NewApp/View/SettingView/Tabs/ServiceTab.swift index 77a0f5a1c..939c60c39 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/ServiceTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/ServiceTab.swift @@ -121,28 +121,29 @@ private struct ServiceItems: View { } } +private class ServiceItemViewModel: ObservableObject { + @Published var isEnable = false + + init(isEnable: Bool) { + self.isEnable = isEnable + } +} + @available(macOS 13.0, *) private struct ServiceItemView: View { let service: QueryService @EnvironmentObject private var viewModel: ServiceTabViewModel - private var enabled: Binding { - .init { - service.enabled - } set: { newValue in - guard service.enabled != newValue else { return } - service.enabled = newValue - if newValue { - service.enabledQuery = newValue - } - EZLocalStorage.shared().setService(service, windowType: viewModel.windowType) - viewModel.postUpdateServiceNotification() - } + @ObservedObject private var serviceItemViewModel: ServiceItemViewModel + + init(service: QueryService) { + self.service = service + serviceItemViewModel = ServiceItemViewModel(isEnable: service.enabled) } var body: some View { - Toggle(isOn: enabled) { + Toggle(isOn: $serviceItemViewModel.isEnable) { HStack { Image(service.serviceType().rawValue) .resizable() @@ -153,6 +154,15 @@ private struct ServiceItemView: View { .fixedSize() } } + .onReceive(serviceItemViewModel.$isEnable) { newValue in + guard service.enabled != newValue else { return } + service.enabled = newValue + if newValue { + service.enabledQuery = newValue + } + EZLocalStorage.shared().setService(service, windowType: viewModel.windowType) + viewModel.postUpdateServiceNotification() + } .padding(4.0) .toggleStyle(.switch) .controlSize(.small) From 4e7fbbbd10c46f67b37460acc5c1a1f3358750ce Mon Sep 17 00:00:00 2001 From: tisfeng Date: Sun, 25 Feb 2024 16:02:04 +0800 Subject: [PATCH 4/4] perf: use EasydictApp.main() only if available macOS 13 --- Easydict/NewApp/EasydictApp.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Easydict/NewApp/EasydictApp.swift b/Easydict/NewApp/EasydictApp.swift index 9743e4dc4..1bacd010f 100644 --- a/Easydict/NewApp/EasydictApp.swift +++ b/Easydict/NewApp/EasydictApp.swift @@ -14,7 +14,7 @@ import SwiftUI enum EasydictCmpatibilityEntry { static func main() { parseArmguments() - if NewAppManager.shared.enable { + if #available(macOS 13, *), NewAppManager.shared.enable { EasydictApp.main() } else { _ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)