diff --git a/Aucma.Core.SheetMetal/ViewModels/LoginPageViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/LoginPageViewModel.cs
index 758b691..5e9f2a3 100644
--- a/Aucma.Core.SheetMetal/ViewModels/LoginPageViewModel.cs
+++ b/Aucma.Core.SheetMetal/ViewModels/LoginPageViewModel.cs
@@ -69,10 +69,10 @@ namespace Aucma.Core.SheetMetal.ViewModels
if (window == null) return;
window.Hide();
- MainWindow indexPage = new MainWindow();
+ MainWindow indexPage = MainWindow.Instance;
indexPage.Show();
- window.Close();
+ // window.Close();
}
else
{
diff --git a/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs
index 652ede4..aa7f59a 100644
--- a/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs
+++ b/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs
@@ -217,9 +217,9 @@ namespace Aucma.Core.SheetMetal.ViewModels
window.Hide();
//跳转到登录页
- LoginPageView login = new LoginPageView();
+ LoginPageView login = LoginPageView.Instance;
login.Show();
- window.Close();
+ // window.Close();
}
}
diff --git a/Aucma.Core.SheetMetal/Views/IndexPageView.xaml b/Aucma.Core.SheetMetal/Views/IndexPageView.xaml
index 96c00b4..6c12067 100644
--- a/Aucma.Core.SheetMetal/Views/IndexPageView.xaml
+++ b/Aucma.Core.SheetMetal/Views/IndexPageView.xaml
@@ -295,9 +295,9 @@
-
-
-
+
+
+
diff --git a/Aucma.Core.SheetMetal/Views/LoginPageView.xaml.cs b/Aucma.Core.SheetMetal/Views/LoginPageView.xaml.cs
index 68ef885..5c657de 100644
--- a/Aucma.Core.SheetMetal/Views/LoginPageView.xaml.cs
+++ b/Aucma.Core.SheetMetal/Views/LoginPageView.xaml.cs
@@ -22,11 +22,22 @@ namespace Aucma.Core.SheetMetal.Views
///
public partial class LoginPageView : Window
{
+ private static readonly Lazy _instance = new Lazy(() => new LoginPageView());
+
+ public static LoginPageView Instance => _instance.Value;
+
LoginPageViewModel loginViewModel = new LoginPageViewModel();
public LoginPageView()
{
InitializeComponent();
this.DataContext = loginViewModel;
+ Closing += LoginPageView_Closing; // 订阅窗口关闭事件
+ }
+
+
+ private void LoginPageView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ System.Environment.Exit(0);
}
private void loginBtn_Click(object sender, RoutedEventArgs e)
diff --git a/Aucma.Core.SheetMetal/Views/MainWindow.xaml b/Aucma.Core.SheetMetal/Views/MainWindow.xaml
index 3717a24..614ad5b 100644
--- a/Aucma.Core.SheetMetal/Views/MainWindow.xaml
+++ b/Aucma.Core.SheetMetal/Views/MainWindow.xaml
@@ -30,7 +30,7 @@
-
+
diff --git a/Aucma.Core.SheetMetal/Views/MainWindow.xaml.cs b/Aucma.Core.SheetMetal/Views/MainWindow.xaml.cs
index b28d579..a3767b1 100644
--- a/Aucma.Core.SheetMetal/Views/MainWindow.xaml.cs
+++ b/Aucma.Core.SheetMetal/Views/MainWindow.xaml.cs
@@ -1,4 +1,5 @@
using Aucma.Core.SheetMetal.ViewModels;
+using System;
using System.Windows;
namespace Aucma.Core.SheetMetal.Views
@@ -8,6 +9,10 @@ namespace Aucma.Core.SheetMetal.Views
///
public partial class MainWindow : Window
{
+ private static readonly Lazy _instance = new Lazy(() => new MainWindow());
+
+ public static MainWindow Instance => _instance.Value;
+
public MainWindow()
{
InitializeComponent();