From 60d788288d8babd8aece18e46811718d3e8aa905 Mon Sep 17 00:00:00 2001 From: Gabe Yuan Date: Mon, 1 Apr 2024 11:50:29 +0800 Subject: [PATCH] feat: add more custom apis --- src/config/index.js | 25 +++++++++++++++++++------ src/views/Options/Apis.js | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/config/index.js b/src/config/index.js index 8d63161..a70ab2d 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -102,6 +102,10 @@ export const OPT_TRANS_OPENAI = "OpenAI"; export const OPT_TRANS_GEMINI = "Gemini"; export const OPT_TRANS_CLOUDFLAREAI = "CloudflareAI"; export const OPT_TRANS_CUSTOMIZE = "Custom"; +export const OPT_TRANS_CUSTOMIZE_2 = "Custom2"; +export const OPT_TRANS_CUSTOMIZE_3 = "Custom3"; +export const OPT_TRANS_CUSTOMIZE_4 = "Custom4"; +export const OPT_TRANS_CUSTOMIZE_5 = "Custom5"; export const OPT_TRANS_ALL = [ OPT_TRANS_GOOGLE, OPT_TRANS_MICROSOFT, @@ -114,6 +118,10 @@ export const OPT_TRANS_ALL = [ 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, ]; export const OPT_LANGS_TO = [ @@ -400,6 +408,12 @@ export const DEFAULT_SUBRULES_LIST = [ ]; // 翻译接口 +const defaultCustomApi = { + url: "", + key: "", + fetchLimit: DEFAULT_FETCH_LIMIT, + fetchInterval: DEFAULT_FETCH_INTERVAL, +}; export const DEFAULT_TRANS_APIS = { [OPT_TRANS_GOOGLE]: { url: "https://translate.googleapis.com/translate_a/single", @@ -457,12 +471,11 @@ export const DEFAULT_TRANS_APIS = { fetchLimit: 1, fetchInterval: 500, }, - [OPT_TRANS_CUSTOMIZE]: { - url: "", - key: "", - fetchLimit: DEFAULT_FETCH_LIMIT, - fetchInterval: DEFAULT_FETCH_INTERVAL, - }, + [OPT_TRANS_CUSTOMIZE]: defaultCustomApi, + [OPT_TRANS_CUSTOMIZE_2]: defaultCustomApi, + [OPT_TRANS_CUSTOMIZE_3]: defaultCustomApi, + [OPT_TRANS_CUSTOMIZE_4]: defaultCustomApi, + [OPT_TRANS_CUSTOMIZE_5]: defaultCustomApi, }; // 默认快捷键 diff --git a/src/views/Options/Apis.js b/src/views/Options/Apis.js index 6c56ce9..2a022ac 100644 --- a/src/views/Options/Apis.js +++ b/src/views/Options/Apis.js @@ -208,7 +208,7 @@ function ApiFields({ translator }) { - {translator === OPT_TRANS_CUSTOMIZE && ( + {translator.startsWith(OPT_TRANS_CUSTOMIZE) && (
{i18n("custom_api_help")}
)}