From 7109424f0e017b84a41b4be2a28b1a9d9f50be95 Mon Sep 17 00:00:00 2001 From: Pylogmon Date: Thu, 20 Jun 2024 19:47:35 +0800 Subject: [PATCH] refactor: remove unnecessary service --- src/i18n/locales/en_US.json | 36 -- .../translate/chatglm_custom/Config.jsx | 194 ---------- .../translate/chatglm_custom/index.jsx | 101 ------ src/services/translate/chatglm_custom/info.ts | 38 -- .../translate/chatglm_polish/Config.jsx | 196 ---------- .../translate/chatglm_polish/index.jsx | 101 ------ src/services/translate/chatglm_polish/info.ts | 38 -- .../translate/chatglm_summary/Config.jsx | 196 ---------- .../translate/chatglm_summary/index.jsx | 101 ------ .../translate/chatglm_summary/info.ts | 38 -- .../translate/geminipro_custom/Config.jsx | 210 ----------- .../translate/geminipro_custom/index.jsx | 141 -------- .../translate/geminipro_custom/info.ts | 38 -- .../translate/geminipro_polish/Config.jsx | 226 ------------ .../translate/geminipro_polish/index.jsx | 141 -------- .../translate/geminipro_polish/info.ts | 38 -- .../translate/geminipro_summary/Config.jsx | 226 ------------ .../translate/geminipro_summary/index.jsx | 141 -------- .../translate/geminipro_summary/info.ts | 38 -- src/services/translate/index.jsx | 24 -- .../translate/ollama_custom/Config.jsx | 336 ------------------ .../translate/ollama_custom/index.jsx | 54 --- src/services/translate/ollama_custom/info.ts | 38 -- .../translate/ollama_polish/Config.jsx | 336 ------------------ .../translate/ollama_polish/index.jsx | 54 --- src/services/translate/ollama_polish/info.ts | 38 -- .../translate/ollama_summary/Config.jsx | 336 ------------------ .../translate/ollama_summary/index.jsx | 54 --- src/services/translate/ollama_summary/info.ts | 38 -- .../translate/openai_custom/Config.jsx | 300 ---------------- .../translate/openai_custom/index.jsx | 155 -------- src/services/translate/openai_custom/info.ts | 38 -- .../translate/openai_polish/Config.jsx | 298 ---------------- .../translate/openai_polish/index.jsx | 155 -------- src/services/translate/openai_polish/info.ts | 38 -- .../translate/openai_summary/Config.jsx | 298 ---------------- .../translate/openai_summary/index.jsx | 155 -------- src/services/translate/openai_summary/info.ts | 38 -- 38 files changed, 5021 deletions(-) delete mode 100644 src/services/translate/chatglm_custom/Config.jsx delete mode 100644 src/services/translate/chatglm_custom/index.jsx delete mode 100644 src/services/translate/chatglm_custom/info.ts delete mode 100644 src/services/translate/chatglm_polish/Config.jsx delete mode 100644 src/services/translate/chatglm_polish/index.jsx delete mode 100644 src/services/translate/chatglm_polish/info.ts delete mode 100644 src/services/translate/chatglm_summary/Config.jsx delete mode 100644 src/services/translate/chatglm_summary/index.jsx delete mode 100644 src/services/translate/chatglm_summary/info.ts delete mode 100644 src/services/translate/geminipro_custom/Config.jsx delete mode 100644 src/services/translate/geminipro_custom/index.jsx delete mode 100644 src/services/translate/geminipro_custom/info.ts delete mode 100644 src/services/translate/geminipro_polish/Config.jsx delete mode 100644 src/services/translate/geminipro_polish/index.jsx delete mode 100644 src/services/translate/geminipro_polish/info.ts delete mode 100644 src/services/translate/geminipro_summary/Config.jsx delete mode 100644 src/services/translate/geminipro_summary/index.jsx delete mode 100644 src/services/translate/geminipro_summary/info.ts delete mode 100644 src/services/translate/ollama_custom/Config.jsx delete mode 100644 src/services/translate/ollama_custom/index.jsx delete mode 100644 src/services/translate/ollama_custom/info.ts delete mode 100644 src/services/translate/ollama_polish/Config.jsx delete mode 100644 src/services/translate/ollama_polish/index.jsx delete mode 100644 src/services/translate/ollama_polish/info.ts delete mode 100644 src/services/translate/ollama_summary/Config.jsx delete mode 100644 src/services/translate/ollama_summary/index.jsx delete mode 100644 src/services/translate/ollama_summary/info.ts delete mode 100644 src/services/translate/openai_custom/Config.jsx delete mode 100644 src/services/translate/openai_custom/index.jsx delete mode 100644 src/services/translate/openai_custom/info.ts delete mode 100644 src/services/translate/openai_polish/Config.jsx delete mode 100644 src/services/translate/openai_polish/index.jsx delete mode 100644 src/services/translate/openai_polish/info.ts delete mode 100644 src/services/translate/openai_summary/Config.jsx delete mode 100644 src/services/translate/openai_summary/index.jsx delete mode 100644 src/services/translate/openai_summary/info.ts diff --git a/src/i18n/locales/en_US.json b/src/i18n/locales/en_US.json index e9f9f17935..23f1501822 100644 --- a/src/i18n/locales/en_US.json +++ b/src/i18n/locales/en_US.json @@ -257,15 +257,6 @@ "prompt_description": "By customizing the Prompt, you can customize the behavior of AI. $text $from $to $detect will be replaced with the text to be translated, source language, target language and detected language.", "add": "Add Prompt" }, - "ollama_polish": { - "title": "Ollama Polish" - }, - "ollama_summary": { - "title": "Ollama Summary" - }, - "ollama_custom": { - "title": "Ollama Custom" - }, "openai": { "title": "OpenAI", "service": "Service Provider", @@ -278,15 +269,6 @@ "prompt_description": "By customizing the Prompt, you can customize the behavior of OpenAI. $text $from $to $detect will be replaced with the text to be translated, source language, target language and detected language.", "add": "Add Prompt" }, - "openai_summary": { - "title": "OpenAI Summary" - }, - "openai_polish": { - "title": "OpenAI Polish" - }, - "openai_custom": { - "title": "OpenAI Custom" - }, "geminipro": { "title": "Gemini Pro", "request_path": "Request Path", @@ -295,15 +277,6 @@ "prompt_description": "By customizing the Prompt, you can customize the behavior of Gemini Pro. $text $from $to $detect will be replaced with the text to be translated, source language, target language and detected language.", "add": "Add Prompt" }, - "geminipro_summary": { - "title": "Gemini Pro Summary" - }, - "geminipro_polish": { - "title": "Gemini Pro Polish" - }, - "geminipro_custom": { - "title": "Gemini Pro Custom" - }, "chatglm": { "title": "ChatGLM", "model": "Model", @@ -315,15 +288,6 @@ "prompt_description": "By customizing the Prompt, you can customize the behavior of AI. $text $from $to $detect will be replaced with the text to be translated, source language, target language and detected language.", "add": "Add Prompt" }, - "chatglm_summary": { - "title": "ChatGLM Summary" - }, - "chatglm_polish": { - "title": "ChatGLM Polish" - }, - "chatglm_custom": { - "title": "ChatGLM Custom" - }, "yandex": { "title": "Yandex" }, diff --git a/src/services/translate/chatglm_custom/Config.jsx b/src/services/translate/chatglm_custom/Config.jsx deleted file mode 100644 index d2b7e9c71d..0000000000 --- a/src/services/translate/chatglm_custom/Config.jsx +++ /dev/null @@ -1,194 +0,0 @@ -import { Input, Button, Textarea } from '@nextui-org/react'; -import { DropdownTrigger } from '@nextui-org/react'; -import { MdDeleteOutline } from 'react-icons/md'; -import { DropdownMenu } from '@nextui-org/react'; -import { DropdownItem } from '@nextui-org/react'; -import toast, { Toaster } from 'react-hot-toast'; -import { useTranslation } from 'react-i18next'; -import { Dropdown } from '@nextui-org/react'; -import { open } from '@tauri-apps/api/shell'; -import React, { useState } from 'react'; - -import { useConfig } from '../../../hooks/useConfig'; -import { useToastStyle } from '../../../hooks'; -import { translate } from './index'; -import { Language } from './index'; - -export function Config(props) { - const { updateServiceList, onClose } = props; - const [serviceConfig, setServiceConfig] = useConfig( - 'chatglm_custom', - { - model: 'chatglm_turbo', - apiKey: '', - promptList: [ - { - role: 'user', - content: 'Hello', - }, - ], - }, - { sync: false } - ); - const [isLoading, setIsLoading] = useState(false); - - const { t } = useTranslation(); - const toastStyle = useToastStyle(); - - return ( - serviceConfig !== null && ( -
{ - e.preventDefault(); - setIsLoading(true); - translate('hello', Language.auto, Language.zh_cn, { config: serviceConfig }).then( - () => { - setIsLoading(false); - setServiceConfig(serviceConfig, true); - updateServiceList('chatglm_custom'); - onClose(); - }, - (e) => { - setIsLoading(false); - toast.error(t('config.service.test_failed') + e.toString(), { style: toastStyle }); - } - ); - }} - > - -
-

{t('services.help')}

- -
-
-

{t('services.translate.chatglm.model')}

- - - - - { - setServiceConfig({ - ...serviceConfig, - model: key, - }); - }} - > - - {t(`services.translate.chatglm.chatglm_turbo`)} - - {t(`services.translate.chatglm.chatglm_pro`)} - {t(`services.translate.chatglm.chatglm_std`)} - - {t(`services.translate.chatglm.chatglm_lite`)} - - - -
-
- { - setServiceConfig({ - ...serviceConfig, - apiKey: value, - }); - }} - /> -
- -

Prompt List

-

{t('services.translate.chatglm.prompt_description')}

- -
- {serviceConfig.promptList && - serviceConfig.promptList.map((prompt, index) => { - return ( -
-