From 092ea6e8368b34aa46d6efeb8e69e7c8f7090524 Mon Sep 17 00:00:00 2001 From: Gabe Yuan Date: Wed, 10 Apr 2024 13:37:16 +0800 Subject: [PATCH] fix: custom api --- src/apis/index.js | 8 ++++++++ src/config/index.js | 16 ++++++++++++++++ src/libs/req.js | 8 ++++++++ 3 files changed, 32 insertions(+) diff --git a/src/apis/index.js b/src/apis/index.js index 8961934..2cd94ba 100644 --- a/src/apis/index.js +++ b/src/apis/index.js @@ -12,6 +12,10 @@ import { OPT_TRANS_GEMINI, OPT_TRANS_CLOUDFLAREAI, OPT_TRANS_CUSTOMIZE, + OPT_TRANS_CUSTOMIZE_2, + OPT_TRANS_CUSTOMIZE_3, + OPT_TRANS_CUSTOMIZE_4, + OPT_TRANS_CUSTOMIZE_5, URL_CACHE_TRAN, KV_SALT_SYNC, URL_BAIDU_LANGDETECT, @@ -245,6 +249,10 @@ export const apiTranslate = async ({ isSame = text === trText; break; case OPT_TRANS_CUSTOMIZE: + case OPT_TRANS_CUSTOMIZE_2: + case OPT_TRANS_CUSTOMIZE_3: + case OPT_TRANS_CUSTOMIZE_4: + case OPT_TRANS_CUSTOMIZE_5: trText = res.text; isSame = to === res.from; break; diff --git a/src/config/index.js b/src/config/index.js index 9d520a5..fd430b6 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -266,6 +266,22 @@ export const OPT_LANGS_SPECIAL = { ...OPT_LANGS_FROM.map(([key]) => [key, key]), ["auto", ""], ]), + [OPT_TRANS_CUSTOMIZE_2]: new Map([ + ...OPT_LANGS_FROM.map(([key]) => [key, key]), + ["auto", ""], + ]), + [OPT_TRANS_CUSTOMIZE_3]: new Map([ + ...OPT_LANGS_FROM.map(([key]) => [key, key]), + ["auto", ""], + ]), + [OPT_TRANS_CUSTOMIZE_4]: new Map([ + ...OPT_LANGS_FROM.map(([key]) => [key, key]), + ["auto", ""], + ]), + [OPT_TRANS_CUSTOMIZE_5]: new Map([ + ...OPT_LANGS_FROM.map(([key]) => [key, key]), + ["auto", ""], + ]), }; export const OPT_LANGS_LIST = OPT_LANGS_TO.map(([lang]) => lang); export const OPT_LANGS_BAIDU = new Map( diff --git a/src/libs/req.js b/src/libs/req.js index a2e287c..31b15d4 100644 --- a/src/libs/req.js +++ b/src/libs/req.js @@ -11,6 +11,10 @@ import { OPT_TRANS_GEMINI, OPT_TRANS_CLOUDFLAREAI, OPT_TRANS_CUSTOMIZE, + OPT_TRANS_CUSTOMIZE_2, + OPT_TRANS_CUSTOMIZE_3, + OPT_TRANS_CUSTOMIZE_4, + OPT_TRANS_CUSTOMIZE_5, URL_MICROSOFT_TRAN, URL_TENCENT_TRANSMART, PROMPT_PLACE_FROM, @@ -310,6 +314,10 @@ export const newTransReq = ({ translator, text, from, to }, apiSetting) => { case OPT_TRANS_CLOUDFLAREAI: return genCloudflareAI(args); case OPT_TRANS_CUSTOMIZE: + case OPT_TRANS_CUSTOMIZE_2: + case OPT_TRANS_CUSTOMIZE_3: + case OPT_TRANS_CUSTOMIZE_4: + case OPT_TRANS_CUSTOMIZE_5: return genCustom(args); default: throw new Error(`[trans] translator: ${translator} not support`);