Skip to content

Commit

Permalink
feat: add gemini key config
Browse files Browse the repository at this point in the history
  • Loading branch information
phlpsong committed Jan 31, 2024
1 parent 0540f46 commit 9a11fa8
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
0AC8A8432B6957B0006DA5CC /* BingService+ConfigurableService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AC8A8422B6957B0006DA5CC /* BingService+ConfigurableService.swift */; };
0AC8A8452B6A4D97006DA5CC /* ServiceConfigurationCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AC8A8442B6A4D97006DA5CC /* ServiceConfigurationCells.swift */; };
0AC8A8472B6A4E3F006DA5CC /* ServiceConfigurationSecretSectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AC8A8462B6A4E3F006DA5CC /* ServiceConfigurationSecretSectionView.swift */; };
0AC8A84B2B6A629D006DA5CC /* GeminiService+ConfigurableService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AC8A84A2B6A629D006DA5CC /* GeminiService+ConfigurableService.swift */; };
17BCAEF72B0DFF9000A7D372 /* EZNiuTransTranslateResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 17BCAEF52B0DFF9000A7D372 /* EZNiuTransTranslateResponse.m */; };
17BCAEF82B0DFF9000A7D372 /* EZNiuTransTranslate.m in Sources */ = {isa = PBXBuildFile; fileRef = 17BCAEF62B0DFF9000A7D372 /* EZNiuTransTranslate.m */; };
2721E4D02AFE920700A059AC /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 2721E4CF2AFE920700A059AC /* Alamofire */; };
Expand Down Expand Up @@ -741,6 +742,7 @@
0AC8A8422B6957B0006DA5CC /* BingService+ConfigurableService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BingService+ConfigurableService.swift"; sourceTree = "<group>"; };
0AC8A8442B6A4D97006DA5CC /* ServiceConfigurationCells.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceConfigurationCells.swift; sourceTree = "<group>"; };
0AC8A8462B6A4E3F006DA5CC /* ServiceConfigurationSecretSectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceConfigurationSecretSectionView.swift; sourceTree = "<group>"; };
0AC8A84A2B6A629D006DA5CC /* GeminiService+ConfigurableService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GeminiService+ConfigurableService.swift"; sourceTree = "<group>"; };
17BCAEF32B0DFF9000A7D372 /* EZNiuTransTranslateResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZNiuTransTranslateResponse.h; sourceTree = "<group>"; };
17BCAEF42B0DFF9000A7D372 /* EZNiuTransTranslate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZNiuTransTranslate.h; sourceTree = "<group>"; };
17BCAEF52B0DFF9000A7D372 /* EZNiuTransTranslateResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZNiuTransTranslateResponse.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2333,6 +2335,7 @@
0AC8A8382B666F07006DA5CC /* CaiyunService+ConfigurableService.swift */,
0AC8A83A2B6682D4006DA5CC /* AliService+ConfigurableService.swift */,
0AC8A8422B6957B0006DA5CC /* BingService+ConfigurableService.swift */,
0AC8A84A2B6A629D006DA5CC /* GeminiService+ConfigurableService.swift */,
);
path = "QueryService+ConfigurableService";
sourceTree = "<group>";
Expand Down Expand Up @@ -2787,6 +2790,7 @@
039CC914292FB3180037B91E /* EZPopUpButton.m in Sources */,
0399C6B829A9F4B800B4AFCC /* EZSchemeParser.m in Sources */,
03542A3A2937AE6400C34C33 /* EZQueryService.m in Sources */,
0AC8A84B2B6A629D006DA5CC /* GeminiService+ConfigurableService.swift in Sources */,
03B0230529231FA6001C7E63 /* EZButton.m in Sources */,
03B0232329231FA6001C7E63 /* NSString+MM.m in Sources */,
036196772A000F5900806370 /* NSData+CommonCrypto.m in Sources */,
Expand Down
16 changes: 16 additions & 0 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -2772,6 +2772,22 @@
}
}
},
"service.configuration.gemini.api_key.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "API Key"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "API Key"
}
}
}
},
"service.configuration.validate" : {
"localizations" : {
"en" : {
Expand Down
3 changes: 3 additions & 0 deletions Easydict/NewApp/Configuration/Configuration+Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,7 @@ extension Defaults.Keys {
// ALI
static let aliAccessKeyId = Key<String?>("EZAliAccessKeyId")
static let aliAccessKeySecret = Key<String?>("EZAliAccessKeySecret")

// Gemni
static let geminiAPIKey = Key<String?>("EZGeminiAPIKey")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// GeminiService+ConfigurableService.swift
// Easydict
//
// Created by phlpsong on 2024/1/31.
// Copyright © 2024 izual. All rights reserved.
//

import Foundation
import SwiftUI

@available(macOS 13.0, *)
extension GeminiService: ConfigurableService {
func configurationListItems() -> some View {
ServiceConfigurationSecretSectionView(service: self, observeKeys: [.geminiAPIKey]) {
ServiceConfigurationSecureInputCell(
textFieldTitleKey: "service.configuration.gemini.api_key.title",
key: .geminiAPIKey
)
}
}
}

0 comments on commit 9a11fa8

Please sign in to comment.