update
This commit is contained in:
parent
546c248535
commit
b6788f4a37
@ -10,6 +10,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageReference Include="log4net" Version="3.0.2" />
|
||||
<PackageReference Include="MaterialDesignXaml.DialogsHelper" Version="1.0.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
|
||||
|
||||
@ -1,21 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VideoConcat.Models;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System.Windows;
|
||||
|
||||
namespace VideoConcat.ViewModels
|
||||
{
|
||||
internal class MainWindowViewModel
|
||||
public partial class MainWindowViewModel : ObservableObject
|
||||
{
|
||||
private string? _username;
|
||||
private string? _password;
|
||||
|
||||
public MainWindowModel MainWindowsModel { get; set; } = new MainWindowModel();
|
||||
|
||||
public void Login()
|
||||
public string Username
|
||||
{
|
||||
string? userName = MainWindowsModel.Username;
|
||||
string? passWord = MainWindowsModel.Password;
|
||||
get => _username ?? "";
|
||||
set => SetProperty(ref _username, value);
|
||||
}
|
||||
|
||||
public string Password
|
||||
{
|
||||
get => _password ?? "";
|
||||
set => SetProperty(ref _password, value);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task LoginAsync()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// 模拟登录逻辑
|
||||
if (Username == "admin" && Password == "password")
|
||||
{
|
||||
MessageBox.Show("登录成功!");
|
||||
// 这里可以导航到主页面或其他操作
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("用户名或密码错误!");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,8 +62,7 @@
|
||||
CaretBrush="#FFD94448"
|
||||
SelectionBrush="#FFD94448"
|
||||
materialDesign:HintAssist.Hint="输入 密码"
|
||||
Password="{Binding MainWindowModel.Password}">
|
||||
</PasswordBox>
|
||||
x:Name="PasswordBox"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="10"
|
||||
HorizontalAlignment="Center"
|
||||
|
||||
@ -12,12 +12,12 @@ namespace VideoConcat.Views
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new MainWindowModel();
|
||||
DataContext = new MainWindowModel();
|
||||
}
|
||||
|
||||
private void BtnExit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void BtnLogin_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user