From 5bf39b8c6d23646341f6d0f66eb0c93d7ca82e6d Mon Sep 17 00:00:00 2001 From: Public <20666312+lol2025@users.noreply.github.com> Date: Wed, 13 Sep 2023 17:16:53 +0800 Subject: [PATCH] Added Deepl API Pro interface (for Chinese users) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deepl is not yet operational in China, and Chinese users do not have access to the API, but they can get it via https://deepl-pro.com 目前Deepl尚未在中国开展业务,中国用户无法获取到API,但是他们可以通过https://deepl-pro.com 获取 --- src/common/translate.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/translate.js b/src/common/translate.js index 5286f11e1..451b1887c 100644 --- a/src/common/translate.js +++ b/src/common/translate.js @@ -74,9 +74,12 @@ const sendRequestToDeepL = async (word, sourceLang, targetLang) => { params.append("auth_key", authKey); params.append("text", word); params.append("target_lang", targetLang); - const url = getSettings("deeplPlan") === "deeplFree" ? - "https://api-free.deepl.com/v2/translate" : - "https://api.deepl.com/v2/translate"; + const url = + getSettings("deeplPlan") === "deeplFree" + ? "https://api-free.deepl.com/v2/translate" + : authKey.endsWith(":dp") + ? "https://api.deepl-pro.com/v2/translate" + : "https://api.deepl.com/v2/translate"; const result = await axios.post(url, params).catch(e => e.response); const resultData = {