API-Keys: Source-URL, einheitliches Status-Schema, passive Usage-Erfassung, Usage-Bars
- SourceUrl-Feld in api_keys: GitHub-URL bei adoptierten Scan-Keys gespeichert - HandleAdopt: Name = user/repo (aus URL extrahiert), SourceUrl = vollständige URL - Status-Schema vereinheitlicht: überall 'valid' statt 'ok'/'usage_limited' - AnthropicKeyChecker.ExtractMetaFromHeaders(): passive Header-Auswertung - AnthropicService: TryUpdateKeyMeta() nach jedem Chat-Request (fire-and-forget) - DatabaseService: UpdateApiKeyMetaByToken() für passive Updates per Token - Frontend: formatKeyStatus() zentrale Status-Labels für API-Keys + Scanned-Keys - Frontend: createUsageBadge() zweizeiliger Balken (Sitzung/Woche) mit Farbstufen - CSS: Usage-Badge mit Track/Fill, warn (>=70%) und danger (>=90%) Klassen
This commit is contained in:
1 parent
608118a823
commit
de388806cb
8 files changed
+226
-32
No files matched your search
@@ -372,8 +372,8 @@ public partial class DatabaseService
|
||||
{
|
||||
using var conn = CreateConnection();
|
||||
await conn.ExecuteAsync(@"
|
||||
INSERT INTO api_keys (key_id, provider, name, api_key, is_active, status, plan, usage_7d, usage_5h, checked_at, created_at, updated_at)
|
||||
VALUES (@KeyId, @Provider, @Name, @ApiKey, @IsActive, @Status, @Plan, @Usage7d, @Usage5h, @CheckedAt, @CreatedAt, @UpdatedAt)",
|
||||
INSERT INTO api_keys (key_id, provider, name, api_key, is_active, status, plan, usage_7d, usage_5h, checked_at, source_url, created_at, updated_at)
|
||||
VALUES (@KeyId, @Provider, @Name, @ApiKey, @IsActive, @Status, @Plan, @Usage7d, @Usage5h, @CheckedAt, @SourceUrl, @CreatedAt, @UpdatedAt)",
|
||||
record);
|
||||
return await conn.ExecuteScalarAsync<long>("SELECT last_insert_rowid()");
|
||||
}
|
||||
@@ -404,6 +404,15 @@ public partial class DatabaseService
|
||||
new { keyId, status, plan, usage7d, usage5h, now = DateTime.UtcNow.ToString("o") });
|
||||
}
|
||||
|
||||
public async Task UpdateApiKeyMetaByToken(string apiKey, string status, string plan, double? usage7d, double? usage5h)
|
||||
{
|
||||
using var conn = CreateConnection();
|
||||
await conn.ExecuteAsync(@"
|
||||
UPDATE api_keys SET status = @status, plan = @plan, usage_7d = @usage7d, usage_5h = @usage5h, checked_at = @now, updated_at = @now
|
||||
WHERE api_key = @apiKey AND is_active = 1",
|
||||
new { apiKey, status, plan, usage7d, usage5h, now = DateTime.UtcNow.ToString("o") });
|
||||
}
|
||||
|
||||
public async Task SetActiveApiKey(string keyId, string provider)
|
||||
{
|
||||
using var conn = CreateConnection();
|
||||
|
||||
Reference in new issue
Block a user