This commit is contained in:
empty
2025-12-17 13:56:00 +08:00
parent 5366c56830
commit 473b44510d
41 changed files with 4620 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
using System.Windows;
using System.Windows.Controls;
using PackagingMallShipper.Services;
using PackagingMallShipper.ViewModels;
namespace PackagingMallShipper.Views
{
public partial class LoginWindow : Window
{
private readonly LoginViewModel _viewModel;
private readonly IAuthService _authService;
public LoginWindow()
{
InitializeComponent();
_authService = new AuthService();
_viewModel = new LoginViewModel(_authService);
DataContext = _viewModel;
_viewModel.OnLoginSuccess += OnLoginSuccess;
if (_authService.IsLoggedIn)
{
OpenMainWindow();
}
}
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
{
if (sender is PasswordBox pb)
{
_viewModel.Password = pb.Password;
}
}
private void OnLoginSuccess()
{
OpenMainWindow();
}
private void OpenMainWindow()
{
var orderService = new OrderService();
var syncService = new SyncService(_authService);
var shipService = new ShipService(_authService);
var excelService = new ExcelService(orderService, shipService);
var orderListViewModel = new OrderListViewModel(orderService, syncService, shipService, excelService);
var mainViewModel = new MainViewModel(_authService, orderListViewModel);
var mainWindow = new MainWindow(mainViewModel);
mainViewModel.OnLogout += () =>
{
var loginWindow = new LoginWindow();
loginWindow.Show();
mainWindow.Close();
};
mainWindow.Show();
this.Close();
}
}
}