From da97410f48a1e94d7e1fe019c69a7c847fe67ddf Mon Sep 17 00:00:00 2001
From: chunhualin1 <chunhualin1@lenovo.com>
Date: 星期三, 12 八月 2026 17:42:02 +0800
Subject: [PATCH] 修复LLM工具无法点击的问题

---
 src/Moli.Desktop/Management/ManagementWindow.xaml.cs |   36 ++++++++++++++++++++++++++++++++++--
 1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/Moli.Desktop/Management/ManagementWindow.xaml.cs b/src/Moli.Desktop/Management/ManagementWindow.xaml.cs
index 19185ed..f21754e 100644
--- a/src/Moli.Desktop/Management/ManagementWindow.xaml.cs
+++ b/src/Moli.Desktop/Management/ManagementWindow.xaml.cs
@@ -27,6 +27,7 @@
     private readonly IDesktopRuntime _runtime;
     private readonly IDiagnosticsService _diagnostics;
     private readonly ILocalApiStatus _apiStatus;
+    private readonly IPluginManager _plugins;
     private readonly DesktopPaths _paths;
     private readonly DispatcherTimer _timer;
     private AppRuntimeState? _state;
@@ -37,11 +38,13 @@
         IDesktopRuntime runtime,
         IDiagnosticsService diagnostics,
         ILocalApiStatus apiStatus,
+        IPluginManager plugins,
         DesktopPaths paths)
     {
         _runtime = runtime;
         _diagnostics = diagnostics;
         _apiStatus = apiStatus;
+        _plugins = plugins;
         _paths = paths;
         InitializeComponent();
         DisplayLayerSelector.ItemsSource = Enum.GetValues<DisplayLayer>();
@@ -124,6 +127,7 @@
             }
         }
 
+        await _runtime.CancelPluginRequestsAsync(new PluginId(widget.PluginId));
         await ExecuteWidgetAsync(widget.InstanceId, new WidgetLayoutPatch { DisplayLayer = layer });
     }
 
@@ -145,6 +149,16 @@
         }
 
         await ExecuteWidgetAsync(widget.InstanceId, new WidgetLayoutPatch { IsLocked = !widget.IsLocked });
+    }
+
+    private async void ToggleWidgetClickThrough_Click(object sender, RoutedEventArgs e)
+    {
+        if (SelectedWidget() is not { } widget)
+        {
+            return;
+        }
+
+        await ExecuteWidgetAsync(widget.InstanceId, new WidgetLayoutPatch { ClickThrough = !widget.ClickThrough });
     }
 
     private async void ResetLayout_Click(object sender, RoutedEventArgs e)
@@ -176,6 +190,21 @@
 
         foreach (var widget in _state.Widgets)
         {
+            var clickThrough = true;
+            var displayLayer = DisplayLayer.Desktop;
+            try
+            {
+                var plugin = await _plugins.GetAsync(widget.PluginId);
+                if (plugin is not null)
+                {
+                    clickThrough = plugin.Manifest.DefaultLayout.ClickThrough;
+                    displayLayer = plugin.Manifest.DefaultLayout.DisplayLayer;
+                }
+            }
+            catch
+            {
+            }
+
             await _runtime.UpdateWidgetLayoutAsync(
                 widget.InstanceId,
                 new WidgetLayoutPatch
@@ -183,8 +212,8 @@
                     IsVisible = true,
                     IsLocked = false,
                     Opacity = 1,
-                    ClickThrough = true,
-                    DisplayLayer = DisplayLayer.Desktop
+                    ClickThrough = clickThrough,
+                    DisplayLayer = displayLayer
                 });
         }
 
@@ -260,9 +289,12 @@
         {
             DisplayLayerSelector.SelectedItem = DisplayLayer.Desktop;
             _selectedWidgetForDisplayLayer = null;
+            ClickThroughButton.Content = "鐐瑰嚮绌块��";
             return;
         }
 
+        ClickThroughButton.Content = widget.ClickThrough ? "鍏抽棴绌块��" : "寮�鍚┛閫�";
+
         if (!force)
         {
             return;

--
Gitblit v1.9.1