From 15bbd62b0b24b72c717ae91ab45348a2083ad04e Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期五, 10 十月 2025 08:58:18 +0800
Subject: [PATCH] 优化bug;

---
 WPFProject/LoadingWindow.xaml.cs |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/WPFProject/LoadingWindow.xaml.cs b/WPFProject/LoadingWindow.xaml.cs
index e9d50a4..4e1ff79 100644
--- a/WPFProject/LoadingWindow.xaml.cs
+++ b/WPFProject/LoadingWindow.xaml.cs
@@ -37,7 +37,8 @@
             }
         }
 
-        public Visibility ConsoleVisiable {
+        public Visibility ConsoleVisiable
+        {
             get => showConsole ? Visibility.Visible : Visibility.Collapsed;
         }
 
@@ -65,7 +66,7 @@
                     Add(msg.Message, null);
                     break;
                 case LoadMsgType.LOADING:
-                    HasErr = msg.Result == false;
+                    HasErr = HasErr || msg.Result == false;
                     if (msg.Result != null)
                     {
                         processBar.Value = ++finished / total * 100;
@@ -83,21 +84,23 @@
 
         private void Button_Click(object sender, RoutedEventArgs e)
         {
-            PanuonWindow window = new PanuonWindow();
+            this.Closed -= ShutDownWhen_Closed;
             window.Show();
             this.Close();
         }
 
+        private PanuonWindow window;
         private double total;
         private double finished;
 
         private void WindowX_ContentRendered(object sender, System.EventArgs e)
         {
+            window = new PanuonWindow();
             PluginLoader loader = PluginLoader.GetLoader();
             loader.LoadMessageAppend += Loader_LoadMessageAppend;
             Task.Run(() =>
             {
-                loader.LoadMenuAndPlugin(Dispatcher);
+                loader.LoadMenuAndPlugin(window, Dispatcher);
                 //
             });
         }
@@ -114,7 +117,13 @@
                 ShowConsole = true;
                 BtnNext.Visibility = Visibility.Visible;
                 MsgBoxHelper.Error(this, "鍔犺浇鍑洪敊锛岃纭");
+                this.Closed += ShutDownWhen_Closed; ;
             }
+        }
+
+        private void ShutDownWhen_Closed(object sender, EventArgs e)
+        {
+            Application.Current.Shutdown();
         }
 
         public void Add(string text, bool? result)
@@ -132,7 +141,7 @@
             };
             //涔熷彲浠ユ彃鍏ュ埌鏈�鍚庨潰
             Console.Document.Blocks.InsertAfter(Console.Document.Blocks.LastBlock, paragraph);
-            
+
             //鎻掑叆鍒版渶鍓嶉潰
             //rtxtLog.Document.Blocks.Add(paragraph);
 

--
Gitblit v1.9.1