change - 登录界面修改

master
wenjy 3 weeks ago
parent acee33516f
commit 9b89759cc9

@ -1,9 +1,36 @@
<Application x:Class="Sln.Wcs.UI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Sln.Wcs.UI"
StartupUri="MainWindow.xaml">
xmlns:local="clr-namespace:Sln.Wcs.UI">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.LightBlue.xaml" />
<!--<ResourceDictionary Source="Templates\Languages\StringResource.en-US.xaml" />
<ResourceDictionary Source="Templates\Languages\StringResource.zh-CN.xaml" />-->
</ResourceDictionary.MergedDictionaries>
<!--重写框架主体色-->
<SolidColorBrush x:Key="PrimaryHueLightBrush" Color="#3b76ee" />
<SolidColorBrush x:Key="PrimaryHueLightForegroundBrush" Color="#3b76ee" />
<SolidColorBrush x:Key="PrimaryHueMidBrush" Color="#3b76ee" />
<SolidColorBrush x:Key="PrimaryHueMidForegroundBrush" Color="#3b76ee" />
<SolidColorBrush x:Key="PrimaryHueDarkBrush" Color="#3b76ee" />
<SolidColorBrush x:Key="PrimaryHueDarkForegroundBrush" Color="#3b76ee" />
<!-- DataGrid列标题居中样式 -->
<Style x:Key="DataGridColumnHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
<!-- DataGrid单元格居中样式 -->
<Style x:Key="DataGridCellCenterStyle" TargetType="DataGridCell">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
</Application>

@ -9,6 +9,8 @@ using ZiggyCreatures.Caching.Fusion;
using ZiggyCreatures.Caching.Fusion.Serialization.NewtonsoftJson;
using System.Windows;
using System.IO;
using Sln.Wcs.UI.Page.Login;
using Sln.Wcs.UI.Attribute;
namespace Sln.Wcs.UI
{
@ -34,6 +36,11 @@ namespace Sln.Wcs.UI
var log = ServiceProvider.GetService<SerilogHelper>();
log.Info($"系统启动成功,日志存放位置:{config["logPath"]}");
var loginWindow = ServiceProvider.GetRequiredService<LoginWindow>();
loginWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
loginWindow.Show();
}
private static void ConfigureServices(IServiceCollection services)
@ -56,6 +63,19 @@ namespace Sln.Wcs.UI
.AsSelf()
.WithTransientLifetime());
// 扫描并注册带有特性的窗口和服务
services.Scan(scan => scan
.FromAssemblyOf<LoginWindow>()
.AddClasses(classes => classes.WithAttribute<RegisterAsSingletonAttribute>())
.AsSelf()
.WithSingletonLifetime());
services.Scan(scan => scan
.FromAssemblyOf<LoginWindow>()
.AddClasses(classes => classes.WithAttribute<RegisterAsTransientAttribute>())
.AsSelf()
.WithTransientLifetime());
services.AddSingleton(typeof(SerilogHelper));
services.AddSqlSugarSetup();

