添加项目文件。

This commit is contained in:
ShrlAlgo
2025-09-16 16:06:41 +08:00
parent 0e7807b826
commit 98c65ceb3d
922 changed files with 1009489 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Windows;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using MaterialDesignThemes.Wpf;
namespace Szmedi.AIScriptRunner.ViewModels
{
public partial class LoginViewModel : ObservableObject
{
[ObservableProperty]
private string? version;
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(LoginCommand))]
private string? accountName = string.Empty;
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(LoginCommand))]
private string? password = string.Empty;
[ObservableProperty]
private bool isAuthenticated;
[ObservableProperty]
private string? userName;
[ObservableProperty]
private string? companyName;
[ObservableProperty]
private string? phone;
partial void OnIsAuthenticatedChanged(bool oldValue, bool newValue)
{
GlobalVariables.IsAuthenticated = newValue;
}
private bool CanLogin()
{
return !string.IsNullOrEmpty(AccountName) && !string.IsNullOrEmpty(Password);
}
[RelayCommand(CanExecute = nameof(CanLogin))]
private async Task LoginAsync()
{
var response = await GlobalVariables.AuthenticationService.LoginAsync(AccountName, Password);
if (response?.Successful == true)
{
IsAuthenticated = true;
AccountName = $"{response.Data?.UserInfoVO.AccountName}";
UserName = $"{response.Data?.UserInfoVO.NameCn}";
Phone = $"{response.Data?.UserInfoVO.Phone}";
CompanyName = $"{response.Data?.UserInfoVO.CompanyNameCn}";
}
else
{
MessageBox.Show(response.Message, "登录失败", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
//注销
[RelayCommand]
private void Logout()
{
IsAuthenticated = false;
}
//注销
[RelayCommand]
private void Close(Window window)
{
if (window != null)
{
window.Hide();
}
}
}
}