From 4df6165fa93c7caeea86385312415e312de4d11f Mon Sep 17 00:00:00 2001
From: Moli <13026959681@163.com>
Date: 星期二, 05 五月 2026 01:10:39 +0800
Subject: [PATCH] 暂存
---
src/Moli.Desktop/Llm/EnvironmentCredentialStore.cs | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/src/Moli.Desktop/Llm/EnvironmentCredentialStore.cs b/src/Moli.Desktop/Llm/EnvironmentCredentialStore.cs
new file mode 100644
index 0000000..81d040c
--- /dev/null
+++ b/src/Moli.Desktop/Llm/EnvironmentCredentialStore.cs
@@ -0,0 +1,25 @@
+namespace Moli.Desktop.Llm;
+
+public sealed class EnvironmentCredentialStore : ICredentialStore
+{
+ public Task<string?> ResolveSecretAsync(string? authRef, CancellationToken cancellationToken = default)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ if (string.IsNullOrWhiteSpace(authRef))
+ {
+ return Task.FromResult<string?>(null);
+ }
+
+ var direct = Environment.GetEnvironmentVariable(authRef);
+ if (!string.IsNullOrWhiteSpace(direct))
+ {
+ return Task.FromResult<string?>(direct);
+ }
+
+ var normalized = "MOLI_" + new string(authRef
+ .Select(ch => char.IsLetterOrDigit(ch) ? char.ToUpperInvariant(ch) : '_')
+ .ToArray());
+
+ return Task.FromResult(Environment.GetEnvironmentVariable(normalized));
+ }
+}
--
Gitblit v1.9.1