You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using SlnMesnac.Config;
|
|
using SlnMesnac.WPF.Attribute;
|
|
using System;
|
|
using System.Windows;
|
|
|
|
namespace SlnMesnac.WPF.ViewModel.Login
|
|
{
|
|
[RegisterAsSingleton]
|
|
public partial class LoginViewModel: ObservableObject
|
|
{
|
|
private readonly AppConfig _appConfig;
|
|
[ObservableProperty]
|
|
public string systemTitle = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
public string userName = string.Empty;
|
|
|
|
public LoginViewModel(AppConfig appConfig)
|
|
{
|
|
_appConfig = appConfig;
|
|
SystemTitle = "系统测试";
|
|
}
|
|
|
|
|
|
[RequirePermission("Login")]
|
|
public bool Login(string userName,string password)
|
|
{
|
|
bool res = true;
|
|
try
|
|
{
|
|
//res = _usersBusiness.Verify(userName, password);
|
|
if (res)
|
|
{
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
{
|
|
MainWindow mainWindow = App.ServiceProvider.GetService<MainWindow>();
|
|
App.Current.MainWindow = mainWindow;
|
|
mainWindow.Show();
|
|
|
|
});
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show($"登录失败:{ex.Message}");
|
|
}
|
|
return res;
|
|
}
|
|
}
|
|
}
|