feat(providers): implement secure API key storage and provider management

Add complete provider configuration system with the following features:

- Secure API key storage using Electron's safeStorage encryption
- Provider CRUD operations with IPC handlers
- Lazy-loaded electron-store for ESM compatibility
- Provider settings UI component with add/edit/delete functionality
- API key masking for display (shows first/last 4 chars)
- Basic API key format validation per provider type
- Default provider selection
- Provider enable/disable toggle

New files:
- electron/utils/secure-storage.ts: Encrypted key storage and provider config
- src/stores/providers.ts: Zustand store for provider state
- src/components/settings/ProvidersSettings.tsx: Provider management UI
This commit is contained in:
Haze
2026-02-05 23:24:31 +08:00
Unverified
parent 18dc3bf53f
commit ebb6f515a7
7 changed files with 1089 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ import {
Loader2,
Terminal,
ExternalLink,
Key,
} from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
@@ -20,6 +21,7 @@ import { Separator } from '@/components/ui/separator';
import { Badge } from '@/components/ui/badge';
import { useSettingsStore } from '@/stores/settings';
import { useGatewayStore } from '@/stores/gateway';
import { ProvidersSettings } from '@/components/settings/ProvidersSettings';
export function Settings() {
const {
@@ -109,6 +111,20 @@ export function Settings() {
</CardContent>
</Card>
{/* AI Providers */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Key className="h-5 w-5" />
AI Providers
</CardTitle>
<CardDescription>Configure your AI model providers and API keys</CardDescription>
</CardHeader>
<CardContent>
<ProvidersSettings />
</CardContent>
</Card>
{/* Gateway */}
<Card>
<CardHeader>