diff --git a/Sln.Wcs.UI/App.xaml b/Sln.Wcs.UI/App.xaml
index c040570..c1e8b0e 100644
--- a/Sln.Wcs.UI/App.xaml
+++ b/Sln.Wcs.UI/App.xaml
@@ -1,9 +1,36 @@
+ xmlns:local="clr-namespace:Sln.Wcs.UI">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/Sln.Wcs.UI/App.xaml.cs b/Sln.Wcs.UI/App.xaml.cs
index 12a8d0b..f2a1df3 100644
--- a/Sln.Wcs.UI/App.xaml.cs
+++ b/Sln.Wcs.UI/App.xaml.cs
@@ -9,6 +9,8 @@ using ZiggyCreatures.Caching.Fusion;
using ZiggyCreatures.Caching.Fusion.Serialization.NewtonsoftJson;
using System.Windows;
using System.IO;
+using Sln.Wcs.UI.Page.Login;
+using Sln.Wcs.UI.Attribute;
namespace Sln.Wcs.UI
{
@@ -34,6 +36,11 @@ namespace Sln.Wcs.UI
var log = ServiceProvider.GetService();
log.Info($"系统启动成功,日志存放位置:{config["logPath"]}");
+
+ var loginWindow = ServiceProvider.GetRequiredService();
+ loginWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
+
+ loginWindow.Show();
}
private static void ConfigureServices(IServiceCollection services)
@@ -56,6 +63,19 @@ namespace Sln.Wcs.UI
.AsSelf()
.WithTransientLifetime());
+ // 扫描并注册带有特性的窗口和服务
+ services.Scan(scan => scan
+ .FromAssemblyOf()
+ .AddClasses(classes => classes.WithAttribute())
+ .AsSelf()
+ .WithSingletonLifetime());
+
+ services.Scan(scan => scan
+ .FromAssemblyOf()
+ .AddClasses(classes => classes.WithAttribute())
+ .AsSelf()
+ .WithTransientLifetime());
+
services.AddSingleton(typeof(SerilogHelper));
services.AddSqlSugarSetup();
diff --git a/Sln.Wcs.UI/MainWindow.xaml.cs b/Sln.Wcs.UI/MainWindow.xaml.cs
index 1fa96a2..3a37b71 100644
--- a/Sln.Wcs.UI/MainWindow.xaml.cs
+++ b/Sln.Wcs.UI/MainWindow.xaml.cs
@@ -1,4 +1,5 @@
-using System.Text;
+using Sln.Wcs.UI.Attribute;
+using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@@ -14,6 +15,8 @@ namespace Sln.Wcs.UI
///
/// Interaction logic for MainWindow.xaml
///
+
+ [RegisterAsSingletonAttribute]
public partial class MainWindow : Window
{
public MainWindow()
diff --git a/Sln.Wcs.UI/Page/Login/LoginWindow.xaml b/Sln.Wcs.UI/Page/Login/LoginWindow.xaml
new file mode 100644
index 0000000..c4a8914
--- /dev/null
+++ b/Sln.Wcs.UI/Page/Login/LoginWindow.xaml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sln.Wcs.UI/Page/Login/LoginWindow.xaml.cs b/Sln.Wcs.UI/Page/Login/LoginWindow.xaml.cs
new file mode 100644
index 0000000..35028f3
--- /dev/null
+++ b/Sln.Wcs.UI/Page/Login/LoginWindow.xaml.cs
@@ -0,0 +1,54 @@
+using Sln.Wcs.UI.Attribute;
+using Sln.Wcs.UI.ViewModel.Login;
+using System;
+using System.Windows;
+
+namespace Sln.Wcs.UI.Page.Login
+{
+ ///
+ /// LoginWindow.xaml 的交互逻辑
+ ///
+ [RegisterAsSingletonAttribute]
+ public partial class LoginWindow : Window
+ {
+ private readonly LoginViewModel _loginViewModel;
+ public LoginWindow(LoginViewModel loginViewModel)
+ {
+ _loginViewModel = loginViewModel;
+ InitializeComponent();
+ this.DataContext = _loginViewModel;
+ }
+
+ private async void LoginBtn_Click(object sender, RoutedEventArgs e)
+ {
+ string userName = UserNameStr.Text.ToString();
+ string password = PasswordStr.Password;
+
+ //if (string.IsNullOrEmpty(userName))
+ //{
+ // MessageBox.Show("用户名不允许为空");
+ // return;
+ //}
+
+ //if (string.IsNullOrEmpty(password))
+ //{
+ // MessageBox.Show("密码不允许为空");
+ // return;
+ //}
+
+ bool res = _loginViewModel.Login(userName,password);
+ if (res)
+ {
+ this.Closing += MainWindow_Closing;
+ this.Close();
+ }
+ }
+
+ private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ this.Closing -= MainWindow_Closing; // 防止多次绑定
+ e.Cancel = true;
+ this.Visibility = Visibility.Hidden; // 隐藏窗口
+ }
+ }
+}
diff --git a/Sln.Wcs.UI/Sln.Wcs.UI.csproj b/Sln.Wcs.UI/Sln.Wcs.UI.csproj
index 02fdd99..8a69fb1 100644
--- a/Sln.Wcs.UI/Sln.Wcs.UI.csproj
+++ b/Sln.Wcs.UI/Sln.Wcs.UI.csproj
@@ -10,6 +10,9 @@
+
+
+
@@ -18,10 +21,17 @@
+
+
+
+
+
+
+
@@ -35,8 +45,4 @@
-
-
-
-