From 9579b3e6d0ecbb1e608d176d51dfcca6d7bf6a79 Mon Sep 17 00:00:00 2001 From: phlpsong Date: Thu, 1 Feb 2024 22:53:18 +0800 Subject: [PATCH] fix: remove openai domain config --- Easydict/App/Localizable.xcstrings | 38 ++----------------- .../Service/Gemini/GeminiService.swift | 3 +- .../Configuration+Defaults.swift | 1 - .../OpenAIService+ConfigurableService.swift | 12 ++---- .../ServiceConfigurationCells.swift | 6 +-- 5 files changed, 11 insertions(+), 49 deletions(-) diff --git a/Easydict/App/Localizable.xcstrings b/Easydict/App/Localizable.xcstrings index f3ac6df06..1ef9e25de 100644 --- a/Easydict/App/Localizable.xcstrings +++ b/Easydict/App/Localizable.xcstrings @@ -2613,39 +2613,7 @@ } } }, - "service.configuration.openai.domain.placeholder" : { - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "api.openai.com" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "api.openai.com" - } - } - } - }, - "service.configuration.openai.domain.title" : { - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Domain" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "域名" - } - } - } - }, - "service.configuration.openai.endpoint_key.placeholder" : { + "service.configuration.openai.endpoint.placeholder" : { "localizations" : { "en" : { "stringUnit" : { @@ -2661,7 +2629,7 @@ } } }, - "service.configuration.openai.endpoint_key.title" : { + "service.configuration.openai.endpoint.title" : { "localizations" : { "en" : { "stringUnit" : { @@ -3894,4 +3862,4 @@ } }, "version" : "1.0" -} \ No newline at end of file +} diff --git a/Easydict/Feature/Service/Gemini/GeminiService.swift b/Easydict/Feature/Service/Gemini/GeminiService.swift index 6df5cfcff..706732b17 100644 --- a/Easydict/Feature/Service/Gemini/GeminiService.swift +++ b/Easydict/Feature/Service/Gemini/GeminiService.swift @@ -6,6 +6,7 @@ // Copyright © 2024 izual. All rights reserved. // +import Defaults import Foundation import GoogleGenerativeAI @@ -59,7 +60,7 @@ public final class GeminiService: QueryService { // easydict://writeKeyValue?EZGeminiAPIKey=xxx private var apiKey: String { - let apiKey = UserDefaults.standard.string(forKey: EZGeminiAPIKey) + let apiKey = Defaults[.geminiAPIKey] if let apiKey, !apiKey.isEmpty { return apiKey } else { diff --git a/Easydict/NewApp/Configuration/Configuration+Defaults.swift b/Easydict/NewApp/Configuration/Configuration+Defaults.swift index e749b2e0c..aa5dbeaad 100644 --- a/Easydict/NewApp/Configuration/Configuration+Defaults.swift +++ b/Easydict/NewApp/Configuration/Configuration+Defaults.swift @@ -137,7 +137,6 @@ extension Defaults.Keys { static let openAIDictionary = Key("EZOpenAIDictionaryKey", default: "1") static let openAISentence = Key("EZOpenAISentenceKey", default: "1") static let openAIServiceUsageStatus = Key("EZOpenAIServiceUsageStatusKey", default: "0") - static let openAIDomain = Key("EZOpenAIDomainKey") static let openAIEndPoint = Key("EZOpenAIEndPointKey") static let openAIModel = Key("EZOpenAIModelKey", default: OpenAIModels.gpt3_5_turbo.rawValue) diff --git a/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/OpenAIService+ConfigurableService.swift b/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/OpenAIService+ConfigurableService.swift index 95960a4cc..141f70403 100644 --- a/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/OpenAIService+ConfigurableService.swift +++ b/Easydict/NewApp/Utility/Extensions/QueryService+ConfigurableService/OpenAIService+ConfigurableService.swift @@ -39,17 +39,11 @@ extension EZOpenAIService: ConfigurableService { key: .openAIAPIKey, placeholder: "service.configuration.openai.api_key.placeholder" ) - // domain + // endpoint ServiceConfigurationInputCell( - textFieldTitleKey: "service.configuration.openai.domain.title", - key: .openAIDomain, - placeholder: "service.configuration.openai.domain.placeholder" - ) - // endpoint key - ServiceConfigurationInputCell( - textFieldTitleKey: "service.configuration.openai.endpoint_key.title", + textFieldTitleKey: "service.configuration.openai.endpoint.title", key: .openAIEndPoint, - placeholder: "service.configuration.openai.endpoint_key.placeholder" + placeholder: "service.configuration.openai.endpoint.placeholder" ) // model ServiceConfigurationPickerCell( diff --git a/Easydict/NewApp/View/SettingView/Tabs/ServiceConfiguration/ServiceConfigurationCells.swift b/Easydict/NewApp/View/SettingView/Tabs/ServiceConfiguration/ServiceConfigurationCells.swift index 90267bd25..59dae6f69 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/ServiceConfiguration/ServiceConfigurationCells.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/ServiceConfiguration/ServiceConfigurationCells.swift @@ -104,9 +104,9 @@ struct ServiceConfigurationToggleCell: View { ) ServiceConfigurationInputCell( - textFieldTitleKey: "service.configuration.openai.domain.title", - key: .openAIDomain, - placeholder: "service.configuration.openai.domain.placeholder" + textFieldTitleKey: "service.configuration.openai.endpoint.title", + key: .openAIEndPoint, + placeholder: "service.configuration.openai.endpoint.placeholder" ) // model