From 9b89759cc9dde04cbb21995f6a46a2ee5f29847c Mon Sep 17 00:00:00 2001 From: wenjy Date: Thu, 26 Mar 2026 08:57:40 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E7=99=BB=E5=BD=95=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sln.Wcs.UI/App.xaml | 35 ++++++++++++-- Sln.Wcs.UI/App.xaml.cs | 20 ++++++++ Sln.Wcs.UI/MainWindow.xaml.cs | 5 +- Sln.Wcs.UI/Page/Login/LoginWindow.xaml | 58 +++++++++++++++++++++++ Sln.Wcs.UI/Page/Login/LoginWindow.xaml.cs | 54 +++++++++++++++++++++ Sln.Wcs.UI/Sln.Wcs.UI.csproj | 14 ++++-- 6 files changed, 177 insertions(+), 9 deletions(-) create mode 100644 Sln.Wcs.UI/Page/Login/LoginWindow.xaml create mode 100644 Sln.Wcs.UI/Page/Login/LoginWindow.xaml.cs 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +