mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 04:10:51 +08:00
feat(gemini-web): Add support for custom auth labels
This commit is contained in:
@@ -34,6 +34,7 @@ type GeminiWebState struct {
|
|||||||
cfg *config.Config
|
cfg *config.Config
|
||||||
token *gemini.GeminiWebTokenStorage
|
token *gemini.GeminiWebTokenStorage
|
||||||
storagePath string
|
storagePath string
|
||||||
|
authLabel string
|
||||||
|
|
||||||
stableClientID string
|
stableClientID string
|
||||||
accountID string
|
accountID string
|
||||||
@@ -55,11 +56,12 @@ type GeminiWebState struct {
|
|||||||
pendingMatch *conversation.MatchResult
|
pendingMatch *conversation.MatchResult
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGeminiWebState(cfg *config.Config, token *gemini.GeminiWebTokenStorage, storagePath string) *GeminiWebState {
|
func NewGeminiWebState(cfg *config.Config, token *gemini.GeminiWebTokenStorage, storagePath, authLabel string) *GeminiWebState {
|
||||||
state := &GeminiWebState{
|
state := &GeminiWebState{
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
token: token,
|
token: token,
|
||||||
storagePath: storagePath,
|
storagePath: storagePath,
|
||||||
|
authLabel: strings.TrimSpace(authLabel),
|
||||||
convStore: make(map[string][]string),
|
convStore: make(map[string][]string),
|
||||||
convData: make(map[string]ConversationRecord),
|
convData: make(map[string]ConversationRecord),
|
||||||
convIndex: make(map[string]string),
|
convIndex: make(map[string]string),
|
||||||
@@ -117,6 +119,9 @@ func (s *GeminiWebState) Label() string {
|
|||||||
return lbl
|
return lbl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if lbl := strings.TrimSpace(s.authLabel); lbl != "" {
|
||||||
|
return lbl
|
||||||
|
}
|
||||||
if s.storagePath != "" {
|
if s.storagePath != "" {
|
||||||
base := strings.TrimSuffix(filepath.Base(s.storagePath), filepath.Ext(s.storagePath))
|
base := strings.TrimSuffix(filepath.Base(s.storagePath), filepath.Ext(s.storagePath))
|
||||||
if base != "" {
|
if base != "" {
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ func (e *GeminiWebExecutor) stateFor(auth *cliproxyauth.Auth) (*geminiwebapi.Gem
|
|||||||
storagePath = p
|
storagePath = p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state := geminiwebapi.NewGeminiWebState(cfg, ts, storagePath)
|
state := geminiwebapi.NewGeminiWebState(cfg, ts, storagePath, auth.Label)
|
||||||
runtime := &geminiWebRuntime{state: state}
|
runtime := &geminiWebRuntime{state: state}
|
||||||
auth.Runtime = runtime
|
auth.Runtime = runtime
|
||||||
return state, nil
|
return state, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user