From 72f3b855d8960d95ad46b7eb758258f749c98782 Mon Sep 17 00:00:00 2001 From: hsc Date: Tue, 23 Dec 2025 15:07:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LAEPS.sln | 38 ++++ LAEPS/App.xaml | 17 +- LAEPS/App.xaml.cs | 38 +++- LAEPS/LAEPS.csproj | 9 +- .../ViewModels/Dialogs/MessageBoxViewModel.cs | 7 +- LAEPS/ViewModels/ShellViewModel.cs | 5 +- LAEPS/Views/LoginModuleView.xaml | 21 ++ ...inView.xaml.cs => LoginModuleView.xaml.cs} | 6 +- LAEPS/Views/LoginView.xaml | 151 --------------- LAEPS/Views/ShellView.xaml.cs | 2 +- LoginModule/LoginModule.cs | 21 ++ LoginModule/LoginModule.csproj | 12 ++ .../ViewModels/LoginViewModel.cs | 18 +- LoginModule/ViewModels/RegisterViewModel.cs | 51 +++++ LoginModule/Views/LoginView.xaml | 163 ++++++++++++++++ LoginModule/Views/LoginView.xaml.cs | 28 +++ LoginModule/Views/RegisterView.xaml | 175 +++++++++++++++++ LoginModule/Views/RegisterView.xaml.cs | 28 +++ MainModule/MainModule.cs | 19 ++ MainModule/MainModule.csproj | 20 ++ .../ViewModels/MainViewModel.cs | 16 +- {LAEPS => MainModule}/Views/MainView.xaml | 2 +- {LAEPS => MainModule}/Views/MainView.xaml.cs | 2 +- Model/Entity/BaseEntity.cs | 2 +- Model/Entity/UserEntity.cs | 16 ++ Model/Result.cs | 180 ++++++++++++++++++ ORM/DatabaseConfig.cs | 8 +- ORM/SqlSugarContext.cs | 162 ++++++++++------ Service/Implement/BaseService.cs | 132 +++++++++++++ Service/Implement/UserService.cs | 90 +++++++++ Service/Interface/IBaseService.cs | 55 ++++++ SettingModule/SettingModule.cs | 19 ++ SettingModule/SettingModule.csproj | 23 +++ .../ViewModels/SettingViewModel.cs | 8 +- .../Views/SettingView.xaml | 2 +- .../Views/SettingView.xaml.cs | 2 +- .../BooleanToVisibilityConverter.cs | 2 +- .../Helpers/PasswordBoxHelper.cs | 2 +- .../PubEvent/LoginSuccessEvent.cs | 2 +- {LAEPS => UIShare}/PubEvent/OverlayEvent.cs | 2 +- {LAEPS => UIShare}/PubEvent/WaitingEvent.cs | 2 +- UIShare/Styles/CommonStyle.xaml | 21 ++ .../Styles/WindowStyle.xaml | 0 UIShare/UIShare.csproj | 20 ++ .../ViewModelBase/DialogViewModelBase.cs | 2 +- .../ViewModelBase/NavigateViewModelBase.cs | 4 +- UpdateInfoModule/UpdateInfoModule.cs | 19 ++ UpdateInfoModule/UpdateInfoModule.csproj | 20 ++ .../ViewModels/UpdateInfoViewModel.cs | 10 +- .../Views/UpdateInfoView.xaml | 2 +- .../Views/UpdateInfoView.xaml.cs | 2 +- 51 files changed, 1356 insertions(+), 302 deletions(-) create mode 100644 LAEPS/Views/LoginModuleView.xaml rename LAEPS/Views/{LoginView.xaml.cs => LoginModuleView.xaml.cs} (84%) delete mode 100644 LAEPS/Views/LoginView.xaml create mode 100644 LoginModule/LoginModule.cs create mode 100644 LoginModule/LoginModule.csproj rename {LAEPS => LoginModule}/ViewModels/LoginViewModel.cs (68%) create mode 100644 LoginModule/ViewModels/RegisterViewModel.cs create mode 100644 LoginModule/Views/LoginView.xaml create mode 100644 LoginModule/Views/LoginView.xaml.cs create mode 100644 LoginModule/Views/RegisterView.xaml create mode 100644 LoginModule/Views/RegisterView.xaml.cs create mode 100644 MainModule/MainModule.cs create mode 100644 MainModule/MainModule.csproj rename {LAEPS => MainModule}/ViewModels/MainViewModel.cs (52%) rename {LAEPS => MainModule}/Views/MainView.xaml (92%) rename {LAEPS => MainModule}/Views/MainView.xaml.cs (95%) create mode 100644 Model/Entity/UserEntity.cs create mode 100644 Model/Result.cs create mode 100644 Service/Implement/BaseService.cs create mode 100644 Service/Implement/UserService.cs create mode 100644 Service/Interface/IBaseService.cs create mode 100644 SettingModule/SettingModule.cs create mode 100644 SettingModule/SettingModule.csproj rename {LAEPS => SettingModule}/ViewModels/SettingViewModel.cs (69%) rename {LAEPS => SettingModule}/Views/SettingView.xaml (91%) rename {LAEPS => SettingModule}/Views/SettingView.xaml.cs (95%) rename {LAEPS => UIShare}/Converters/BooleanToVisibilityConverter.cs (97%) rename {LAEPS => UIShare}/Helpers/PasswordBoxHelper.cs (98%) rename {LAEPS => UIShare}/PubEvent/LoginSuccessEvent.cs (87%) rename {LAEPS => UIShare}/PubEvent/OverlayEvent.cs (87%) rename {LAEPS => UIShare}/PubEvent/WaitingEvent.cs (87%) create mode 100644 UIShare/Styles/CommonStyle.xaml rename {LAEPS/Resources => UIShare}/Styles/WindowStyle.xaml (100%) create mode 100644 UIShare/UIShare.csproj rename {LAEPS/ViewModels => UIShare}/ViewModelBase/DialogViewModelBase.cs (96%) rename {LAEPS/ViewModels => UIShare}/ViewModelBase/NavigateViewModelBase.cs (87%) create mode 100644 UpdateInfoModule/UpdateInfoModule.cs create mode 100644 UpdateInfoModule/UpdateInfoModule.csproj rename {LAEPS => UpdateInfoModule}/ViewModels/UpdateInfoViewModel.cs (65%) rename {LAEPS => UpdateInfoModule}/Views/UpdateInfoView.xaml (91%) rename {LAEPS => UpdateInfoModule}/Views/UpdateInfoView.xaml.cs (94%) diff --git a/LAEPS.sln b/LAEPS.sln index c5a0c63..b440747 100644 --- a/LAEPS.sln +++ b/LAEPS.sln @@ -15,6 +15,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LAEPS", "LAEPS\LAEPS.csproj", "{5EC9A233-D154-4B77-6911-063269A883E9}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Module", "Module", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoginModule", "LoginModule\LoginModule.csproj", "{F79AC87E-7A5A-486F-BE6C-51E81CA569E4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UIShare", "UIShare\UIShare.csproj", "{F7A7D4FA-974C-470F-9543-0B256640BD81}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingModule", "SettingModule\SettingModule.csproj", "{2C3C2DBB-F782-416B-8571-07D3F533820B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateInfoModule", "UpdateInfoModule\UpdateInfoModule.csproj", "{B99017CA-BB14-426A-BBF0-C0C05C6510CA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MainModule", "MainModule\MainModule.csproj", "{715852A3-D2DE-4C2E-AEF2-2BC0ADBEAC0A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,10 +57,36 @@ Global {5EC9A233-D154-4B77-6911-063269A883E9}.Debug|Any CPU.Build.0 = Debug|Any CPU {5EC9A233-D154-4B77-6911-063269A883E9}.Release|Any CPU.ActiveCfg = Release|Any CPU {5EC9A233-D154-4B77-6911-063269A883E9}.Release|Any CPU.Build.0 = Release|Any CPU + {F79AC87E-7A5A-486F-BE6C-51E81CA569E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F79AC87E-7A5A-486F-BE6C-51E81CA569E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F79AC87E-7A5A-486F-BE6C-51E81CA569E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F79AC87E-7A5A-486F-BE6C-51E81CA569E4}.Release|Any CPU.Build.0 = Release|Any CPU + {F7A7D4FA-974C-470F-9543-0B256640BD81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7A7D4FA-974C-470F-9543-0B256640BD81}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7A7D4FA-974C-470F-9543-0B256640BD81}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7A7D4FA-974C-470F-9543-0B256640BD81}.Release|Any CPU.Build.0 = Release|Any CPU + {2C3C2DBB-F782-416B-8571-07D3F533820B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2C3C2DBB-F782-416B-8571-07D3F533820B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2C3C2DBB-F782-416B-8571-07D3F533820B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2C3C2DBB-F782-416B-8571-07D3F533820B}.Release|Any CPU.Build.0 = Release|Any CPU + {B99017CA-BB14-426A-BBF0-C0C05C6510CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B99017CA-BB14-426A-BBF0-C0C05C6510CA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B99017CA-BB14-426A-BBF0-C0C05C6510CA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B99017CA-BB14-426A-BBF0-C0C05C6510CA}.Release|Any CPU.Build.0 = Release|Any CPU + {715852A3-D2DE-4C2E-AEF2-2BC0ADBEAC0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {715852A3-D2DE-4C2E-AEF2-2BC0ADBEAC0A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {715852A3-D2DE-4C2E-AEF2-2BC0ADBEAC0A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {715852A3-D2DE-4C2E-AEF2-2BC0ADBEAC0A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {F79AC87E-7A5A-486F-BE6C-51E81CA569E4} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {2C3C2DBB-F782-416B-8571-07D3F533820B} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {B99017CA-BB14-426A-BBF0-C0C05C6510CA} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {715852A3-D2DE-4C2E-AEF2-2BC0ADBEAC0A} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {22BD9235-6581-454D-97D8-F4E932F80888} EndGlobalSection diff --git a/LAEPS/App.xaml b/LAEPS/App.xaml index 8e5c815..79174dd 100644 --- a/LAEPS/App.xaml +++ b/LAEPS/App.xaml @@ -7,23 +7,8 @@ - - - - - - - - - - - - - - - - + diff --git a/LAEPS/App.xaml.cs b/LAEPS/App.xaml.cs index 0135d1f..c7bc9e3 100644 --- a/LAEPS/App.xaml.cs +++ b/LAEPS/App.xaml.cs @@ -9,10 +9,11 @@ using System.Data; using System.Reflection; using System.Windows; using static System.Runtime.InteropServices.JavaScript.JSType; -using LAEPS.PubEvent; +using UIShare.PubEvent; using Notifications.Wpf.Core; using Logger; using Common; +using ORM; namespace LAEPS { @@ -33,7 +34,6 @@ namespace LAEPS } private void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { - //通常全局异常捕捉的都是致命信息 LoggerHelper.Error(e.Exception.Message,e.Exception.StackTrace); } @@ -50,20 +50,44 @@ namespace LAEPS } protected override void OnInitialized() { - var login=Container.Resolve(); + //初始化数据库 + DatabaseConfig.SetTenant(10001); + DatabaseConfig.InitMySql("127.0.0.1",3306,"LAEPS","root","123456"); + DatabaseConfig.CreateDatabaseAndCheckConnection(createDatabase: true, checkConnection: true); + SqlSugarContext.InitDatabase(); + //显示登录窗口 + var login=Container.Resolve(); + var re=Container.Resolve(); + RegionManager.SetRegionManager(login, re); + RegionManager.SetRegionManager(Application.Current.MainWindow, re); login.Show(); } protected override void RegisterTypes(IContainerRegistry containerRegistry) { - //注册视图 - containerRegistry.RegisterForNavigation("MainView"); - containerRegistry.RegisterForNavigation("SettingView"); - containerRegistry.RegisterForNavigation("UpdateInfoView"); //注册弹窗 containerRegistry.RegisterDialog("MessageBox"); // 注册通知管理器 INotificationManager NotificationManager = new NotificationManager(); containerRegistry.RegisterInstance(NotificationManager); } + //指定模块加载方式(需要手动将模块生成的dll放入Modules文件夹中) + protected override IModuleCatalog CreateModuleCatalog() + { + //指定模块加载方式为从文件夹中以反射发现并加载module(推荐用法) + return new DirectoryModuleCatalog() { ModulePath = @".\Modules" }; + } + //手动模块加载方式 + //protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) + //{ + // Type moduleAType = typeof(LoginModule.LoginModule); + // moduleCatalog.AddModule(new ModuleInfo() + // { + // ModuleName = moduleAType.Name, + // ModuleType = moduleAType.AssemblyQualifiedName, + // InitializationMode = InitializationMode.OnDemand + // }); + + // base.ConfigureModuleCatalog(moduleCatalog); + //} } } diff --git a/LAEPS/LAEPS.csproj b/LAEPS/LAEPS.csproj index 881958b..c85fb8b 100644 --- a/LAEPS/LAEPS.csproj +++ b/LAEPS/LAEPS.csproj @@ -34,20 +34,21 @@ - - - - + + + + + diff --git a/LAEPS/ViewModels/Dialogs/MessageBoxViewModel.cs b/LAEPS/ViewModels/Dialogs/MessageBoxViewModel.cs index 31c09b3..c035272 100644 --- a/LAEPS/ViewModels/Dialogs/MessageBoxViewModel.cs +++ b/LAEPS/ViewModels/Dialogs/MessageBoxViewModel.cs @@ -1,8 +1,5 @@ -using LAEPS.PubEvent; -using ControlzEx.Standard; -using LAEPS.ViewModels; -using Prism.Commands; -using Prism.Mvvm; +using UIShare.PubEvent; +using UIShare.ViewModelBase; using System.Windows.Input; namespace LAEPS.ViewModels.Dialogs diff --git a/LAEPS/ViewModels/ShellViewModel.cs b/LAEPS/ViewModels/ShellViewModel.cs index 8bf4bc2..553dcb3 100644 --- a/LAEPS/ViewModels/ShellViewModel.cs +++ b/LAEPS/ViewModels/ShellViewModel.cs @@ -1,9 +1,9 @@ -using LAEPS.PubEvent; -using LAEPS.Views; +using LAEPS.Views; using MaterialDesignThemes.Wpf; using Notifications.Wpf.Core; using Prism.Events; using Prism.Ioc; +using Prism.Modularity; using System; using System.Collections.Generic; using System.Linq; @@ -11,6 +11,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; +using UIShare.PubEvent; namespace LAEPS.ViewModels { diff --git a/LAEPS/Views/LoginModuleView.xaml b/LAEPS/Views/LoginModuleView.xaml new file mode 100644 index 0000000..90568f9 --- /dev/null +++ b/LAEPS/Views/LoginModuleView.xaml @@ -0,0 +1,21 @@ + + + + + \ No newline at end of file diff --git a/LAEPS/Views/LoginView.xaml.cs b/LAEPS/Views/LoginModuleView.xaml.cs similarity index 84% rename from LAEPS/Views/LoginView.xaml.cs rename to LAEPS/Views/LoginModuleView.xaml.cs index 4902938..5f785b9 100644 --- a/LAEPS/Views/LoginView.xaml.cs +++ b/LAEPS/Views/LoginModuleView.xaml.cs @@ -1,4 +1,4 @@ -using LAEPS.PubEvent; +using UIShare.PubEvent; using MahApps.Metro.Controls; using System; using System.Collections.Generic; @@ -23,9 +23,9 @@ namespace LAEPS.Views /// /// Login.xaml 的交互逻辑 /// - public partial class LoginView : MetroWindow + public partial class LoginModuleView : MetroWindow { - public LoginView(IEventAggregator eventAggregator) + public LoginModuleView(IEventAggregator eventAggregator) { InitializeComponent(); //订阅登录成功事件 diff --git a/LAEPS/Views/LoginView.xaml b/LAEPS/Views/LoginView.xaml deleted file mode 100644 index 4cb15e5..0000000 --- a/LAEPS/Views/LoginView.xaml +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/LAEPS/Views/ShellView.xaml.cs b/LAEPS/Views/ShellView.xaml.cs index 36b002a..fd10347 100644 --- a/LAEPS/Views/ShellView.xaml.cs +++ b/LAEPS/Views/ShellView.xaml.cs @@ -1,4 +1,4 @@ -using LAEPS.PubEvent; +using UIShare.PubEvent; using Prism.Events; using System; using System.Collections.Generic; diff --git a/LoginModule/LoginModule.cs b/LoginModule/LoginModule.cs new file mode 100644 index 0000000..f5865e1 --- /dev/null +++ b/LoginModule/LoginModule.cs @@ -0,0 +1,21 @@ +using LoginModule.Views; +using Prism.Modularity; +using System.Reflection; +namespace LoginModule +{ + public class LoginModule : IModule + { + public void OnInitialized(IContainerProvider containerProvider) + { + IRegionManager regionManager = containerProvider.Resolve(); + regionManager.RegisterViewWithRegion("LoginRegion", typeof(LoginView)); + regionManager.RegisterViewWithRegion("LoginRegion", typeof(RegisterView)); + } + + public void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterForNavigation("LoginView"); + containerRegistry.RegisterForNavigation("RegisterView"); + } + } +} diff --git a/LoginModule/LoginModule.csproj b/LoginModule/LoginModule.csproj new file mode 100644 index 0000000..60cce13 --- /dev/null +++ b/LoginModule/LoginModule.csproj @@ -0,0 +1,12 @@ + + + + net8.0-windows + enable + true + enable + + + + + diff --git a/LAEPS/ViewModels/LoginViewModel.cs b/LoginModule/ViewModels/LoginViewModel.cs similarity index 68% rename from LAEPS/ViewModels/LoginViewModel.cs rename to LoginModule/ViewModels/LoginViewModel.cs index d577657..cffbb91 100644 --- a/LAEPS/ViewModels/LoginViewModel.cs +++ b/LoginModule/ViewModels/LoginViewModel.cs @@ -1,14 +1,15 @@ -using LAEPS.PubEvent; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input; +using UIShare.PubEvent; +using UIShare.ViewModelBase; -namespace LAEPS.ViewModels +namespace LoginModule.ViewModels { - public class LoginViewModel:BindableBase + public class LoginViewModel: NavigateViewModelBase { #region 属性 private string _Password; @@ -25,11 +26,18 @@ namespace LAEPS.ViewModels } #endregion public ICommand LoginCommand { get; set; } + public ICommand RegisterCommand { get; set; } private IEventAggregator _eventAggregator; - public LoginViewModel(IContainerProvider containerProvider) + public LoginViewModel(IContainerProvider containerProvider) : base(containerProvider) { _eventAggregator = containerProvider.Resolve(); LoginCommand = new AsyncDelegateCommand(OnLogin); + RegisterCommand = new AsyncDelegateCommand(OnRegister); + } + + private async Task OnRegister() + { + _regionManager.RequestNavigate("LoginRegion", "RegisterView"); } private async Task OnLogin() diff --git a/LoginModule/ViewModels/RegisterViewModel.cs b/LoginModule/ViewModels/RegisterViewModel.cs new file mode 100644 index 0000000..0daf043 --- /dev/null +++ b/LoginModule/ViewModels/RegisterViewModel.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using UIShare.ViewModelBase; + +namespace LoginModule.ViewModels +{ + public class RegisterViewModel : NavigateViewModelBase + { + #region 属性 + private string _SecondPassword; + public string SecondPassword + { + get => _SecondPassword; + set => SetProperty(ref _SecondPassword, value); + } + private string _Password; + public string Password + { + get => _Password; + set => SetProperty(ref _Password, value); + } + private string _Account; + public string Account + { + get => _Account; + set => SetProperty(ref _Account, value); + } + #endregion + public ICommand BackCommand { get; set; } + public ICommand RegisterCommand { get; set; } + public RegisterViewModel(IContainerProvider containerProvider) : base(containerProvider) + { + BackCommand = new DelegateCommand(OnBack); + RegisterCommand = new AsyncDelegateCommand(OnRegister); + } + + private void OnBack() + { + _regionManager.RequestNavigate("LoginRegion", "LoginView"); + } + + private async Task OnRegister() + { + _regionManager.RequestNavigate("LoginRegion", "LoginView"); + } + } +} diff --git a/LoginModule/Views/LoginView.xaml b/LoginModule/Views/LoginView.xaml new file mode 100644 index 0000000..f7ec751 --- /dev/null +++ b/LoginModule/Views/LoginView.xaml @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LoginModule/Views/LoginView.xaml.cs b/LoginModule/Views/LoginView.xaml.cs new file mode 100644 index 0000000..31db76b --- /dev/null +++ b/LoginModule/Views/LoginView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace LoginModule.Views +{ + /// + /// LoginView.xaml 的交互逻辑 + /// + public partial class LoginView : UserControl + { + public LoginView() + { + InitializeComponent(); + } + } +} diff --git a/LoginModule/Views/RegisterView.xaml b/LoginModule/Views/RegisterView.xaml new file mode 100644 index 0000000..2708b9c --- /dev/null +++ b/LoginModule/Views/RegisterView.xaml @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LoginModule/Views/RegisterView.xaml.cs b/LoginModule/Views/RegisterView.xaml.cs new file mode 100644 index 0000000..f8d1138 --- /dev/null +++ b/LoginModule/Views/RegisterView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace LoginModule.Views +{ + /// + /// RegisterView.xaml 的交互逻辑 + /// + public partial class RegisterView : UserControl + { + public RegisterView() + { + InitializeComponent(); + } + } +} diff --git a/MainModule/MainModule.cs b/MainModule/MainModule.cs new file mode 100644 index 0000000..43e3146 --- /dev/null +++ b/MainModule/MainModule.cs @@ -0,0 +1,19 @@ +using MainModule.Views; +using System.Reflection; + +namespace MainModule +{ + public class MainModule : IModule + { + public void OnInitialized(IContainerProvider containerProvider) + { + IRegionManager regionManager = containerProvider.Resolve(); + regionManager.RegisterViewWithRegion("ShellViewManager", typeof(MainView)); + } + + public void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterForNavigation("MainView"); + } + } +} diff --git a/MainModule/MainModule.csproj b/MainModule/MainModule.csproj new file mode 100644 index 0000000..71a91c1 --- /dev/null +++ b/MainModule/MainModule.csproj @@ -0,0 +1,20 @@ + + + + net8.0-windows + enable + true + enable + + + + + + + + + Code + + + + diff --git a/LAEPS/ViewModels/MainViewModel.cs b/MainModule/ViewModels/MainViewModel.cs similarity index 52% rename from LAEPS/ViewModels/MainViewModel.cs rename to MainModule/ViewModels/MainViewModel.cs index 64a490a..acbd1d8 100644 --- a/LAEPS/ViewModels/MainViewModel.cs +++ b/MainModule/ViewModels/MainViewModel.cs @@ -1,18 +1,6 @@ -using LAEPS.PubEvent; -using LAEPS.ViewModels; -using Logger; -using NLog; -using Prism.Dialogs; -using Prism.Events; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Windows.Input; +using UIShare.ViewModelBase; -namespace LAEPS.ViewModels +namespace MainModule.ViewModels { public class MainViewModel : NavigateViewModelBase { diff --git a/LAEPS/Views/MainView.xaml b/MainModule/Views/MainView.xaml similarity index 92% rename from LAEPS/Views/MainView.xaml rename to MainModule/Views/MainView.xaml index 8c7b8c1..178e897 100644 --- a/LAEPS/Views/MainView.xaml +++ b/MainModule/Views/MainView.xaml @@ -1,4 +1,4 @@ - /// MainView.xaml 的交互逻辑 diff --git a/Model/Entity/BaseEntity.cs b/Model/Entity/BaseEntity.cs index e04f252..8f6f7b0 100644 --- a/Model/Entity/BaseEntity.cs +++ b/Model/Entity/BaseEntity.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Model.Entity { - public class BaseEntity + public abstract class BaseEntity { /// /// 主键Id diff --git a/Model/Entity/UserEntity.cs b/Model/Entity/UserEntity.cs new file mode 100644 index 0000000..f7fbd1a --- /dev/null +++ b/Model/Entity/UserEntity.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model.Entity +{ + public class UserEntity:BaseEntity + { + public string UserName { get; set; } + public string Password { get; set; } + public string Role { get; set; } + public string Status { get; set; } + } +} diff --git a/Model/Result.cs b/Model/Result.cs new file mode 100644 index 0000000..6582ea0 --- /dev/null +++ b/Model/Result.cs @@ -0,0 +1,180 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + public class Result + { + public Result() + { + + } + private int _code; + private readonly string _msg; + + /// + /// 结果是否成功 + /// + public bool IsSuccess => _code == 0; + + /// + /// 结果代码 + /// + public int Code { set => _code = value; get => _code; } + + /// + /// 结果消息 + /// + public string Msg => _msg; + + /// + /// 构造方法 + /// + /// + /// + /// + protected Result(int code, string msg, Exception? exception = null) + { + if (exception != null) + { + var listMoreMsg = new List(); + if (exception is ResultException resultException) + { + listMoreMsg.AddRange(resultException.MessageList); + } + //else if (exception is DeviceControlException deviceControlException) + //{ + // listMoreMsg.Add(deviceControlException.ErrorInfo); + //} + else + { + listMoreMsg.Add(exception.Message); + } + var strMoreMsg = string.Join("、", listMoreMsg.Where(it => !string.IsNullOrWhiteSpace(it))); + if (!string.IsNullOrWhiteSpace(strMoreMsg)) + { + msg += $"({strMoreMsg})"; + } + } + _code = code; + _msg = msg; + } + + /// + /// 返回成功结果 + /// + /// + /// + public static Result Success() + { + return new Result(0, ""); + } + + /// + /// 返回错误结果 + /// + /// + /// + /// + public static Result Error(string msg, Exception? exception = null) + { + return new Result(-1, msg, exception); + } + + + } + + public class Result : Result + { + public Result() + { + + } + private T? _data; + + /// + /// 结果数据 + /// + public T? Data { set => _data = value; get => _data; } + + /// + /// 构造方法 + /// + /// + /// + /// + /// + private Result(int code, string msg, T? data, Exception? exception = null) : base(code, msg, exception) + { + _data = data; + } + + /// + /// 返回成功数据 + /// + /// + /// + public static Result Success(T data) + { + return new Result(0, "", data); + } + + /// + /// 返回失败信息 + /// + /// + /// + /// + public new static Result Error(string msg, Exception? exception = null) + { + return new Result(-1, msg, default, exception); + } + + /// + /// 返回失败信息和数据 + /// + /// + /// + /// + /// + public static Result Error(string msg, T data, Exception? exception = null) + { + return new Result(-1, msg, data, exception); + } + + + } + + public class ResultException : Exception + { + private List? _messageList; + + public List MessageList + { + get + { + List messages = new(); + if (_messageList != null) + { + messages.AddRange(_messageList.Where(it => !string.IsNullOrWhiteSpace(it))); + } + return messages; + } + } + + public override string Message => string.Join(", ", MessageList); + + public ResultException() : base(null) + { + } + + public void AddAdditionMessage(string message) + { + _messageList ??= new(); + _messageList.Add(message); + } + } +} diff --git a/ORM/DatabaseConfig.cs b/ORM/DatabaseConfig.cs index 95b86c5..a790081 100644 --- a/ORM/DatabaseConfig.cs +++ b/ORM/DatabaseConfig.cs @@ -34,7 +34,7 @@ namespace ORM public static int SnowFlakeWorkId { get; private set; } #region 不同数据库初始化方法 - private static void InitSqlite() + public static void InitSqlite() { DbConnectionType = DbType.Sqlite; // 获取程序运行目录 @@ -48,20 +48,20 @@ namespace ORM string DBPath = Path.Combine(folder, "SQL.db"); DbConnectionString = $"Data Source={DBPath};Version=3;"; } - private static void InitMySql(string Server, int Port, string Database, string Uid,string Pwd) + public static void InitMySql(string Server, int Port, string Database, string Uid,string Pwd) { DbConnectionType = DbType.MySql; DbConnectionString = $"Server={Server};Port={Port};Database={Database};Uid={Uid};Pwd={Pwd};"; } - private static void InitSqlServer(string server,int port,string database,string user,string password) + public static void InitSqlServer(string server,int port,string database,string user,string password) { DbConnectionType = DbType.SqlServer; DbConnectionString = $"Data Source={server},{port};Initial Catalog={database};user={user};Password={password};"; } - private static void InitSqlServerLocalDb() + public static void InitSqlServerLocalDb() { DbConnectionType = DbType.SqlServer; string baseDir = AppDomain.CurrentDomain.BaseDirectory; diff --git a/ORM/SqlSugarContext.cs b/ORM/SqlSugarContext.cs index a5f383c..4fb45a9 100644 --- a/ORM/SqlSugarContext.cs +++ b/ORM/SqlSugarContext.cs @@ -3,83 +3,121 @@ using SqlSugar; using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; namespace ORM { - public class SqlSugarContext - { - /// - /// SqlSugarScope单例模式 - /// - public static readonly SqlSugarScope DbContext = new SqlSugarScope( - new ConnectionConfig() - { - DbType = DatabaseConfig.DbConnectionType, - ConnectionString = DatabaseConfig.DbConnectionString, // 连接符字串 - //ConfigId = "Db1",//管理多个数据库 - IsAutoCloseConnection = true, // 自动关闭连接 - InitKeyType = InitKeyType.Attribute // 通过实体类上的特性初始化 - }, - db => - { - // 执行超时时间,单位秒 - db.Ado.CommandTimeOut = 30; + public class SqlSugarContext + { + /// + /// SqlSugarScope单例模式 + /// + public static readonly SqlSugarScope DbContext = new SqlSugarScope( + new ConnectionConfig() + { + DbType = DatabaseConfig.DbConnectionType, + ConnectionString = DatabaseConfig.DbConnectionString, // 连接符字串 + //ConfigId = "Db1",//管理多个数据库 + IsAutoCloseConnection = true, // 自动关闭连接 + InitKeyType = InitKeyType.Attribute // 通过实体类上的特性初始化 + }, + db => + { + // 执行超时时间,单位秒 + db.Ado.CommandTimeOut = 30; - // 每次SQL执行前事件 - db.Aop.OnLogExecuting = (sql, pars) => - { + // 每次SQL执行前事件 + db.Aop.OnLogExecuting = (sql, pars) => + { #if DEBUG - // 确保 SQL 只通过 sqlLogger 记录 - LoggerHelper.sqlLogger.Info("Executing SQL: {0} with parameters: {1}", sql, pars); // 使用 NLog 记录 SQL + // 确保 SQL 只通过 sqlLogger 记录 + LoggerHelper.sqlLogger.Info("Executing SQL: {0} with parameters: {1}", sql, pars); // 使用 NLog 记录 SQL #endif - }; + }; - // SQL执行完 - db.Aop.OnLogExecuted = (sql, pars) => + // SQL执行完 + db.Aop.OnLogExecuted = (sql, pars) => + { + // 执行时间超过1秒记录慢日志 + if (db.Ado.SqlExecutionTime.TotalSeconds > 1) { - // 执行时间超过1秒记录慢日志 - if (db.Ado.SqlExecutionTime.TotalSeconds > 1) + LoggerHelper.sqlLogger.Warn("SQL Slow Execution. Time: {0}, File: {1}, Line: {2}, Method: {3}, SQL: {4}", + db.Ado.SqlExecutionTime.ToString(), // SQL 执行时间 + db.Ado.SqlStackTrace.FirstFileName, // 代码 CS 文件名 + db.Ado.SqlStackTrace.FirstLine, // 代码行数 + db.Ado.SqlStackTrace.FirstMethodName, // 代码方法名 + sql); // 使用 NLog 记录慢 SQL 日志 + } + }; + + // SQL 报错 + db.Aop.OnError = (exp) => + { + // 确保 SQL 错误日志仅通过 sqlLogger 记录 + LoggerHelper.sqlLogger.Error(exp, "SQL Error: {0}", exp.Sql); // 使用 NLog 记录 SQL 错误日志 + }; + + // 数据过滤器:例如在新增数据时生成雪花 Id + db.Aop.DataExecuting = (oldValue, entityInfo) => + { + // 新增操作 + if (entityInfo.OperationType == DataFilterType.InsertByObject) + { + // 主键(long)赋值雪花 Id + if (entityInfo.EntityColumnInfo.IsPrimarykey && entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long)) { - LoggerHelper.sqlLogger.Warn("SQL Slow Execution. Time: {0}, File: {1}, Line: {2}, Method: {3}, SQL: {4}", - db.Ado.SqlExecutionTime.ToString(), // SQL 执行时间 - db.Ado.SqlStackTrace.FirstFileName, // 代码 CS 文件名 - db.Ado.SqlStackTrace.FirstLine, // 代码行数 - db.Ado.SqlStackTrace.FirstMethodName, // 代码方法名 - sql); // 使用 NLog 记录慢 SQL 日志 - } - }; - - // SQL 报错 - db.Aop.OnError = (exp) => - { - // 确保 SQL 错误日志仅通过 sqlLogger 记录 - LoggerHelper.sqlLogger.Error(exp, "SQL Error: {0}", exp.Sql); // 使用 NLog 记录 SQL 错误日志 - }; - - // 数据过滤器:例如在新增数据时生成雪花 Id - db.Aop.DataExecuting = (oldValue, entityInfo) => - { - // 新增操作 - if (entityInfo.OperationType == DataFilterType.InsertByObject) - { - // 主键(long)赋值雪花 Id - if (entityInfo.EntityColumnInfo.IsPrimarykey && entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long)) + var id = ((dynamic)entityInfo.EntityValue).Id; + if (id == null || id == 0) { - var id = ((dynamic)entityInfo.EntityValue).Id; - if (id == null || id == 0) - { - SnowFlakeSingle.WorkId = DatabaseConfig.SnowFlakeWorkId; - SnowFlakeSingle.DatacenterId = DatabaseConfig.SnowFlakeDatacenterId; - entityInfo.SetValue(SnowFlakeSingle.Instance.NextId()); - } + SnowFlakeSingle.WorkId = DatabaseConfig.SnowFlakeWorkId; + SnowFlakeSingle.DatacenterId = DatabaseConfig.SnowFlakeDatacenterId; + entityInfo.SetValue(SnowFlakeSingle.Instance.NextId()); } } - }; + } + }; + } + ); + + /// + /// 初始化数据库,创建所有后缀为 Entity 的表 + /// + public static void InitDatabase() + { + // 加载 Model.dll 文件 + string modelDllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Model.dll"); + + if (!File.Exists(modelDllPath)) + { + throw new FileNotFoundException($"未找到 Model.dll 文件: {modelDllPath}"); + } + + // 加载指定的程序集(Model.dll) + var modelAssembly = Assembly.LoadFrom(modelDllPath); + + // 获取所有的 Model层下的Entity 类(后缀为 Entity) + var entityTypes = modelAssembly.GetTypes() + .Where(t => t.Name.EndsWith("Entity") && t.IsClass && !t.IsInterface && !t.IsAbstract) + .ToList(); + + + // 使用 SqlSugar 自动创建表 + using (var db = DbContext) + { + foreach (var entityType in entityTypes) + { + // 判断该类型是否为类且符合条件 + if (entityType.IsClass) + { + // 自动创建表 + db.CodeFirst.InitTables(entityType); + } } - ); - } + } + } } +} diff --git a/Service/Implement/BaseService.cs b/Service/Implement/BaseService.cs new file mode 100644 index 0000000..7df16db --- /dev/null +++ b/Service/Implement/BaseService.cs @@ -0,0 +1,132 @@ +using Model; +using Model.Entity; +using ORM; +using Service.Interface; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Service.Implement +{ + public class BaseService : IBaseService where TEntity : BaseEntity, new() + { + protected readonly SqlSugarRepository _repository; + + public BaseService(SqlSugarRepository repository) + { + _repository = repository; + } + + /// + /// 查询全部 + /// + public virtual async Task>> GetAllAsync() + { + try + { + var list = await _repository.Entities.ToListAsync(); + return Result>.Success(list); + } + catch (Exception ex) + { + return Result>.Error("查询所有数据失败", ex); + } + } + /// + /// 根据日期查询全部 + /// + public virtual async Task>> GetAllAsyncByDate(DateTime? startDate, DateTime? endDate) + { + try + { + var list = await _repository.Entities.Where(x => x.CreateTime >= startDate && x.CreateTime <= endDate).ToListAsync(); + return Result>.Success(list); + } + catch (Exception ex) + { + return Result>.Error("查询所有数据失败", ex); + } + } + + /// + /// 分页查询 + /// + public virtual async Task>> GetPagedAsync(int pageIndex, int pageSize, RefAsync total) + { + try + { + var list = await _repository.Entities + .OrderBy(d => d.Id) + .ToPageListAsync(pageIndex, pageSize, total); + total.Value = (int)Math.Ceiling((double)total.Value / pageSize); + return Result>.Success(list); + } + catch (Exception ex) + { + return Result>.Error("分页查询数据失败", ex); + } + } + + /// + /// 分页查询,并可以根据日期范围进行过滤 + /// + public virtual async Task>> GetPagedAsync(int pageIndex, int pageSize, RefAsync total, DateTime? startDate, DateTime? endDate) + { + try + { + var list = await _repository.Entities + .Where(x=>x.CreateTime>=startDate&&x.CreateTime <= endDate) + .OrderBy(d => d.Id) + .ToPageListAsync(pageIndex, pageSize, total); + total.Value = (int)Math.Ceiling((double)total.Value / pageSize); + return Result>.Success(list); + } + catch (Exception ex) + { + return Result>.Error("分页查询数据失败", ex); + } + } + + /// + /// 插入单条数据 + /// + public virtual async Task> InsertAsync(TEntity entity) + { + try + { + var result = await _repository.Context.Insertable(entity).ExecuteCommandAsync(); + return Result.Success(result > 0); + } + catch (Exception ex) + { + return Result.Error("插入数据失败", ex); + } + } + /// + /// 删除单条数据(根据 Id) + /// + /// 主键 Id + public virtual async Task> DeleteAsync(long id) + { + if (id <= 0) + return Result.Error("主键 Id 无效,无法删除"); + + try + { + // 删除实体 + var result = await _repository.Context + .Deleteable() + .Where(x => x.Id == id) + .ExecuteCommandAsync(); + + return Result.Success(result > 0); + } + catch (Exception ex) + { + return Result.Error("删除数据失败", ex); + } + } + + } +} diff --git a/Service/Implement/UserService.cs b/Service/Implement/UserService.cs new file mode 100644 index 0000000..35457b1 --- /dev/null +++ b/Service/Implement/UserService.cs @@ -0,0 +1,90 @@ +using Model; +using Model.Entity; +using ORM; +using Service.Implement; + +public class UserService: BaseService +{ + public UserService(SqlSugarRepository repository) : base(repository) + { + } + + public async Task> GetUserByUserNameAsync(string username) + { + if (string.IsNullOrWhiteSpace(username)) + return Result.Error("用户名不能为空"); + + try + { + var user = await _repository.Entities + .Where(x => x.UserName == username) + .FirstAsync(); + + if (user == null) + return Result.Error("用户不存在"); + + return Result.Success(user); + } + catch (Exception ex) + { + return Result.Error("获取用户失败", ex); + } + } + + public override async Task> InsertAsync(UserEntity entity) + { + if (entity == null) + return Result.Error("用户数据不能为空"); + + try + { + // 唯一性校验 + bool exists = await _repository.Entities + .AnyAsync(x => x.UserName == entity.UserName); + + if (exists) + return Result.Error("用户名已存在"); + + var result = await _repository.InsertAsync(entity); + + return Result.Success(result); + } + catch (Exception ex) + { + return Result.Error("插入数据失败", ex); + } + } + /// + /// 更新单条用户记录 + /// + /// 要更新的用户实体,Id 必须有值 + public async Task> UpdateAsync(UserEntity entity) + { + if (entity == null) + return Result.Error("用户数据不能为空"); + + if (entity.Id <= 0) + return Result.Error("主键 Id 无效,无法更新"); + + try + { + // 唯一性校验(可选,如果允许改用户名就检查) + bool exists = await _repository.Entities + .Where(x => x.UserName == entity.UserName && x.Id != entity.Id) + .AnyAsync(); + + if (exists) + return Result.Error("用户名已存在"); + + // 更新整个实体 + var result = await _repository.UpdateAsync(entity); + + return Result.Success(result); + } + catch (Exception ex) + { + return Result.Error("更新用户失败", ex); + } + } + +} diff --git a/Service/Interface/IBaseService.cs b/Service/Interface/IBaseService.cs new file mode 100644 index 0000000..371f980 --- /dev/null +++ b/Service/Interface/IBaseService.cs @@ -0,0 +1,55 @@ +using Model; +using SqlSugar; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Service.Interface +{ + /// + /// 泛型基础服务接口(返回 Result 封装) + /// + /// 实体类型 + public interface IBaseService where TEntity : class, new() + { + /// + /// 查询全部 + /// + /// 返回包含数据的 Result + Task>> GetAllAsync(); + + /// + /// 根据日期查询全部 + /// + /// 开始日期 + /// 结束日期 + /// 返回包含日期范内的数据的 Result + Task>> GetAllAsyncByDate(DateTime? startDate, DateTime? endDate); + + /// + /// 插入单条数据 + /// + /// + /// 返回操作是否成功的 Result + Task> InsertAsync(TEntity entity); + + /// + /// 分页查询 + /// + /// 页码(从1开始) + /// 每页数量 + /// 总条数(输出参数) + /// 返回包含分页数据的 Result + Task>> GetPagedAsync(int pageIndex, int pageSize, RefAsync total); + + /// + /// 分页查询,并根据日期范围进行过滤 + /// + /// 页码(从1开始) + /// 每页数量 + /// 总条数(输出参数) + /// 开始日期 + /// 结束日期 + /// 返回包含分页数据的 Result + Task>> GetPagedAsync(int pageIndex, int pageSize, RefAsync total, DateTime? startDate, DateTime? endDate); + } +} diff --git a/SettingModule/SettingModule.cs b/SettingModule/SettingModule.cs new file mode 100644 index 0000000..56f2440 --- /dev/null +++ b/SettingModule/SettingModule.cs @@ -0,0 +1,19 @@ +using SettingModule.Views; +using System.Reflection; + +namespace SettingModule +{ + public class SettingModule : IModule + { + public void OnInitialized(IContainerProvider containerProvider) + { + IRegionManager regionManager = containerProvider.Resolve(); + regionManager.RegisterViewWithRegion("ShellViewManager", typeof(SettingView)); + } + + public void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterForNavigation("SettingView"); + } + } +} diff --git a/SettingModule/SettingModule.csproj b/SettingModule/SettingModule.csproj new file mode 100644 index 0000000..8d75460 --- /dev/null +++ b/SettingModule/SettingModule.csproj @@ -0,0 +1,23 @@ + + + + net8.0-windows + enable + true + enable + + + + + + + + + Code + + + Code + + + + diff --git a/LAEPS/ViewModels/SettingViewModel.cs b/SettingModule/ViewModels/SettingViewModel.cs similarity index 69% rename from LAEPS/ViewModels/SettingViewModel.cs rename to SettingModule/ViewModels/SettingViewModel.cs index c0b90a8..4a152e0 100644 --- a/LAEPS/ViewModels/SettingViewModel.cs +++ b/SettingModule/ViewModels/SettingViewModel.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using UIShare.ViewModelBase; -namespace LAEPS.ViewModels +namespace SettingModule.ViewModels { public class SettingViewModel : NavigateViewModelBase { diff --git a/LAEPS/Views/SettingView.xaml b/SettingModule/Views/SettingView.xaml similarity index 91% rename from LAEPS/Views/SettingView.xaml rename to SettingModule/Views/SettingView.xaml index e945104..8cfaae9 100644 --- a/LAEPS/Views/SettingView.xaml +++ b/SettingModule/Views/SettingView.xaml @@ -1,4 +1,4 @@ - /// SettingView.xaml 的交互逻辑 diff --git a/LAEPS/Converters/BooleanToVisibilityConverter.cs b/UIShare/Converters/BooleanToVisibilityConverter.cs similarity index 97% rename from LAEPS/Converters/BooleanToVisibilityConverter.cs rename to UIShare/Converters/BooleanToVisibilityConverter.cs index 9d9a4d8..db57ae8 100644 --- a/LAEPS/Converters/BooleanToVisibilityConverter.cs +++ b/UIShare/Converters/BooleanToVisibilityConverter.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Data; -namespace LAEPS.Converters +namespace UIShare.Converters { public class BooleanToVisibilityConverter : IValueConverter { diff --git a/LAEPS/Helpers/PasswordBoxHelper.cs b/UIShare/Helpers/PasswordBoxHelper.cs similarity index 98% rename from LAEPS/Helpers/PasswordBoxHelper.cs rename to UIShare/Helpers/PasswordBoxHelper.cs index 097041d..e5eadd4 100644 --- a/LAEPS/Helpers/PasswordBoxHelper.cs +++ b/UIShare/Helpers/PasswordBoxHelper.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -namespace LAEPS.Helpers +namespace UIShare.Helpers { public static class PasswordBoxHelper { diff --git a/LAEPS/PubEvent/LoginSuccessEvent.cs b/UIShare/PubEvent/LoginSuccessEvent.cs similarity index 87% rename from LAEPS/PubEvent/LoginSuccessEvent.cs rename to UIShare/PubEvent/LoginSuccessEvent.cs index 8a8edb9..45201c8 100644 --- a/LAEPS/PubEvent/LoginSuccessEvent.cs +++ b/UIShare/PubEvent/LoginSuccessEvent.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace LAEPS.PubEvent +namespace UIShare.PubEvent { public class LoginSuccessEvent:PubSubEvent { diff --git a/LAEPS/PubEvent/OverlayEvent.cs b/UIShare/PubEvent/OverlayEvent.cs similarity index 87% rename from LAEPS/PubEvent/OverlayEvent.cs rename to UIShare/PubEvent/OverlayEvent.cs index fe4a047..dd886db 100644 --- a/LAEPS/PubEvent/OverlayEvent.cs +++ b/UIShare/PubEvent/OverlayEvent.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace LAEPS.PubEvent +namespace UIShare.PubEvent { public class OverlayEvent : PubSubEvent { diff --git a/LAEPS/PubEvent/WaitingEvent.cs b/UIShare/PubEvent/WaitingEvent.cs similarity index 87% rename from LAEPS/PubEvent/WaitingEvent.cs rename to UIShare/PubEvent/WaitingEvent.cs index ab36f7f..1633c54 100644 --- a/LAEPS/PubEvent/WaitingEvent.cs +++ b/UIShare/PubEvent/WaitingEvent.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace LAEPS.PubEvent +namespace UIShare.PubEvent { public class WaitingEvent : PubSubEvent { diff --git a/UIShare/Styles/CommonStyle.xaml b/UIShare/Styles/CommonStyle.xaml new file mode 100644 index 0000000..e59a590 --- /dev/null +++ b/UIShare/Styles/CommonStyle.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/LAEPS/Resources/Styles/WindowStyle.xaml b/UIShare/Styles/WindowStyle.xaml similarity index 100% rename from LAEPS/Resources/Styles/WindowStyle.xaml rename to UIShare/Styles/WindowStyle.xaml diff --git a/UIShare/UIShare.csproj b/UIShare/UIShare.csproj new file mode 100644 index 0000000..7ccaa94 --- /dev/null +++ b/UIShare/UIShare.csproj @@ -0,0 +1,20 @@ + + + + net8.0-windows + enable + true + enable + + + + + + + + + + + + + diff --git a/LAEPS/ViewModels/ViewModelBase/DialogViewModelBase.cs b/UIShare/ViewModelBase/DialogViewModelBase.cs similarity index 96% rename from LAEPS/ViewModels/ViewModelBase/DialogViewModelBase.cs rename to UIShare/ViewModelBase/DialogViewModelBase.cs index 885c041..a6c15bd 100644 --- a/LAEPS/ViewModels/ViewModelBase/DialogViewModelBase.cs +++ b/UIShare/ViewModelBase/DialogViewModelBase.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace LAEPS.ViewModels +namespace UIShare.ViewModelBase { public abstract class DialogViewModelBase : BindableBase,IDialogAware { diff --git a/LAEPS/ViewModels/ViewModelBase/NavigateViewModelBase.cs b/UIShare/ViewModelBase/NavigateViewModelBase.cs similarity index 87% rename from LAEPS/ViewModels/ViewModelBase/NavigateViewModelBase.cs rename to UIShare/ViewModelBase/NavigateViewModelBase.cs index 8629903..357f920 100644 --- a/LAEPS/ViewModels/ViewModelBase/NavigateViewModelBase.cs +++ b/UIShare/ViewModelBase/NavigateViewModelBase.cs @@ -5,18 +5,20 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace LAEPS.ViewModels +namespace UIShare.ViewModelBase { public abstract class NavigateViewModelBase : BindableBase, INavigationAware { public DialogCloseListener RequestClose { get; set; } public IEventAggregator _eventAggregator; public IDialogService _dialogService; + public IRegionManager _regionManager; private INotificationManager _notificationManager; public NavigateViewModelBase(IContainerProvider containerProvider) { _eventAggregator = containerProvider.Resolve(); _dialogService = containerProvider.Resolve(); + _regionManager = containerProvider.Resolve(); _notificationManager = containerProvider.Resolve(); } diff --git a/UpdateInfoModule/UpdateInfoModule.cs b/UpdateInfoModule/UpdateInfoModule.cs new file mode 100644 index 0000000..d27816d --- /dev/null +++ b/UpdateInfoModule/UpdateInfoModule.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using UpdateInfoModule.Views; + +namespace UpdateInfoModule +{ + public class UpdateInfoModule : IModule + { + public void OnInitialized(IContainerProvider containerProvider) + { + IRegionManager regionManager = containerProvider.Resolve(); + regionManager.RegisterViewWithRegion("ShellViewManager", typeof(UpdateInfoView)); + } + + public void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterForNavigation("UpdateInfoView"); + } + } +} diff --git a/UpdateInfoModule/UpdateInfoModule.csproj b/UpdateInfoModule/UpdateInfoModule.csproj new file mode 100644 index 0000000..9c40ada --- /dev/null +++ b/UpdateInfoModule/UpdateInfoModule.csproj @@ -0,0 +1,20 @@ + + + + net8.0-windows + enable + true + enable + + + + + + + + + Code + + + + diff --git a/LAEPS/ViewModels/UpdateInfoViewModel.cs b/UpdateInfoModule/ViewModels/UpdateInfoViewModel.cs similarity index 65% rename from LAEPS/ViewModels/UpdateInfoViewModel.cs rename to UpdateInfoModule/ViewModels/UpdateInfoViewModel.cs index 05a4dcd..68bd2db 100644 --- a/LAEPS/ViewModels/UpdateInfoViewModel.cs +++ b/UpdateInfoModule/ViewModels/UpdateInfoViewModel.cs @@ -1,12 +1,6 @@ -using Prism.Dialogs; -using Prism.Events; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using UIShare.ViewModelBase; -namespace LAEPS.ViewModels +namespace UpdateInfoModule.ViewModels { public class UpdateInfoViewModel : NavigateViewModelBase { diff --git a/LAEPS/Views/UpdateInfoView.xaml b/UpdateInfoModule/Views/UpdateInfoView.xaml similarity index 91% rename from LAEPS/Views/UpdateInfoView.xaml rename to UpdateInfoModule/Views/UpdateInfoView.xaml index d49f995..d3a7199 100644 --- a/LAEPS/Views/UpdateInfoView.xaml +++ b/UpdateInfoModule/Views/UpdateInfoView.xaml @@ -1,4 +1,4 @@ - /// UpdateInfoView.xaml 的交互逻辑