@ -1,4 +1,5 @@
using System.Text;
using Sln.Wcs.UI.Attribute;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@ -14,6 +15,8 @@ namespace Sln.Wcs.UI
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
[RegisterAsSingletonAttribute]
public partial class MainWindow : Window
{
public MainWindow()

@ -0,0 +1,58 @@
<Window x:Class="Sln.Wcs.UI.Page.Login.LoginWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Sln.Wcs.UI.Page.Login"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
Title="{Binding SystemTitle}" Height="600" Width="980">
<Window.Background>
<ImageBrush ImageSource="/Templates/image/login-background.jpg" />
</Window.Background>
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Background="Transparent" Height="50" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="50,50">
<Label Content="{Binding SystemTitle}" Foreground="#007DFA" FontSize="25"/>
</StackPanel>
<Border Grid.Column="1" Background="White" Height="300" CornerRadius="10" >
<Grid Cursor="">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Foreground="Gray" Text="用户登录" FontSize="20"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<!--<TextBlock Foreground="Gray" Text="账号:" FontSize="16" Margin="0,10,10,0"/>
<TextBox x:Name="UserNameStr" Foreground="Gray" FontSize="16" Width="150" Height="35"/>-->
<materialDesign:PackIcon Kind="AccountKeyOutline" VerticalAlignment="Bottom" Height="25" Width="25" Margin="0,0,10,0"/>
<TextBox x:Name="UserNameStr" Width="150" FontSize="16" VerticalAlignment="Center" materialDesign:HintAssist.Hint="请输入用户名" Style="{StaticResource MaterialDesignFloatingHintTextBox}" />
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<!--<TextBlock Foreground="Gray" Text="密码:" FontSize="16" Margin="0,10,10,0"/>-->
<!--<PasswordBox x:Name="PasswordStr" HorizontalAlignment="Left" VerticalContentAlignment="Center" Width="150" PasswordChar="*" />-->
<materialDesign:PackIcon Kind="AccountLockOutline" VerticalAlignment="Bottom" Height="25" Width="25" Margin="0,0,10,0"/>
<PasswordBox
x:Name="PasswordStr" Width="150" FontSize="16"
materialDesign:HintAssist.Foreground="Green"
materialDesign:HintAssist.Hint="请输入密码"
materialDesign:TextFieldAssist.UnderlineBrush="Green"
Style="{StaticResource MaterialDesignFloatingHintPasswordBox}" Cursor="Hand" />
</StackPanel>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="3">
<Button x:Name="LoginBtn" Content="登录" Background="#007DFA" ToolTip="MaterialDesignFlatMidButton" Margin="10,0,10,0" Style="{StaticResource MaterialDesignFlatMidBgButton}" Foreground="White" FontSize="16" Width="150" Height="30" Click="LoginBtn_Click"/>
</StackPanel>
</Grid>
</Border>
</Grid>
</Grid>
</Window>

@ -0,0 +1,54 @@
using Sln.Wcs.UI.Attribute;
using Sln.Wcs.UI.ViewModel.Login;
using System;
using System.Windows;
namespace Sln.Wcs.UI.Page.Login
{
/// <summary>
/// LoginWindow.xaml 的交互逻辑
/// </summary>
[RegisterAsSingletonAttribute]
public partial class LoginWindow : Window
{
private readonly LoginViewModel _loginViewModel;
public LoginWindow(LoginViewModel loginViewModel)
{
_loginViewModel = loginViewModel;
InitializeComponent();
this.DataContext = _loginViewModel;
}
private async void LoginBtn_Click(object sender, RoutedEventArgs e)
{
string userName = UserNameStr.Text.ToString();
string password = PasswordStr.Password;
//if (string.IsNullOrEmpty(userName))
//{
// MessageBox.Show("用户名不允许为空");
// return;
//}
//if (string.IsNullOrEmpty(password))
//{
// MessageBox.Show("密码不允许为空");
// return;
//}
bool res = _loginViewModel.Login(userName,password);
if (res)
{
this.Closing += MainWindow_Closing;
this.Close();
}
}
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
this.Closing -= MainWindow_Closing; // 防止多次绑定
e.Cancel = true;
this.Visibility = Visibility.Hidden; // 隐藏窗口
}
}
}

@ -10,6 +10,9 @@
<ItemGroup>
<None Remove="appsettings.json" />
<None Remove="Templates\gif\loading.gif" />
<None Remove="Templates\image\background.jpg" />
<None Remove="Templates\image\login-background.jpg" />
</ItemGroup>
<ItemGroup>
@ -18,10 +21,17 @@
</Content>
</ItemGroup>
<ItemGroup>
<Resource Include="Templates\gif\loading.gif" />
<Resource Include="Templates\image\background.jpg" />
<Resource Include="Templates\image\login-background.jpg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Com.Ctrip.Framework.Apollo" Version="2.11.0" />
<PackageReference Include="Com.Ctrip.Framework.Apollo.Configuration" Version="2.11.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.1" />
<PackageReference Include="MaterialDesignThemes" Version="5.3.1" />
<PackageReference Include="Rougamo.Fody" Version="5.0.2" />
<PackageReference Include="Scrutor" Version="7.0.0" />
<PackageReference Include="WpfAnimatedGif" Version="2.0.2" />
@ -35,8 +45,4 @@
<ProjectReference Include="..\Sln.Wcs.Serilog\Sln.Wcs.Serilog.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Page\Login\" />
</ItemGroup>
</Project>

Loading…
Cancel
Save