From b84db8983d63a9a981083ebce1a139860c6bdf25 Mon Sep 17 00:00:00 2001
From: chunhualin1 <chunhualin1@lenovo.com>
Date: 星期五, 14 八月 2026 15:35:21 +0800
Subject: [PATCH] commit

---
 src/Moli.Desktop/Configuration/JsonConfigurationService.cs |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/src/Moli.Desktop/Configuration/JsonConfigurationService.cs b/src/Moli.Desktop/Configuration/JsonConfigurationService.cs
index 54303e9..0ee83a0 100644
--- a/src/Moli.Desktop/Configuration/JsonConfigurationService.cs
+++ b/src/Moli.Desktop/Configuration/JsonConfigurationService.cs
@@ -3,6 +3,7 @@
 using System.Text.Json.Serialization;
 using Moli.Desktop.Diagnostics;
 using Moli.Desktop.Host;
+using Moli.Desktop.Hotkeys;
 
 namespace Moli.Desktop.Configuration;
 
@@ -42,13 +43,29 @@
     public Task SaveLayoutAsync(LayoutDocument document, CancellationToken cancellationToken = default)
         => SaveDocumentAsync("layout.json", document, cancellationToken);
 
+    public async Task<HotkeysDocument> LoadHotkeysAsync(CancellationToken cancellationToken = default)
+    {
+        var document = await LoadDocumentAsync("hotkeys.json", HotkeysDocument.CreateDefault, cancellationToken).ConfigureAwait(false);
+        if (document.Bindings.All(binding =>
+            !string.Equals(binding.Id, HotkeysDocument.BuiltinPaletteToggleId, StringComparison.OrdinalIgnoreCase)))
+        {
+            document.Bindings.Insert(0, HotkeysDocument.CreateBuiltinPaletteBinding());
+        }
+
+        return document;
+    }
+
+    public Task SaveHotkeysAsync(HotkeysDocument document, CancellationToken cancellationToken = default)
+        => SaveDocumentAsync("hotkeys.json", document, cancellationToken);
+
     public async Task<ConfigurationSnapshot> LoadAllAsync(CancellationToken cancellationToken = default)
     {
         return new ConfigurationSnapshot
         {
             AppSettings = await LoadAppSettingsAsync(cancellationToken).ConfigureAwait(false),
             Plugins = await LoadPluginRegistryAsync(cancellationToken).ConfigureAwait(false),
-            Layout = await LoadLayoutAsync(cancellationToken).ConfigureAwait(false)
+            Layout = await LoadLayoutAsync(cancellationToken).ConfigureAwait(false),
+            Hotkeys = await LoadHotkeysAsync(cancellationToken).ConfigureAwait(false)
         };
     }
 
@@ -57,6 +74,7 @@
         await SaveAppSettingsAsync(snapshot.AppSettings, cancellationToken).ConfigureAwait(false);
         await SavePluginRegistryAsync(snapshot.Plugins, cancellationToken).ConfigureAwait(false);
         await SaveLayoutAsync(snapshot.Layout, cancellationToken).ConfigureAwait(false);
+        await SaveHotkeysAsync(snapshot.Hotkeys, cancellationToken).ConfigureAwait(false);
     }
 
     private async Task<T> LoadDocumentAsync<T>(string fileName, Func<T> createDefault, CancellationToken cancellationToken)

--
Gitblit v1.9.1