mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix exit crashing
This commit is contained in:
@@ -50,8 +50,6 @@ public sealed partial class App : Application
|
||||
/// <param name="serviceProvider">服务提供器</param>
|
||||
public App(IServiceProvider serviceProvider)
|
||||
{
|
||||
// DispatcherShutdownMode = DispatcherShutdownMode.OnExplicitShutdown;
|
||||
|
||||
// Load app resource
|
||||
InitializeComponent();
|
||||
activation = serviceProvider.GetRequiredService<IActivation>();
|
||||
@@ -61,6 +59,14 @@ public sealed partial class App : Application
|
||||
this.serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public bool IsExiting { get; private set; }
|
||||
|
||||
public new void Exit()
|
||||
{
|
||||
IsExiting = true;
|
||||
base.Exit();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Snap.Hutao.Core.ExceptionService;
|
||||
using Snap.Hutao.Win32.Foundation;
|
||||
using Snap.Hutao.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
@@ -136,7 +136,7 @@ internal sealed class XamlWindowController
|
||||
|
||||
private void OnWindowClosed(object sender, WindowEventArgs args)
|
||||
{
|
||||
if (LocalSetting.Get(SettingKeys.IsNotifyIconEnabled, true))
|
||||
if (LocalSetting.Get(SettingKeys.IsNotifyIconEnabled, true) && !serviceProvider.GetRequiredService<App>().IsExiting)
|
||||
{
|
||||
args.Handled = true;
|
||||
window.Hide();
|
||||
|
||||
@@ -29,8 +29,6 @@ internal sealed partial class MainWindow : Window, IXamlWindowOptionsSource, IMi
|
||||
InitializeComponent();
|
||||
windowOptions = new(this, TitleBarView.DragArea, new(1200, 741), SettingKeys.WindowRect);
|
||||
this.InitializeController(serviceProvider);
|
||||
|
||||
Closed += OnClosed;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -42,13 +40,4 @@ internal sealed partial class MainWindow : Window, IXamlWindowOptionsSource, IMi
|
||||
pInfo.ptMinTrackSize.x = (int)Math.Max(MinWidth * scalingFactor, pInfo.ptMinTrackSize.x);
|
||||
pInfo.ptMinTrackSize.y = (int)Math.Max(MinHeight * scalingFactor, pInfo.ptMinTrackSize.y);
|
||||
}
|
||||
|
||||
private void OnClosed(object sender, WindowEventArgs args)
|
||||
{
|
||||
if (LocalSetting.Get(SettingKeys.IsNotifyIconEnabled, true))
|
||||
{
|
||||
args.Handled = true;
|
||||
this.Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"profiles": {
|
||||
"Snap.Hutao": {
|
||||
"commandName": "MsixPackage",
|
||||
"nativeDebugging": false,
|
||||
"nativeDebugging": true,
|
||||
"doNotLaunchApp": false,
|
||||
"allowLocalNetworkLoopbackProperty": true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user