feat(gemini-web): Add support for custom auth labels

This commit is contained in:
hkfires
2025-09-29 23:48:37 +08:00
parent d33a89b89f
commit 8858e07d8b
2 changed files with 7 additions and 2 deletions

View File

@@ -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 != "" {

View File

@@ -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