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/App.xaml.cs |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/Moli.Desktop/App.xaml.cs b/src/Moli.Desktop/App.xaml.cs
index 9063de7..37f816d 100644
--- a/src/Moli.Desktop/App.xaml.cs
+++ b/src/Moli.Desktop/App.xaml.cs
@@ -1,12 +1,16 @@
 using System.Windows;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
+using Moli.Desktop.Configuration;
 using Moli.Desktop.Host;
+using Moli.Desktop.Management;
+using Moli.Desktop.Runtime;
+using Moli.Desktop.Tray;
 
 namespace Moli.Desktop;
 
 /// <summary>Application entry point and composition root.</summary>
-public partial class App : Application
+public partial class App : System.Windows.Application
 {
     private IHost? _host;
 
@@ -16,15 +20,23 @@
 
         _host = DesktopHostBuilder.Create(e.Args).Build();
         await _host.StartAsync();
+        await _host.Services.GetRequiredService<IDefaultContentInstaller>().InstallAsync();
+        await _host.Services.GetRequiredService<IDesktopRuntime>().StartAsync();
+        await _host.Services.GetRequiredService<ITrayShell>().StartAsync();
 
-        var mainWindow = _host.Services.GetRequiredService<MainWindow>();
-        mainWindow.Show();
+        var settings = await _host.Services.GetRequiredService<IConfigurationService>().LoadAppSettingsAsync();
+        if (!settings.Startup.StartMinimized)
+        {
+            _host.Services.GetRequiredService<ManagementWindow>().Show();
+        }
     }
 
     protected override async void OnExit(ExitEventArgs e)
     {
         if (_host is not null)
         {
+            await _host.Services.GetRequiredService<ITrayShell>().StopAsync();
+            await _host.Services.GetRequiredService<IDesktopRuntime>().ShutdownAsync();
             await _host.StopAsync(TimeSpan.FromSeconds(5));
             _host.Dispose();
         }

--
Gitblit v1.9.1