更新项目配置,新增设备同步模块,优化WebSocket和Swagger配置,增强SCADA系统的免登录接口,支持数据字典项和登录日志的免登录查询与记录。调整Java编译设置,确保更好的开发体验。
This commit is contained in:
50
yy-admin-master/YY.Admin/Views/Control/MenuTreeView.xaml
Normal file
50
yy-admin-master/YY.Admin/Views/Control/MenuTreeView.xaml
Normal file
@@ -0,0 +1,50 @@
|
||||
<UserControl x:Class="YY.Admin.Views.Control.MenuTreeView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:YY.Admin.Views"
|
||||
xmlns:beh="clr-namespace:YY.Admin.Core.Behavior;assembly=YY.Admin.Core"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<TreeView
|
||||
x:Name="MenuTree"
|
||||
ItemsSource="{Binding MenuItems}"
|
||||
Background="Transparent"
|
||||
BorderThickness="0">
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="TreeViewItem" BasedOn="{StaticResource CusTreeViewItemBaseStyle}">
|
||||
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
|
||||
<Setter Property="FontSize" Value="{StaticResource FontSize}"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
|
||||
<!-- 禁止双击自动展开 -->
|
||||
<EventSetter Event="MouseDoubleClick" Handler="TreeViewItem_MouseDoubleClick"/>
|
||||
<!--<Setter Property="Margin" Value="0"/>-->
|
||||
<!-- 绑定命令到 TreeView 的 DataContext 下的 NavigateCommand -->
|
||||
<Setter
|
||||
Property="beh:TreeViewItemClickBehavior.Command"
|
||||
Value="{Binding DataContext.NavigateCommand,
|
||||
RelativeSource={RelativeSource AncestorType=TreeView}}"/>
|
||||
<!-- 把命令参数设为当前数据上下文(菜单项本身) -->
|
||||
<Setter Property="beh:TreeViewItemClickBehavior.CommandParameter" Value="{Binding}"/>
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
<TreeView.ItemTemplate>
|
||||
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
||||
<StackPanel Orientation="Horizontal" Height="50">
|
||||
<!--菜单图标-->
|
||||
<TextBlock
|
||||
Text="{Binding Icon}"
|
||||
FontFamily="{StaticResource AntDesignIcon}"
|
||||
FontSize="16"
|
||||
VerticalAlignment="Center"
|
||||
Margin="20,0,12,0"/>
|
||||
<!--菜单名称-->
|
||||
<TextBlock Text="{Binding Name}" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</HierarchicalDataTemplate>
|
||||
</TreeView.ItemTemplate>
|
||||
</TreeView>
|
||||
</UserControl>
|
||||
22
yy-admin-master/YY.Admin/Views/Control/MenuTreeView.xaml.cs
Normal file
22
yy-admin-master/YY.Admin/Views/Control/MenuTreeView.xaml.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace YY.Admin.Views.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MenuTreeView.xaml
|
||||
/// </summary>
|
||||
public partial class MenuTreeView : UserControl
|
||||
{
|
||||
public MenuTreeView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void TreeViewItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
// 阻止双击默认展开行为
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<UserControl x:Class="YY.Admin.Views.Control.PaginationDataGridControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<!-- 底部分页区 -->
|
||||
<DockPanel LastChildFill="False" Margin="0 10 0 0">
|
||||
|
||||
<!-- 分页条(靠右) -->
|
||||
<hc:Pagination
|
||||
MaxPageCount="{Binding MaxPageCount}"
|
||||
PageIndex="{Binding PageIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
DataCountPerPage="{Binding DataCountPerPage}"
|
||||
IsJumpEnabled="True"
|
||||
DockPanel.Dock="Right"
|
||||
Margin="0,0,4,0">
|
||||
<hc:Interaction.Triggers>
|
||||
<hc:EventTrigger EventName="PageUpdated">
|
||||
<hc:EventToCommand Command="{Binding PageUpdatedCmd}" PassEventArgsToCommand="True" />
|
||||
</hc:EventTrigger>
|
||||
</hc:Interaction.Triggers>
|
||||
</hc:Pagination>
|
||||
|
||||
<hc:ComboBox
|
||||
Width="100"
|
||||
ItemsSource="{Binding PageSizes}"
|
||||
SelectedIndex="0"
|
||||
SelectedValue="{Binding DataCountPerPage, Mode=TwoWay}"
|
||||
DisplayMemberPath="Value"
|
||||
SelectedValuePath="Key"
|
||||
Margin="5,0 10 0"
|
||||
DockPanel.Dock="Right">
|
||||
<hc:Interaction.Triggers>
|
||||
<hc:EventTrigger EventName="SelectionChanged">
|
||||
<hc:EventToCommand Command="{Binding PageSizeUpdatedCmd}"
|
||||
PassEventArgsToCommand="True"/>
|
||||
</hc:EventTrigger>
|
||||
</hc:Interaction.Triggers>
|
||||
</hc:ComboBox>
|
||||
|
||||
<!-- 分页信息(靠左) -->
|
||||
<TextBlock
|
||||
Text="{Binding TotalCount, StringFormat='共 {0} 条'}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="10,0 5 0"
|
||||
DockPanel.Dock="Right"/>
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using YY.Admin.Core;
|
||||
using YY.Admin.Services.Service;
|
||||
|
||||
namespace YY.Admin.Views.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// PaginationDataGridControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class PaginationDataGridControl : UserControl
|
||||
{
|
||||
public PaginationDataGridControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
//this.Loaded += PaginationDataGridControl_Loaded;
|
||||
}
|
||||
|
||||
// 确保用户在控制加载时触发列生成
|
||||
//private void PaginationDataGridControl_Loaded(object sender, RoutedEventArgs e)
|
||||
//{
|
||||
// // 确保 DataGrid 已完全加载
|
||||
// Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() =>
|
||||
// {
|
||||
// // 确保 DataGrid 控件已初始化并且 ItemsSource 不为 null
|
||||
// var data = DataGrid.ItemsSource;
|
||||
// if (data == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // 获取数据模型的类型
|
||||
// var type = data.GetType().GetGenericArguments().FirstOrDefault();
|
||||
// if (type == null) return;
|
||||
|
||||
// // 获取所有带有 BindDescriptionAttribute 的属性
|
||||
// var properties = type.GetProperties()
|
||||
// .Where(prop => Attribute.IsDefined(prop, typeof(BindDescriptionAttribute)))
|
||||
// .OrderBy(prop => ((BindDescriptionAttribute)prop.GetCustomAttribute(typeof(BindDescriptionAttribute))).DisplayIndex)
|
||||
// .ToList();
|
||||
|
||||
// foreach (var prop in properties)
|
||||
// {
|
||||
// var attribute = prop.GetCustomAttribute<BindDescriptionAttribute>();
|
||||
// if (attribute != null)
|
||||
// {
|
||||
// // 检查列是否已经存在
|
||||
// if (!ColumnExists(attribute.HeaderName))
|
||||
// {
|
||||
// var column = CreateDataGridColumn(attribute, prop);
|
||||
// if (column != null)
|
||||
// {
|
||||
// // 通过绑定添加列
|
||||
// DataGrid.Columns.Add(column);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }));
|
||||
//}
|
||||
|
||||
//// 检查列是否已经存在
|
||||
//private bool ColumnExists(string headerName)
|
||||
//{
|
||||
// return DataGrid.Columns.Any(c => c.Header.ToString() == headerName);
|
||||
//}
|
||||
|
||||
//private DataGridColumn CreateDataGridColumn(BindDescriptionAttribute attribute, PropertyInfo property)
|
||||
//{
|
||||
// DataGridColumn column = null;
|
||||
|
||||
// // 根据属性的显示方式来创建不同的列
|
||||
// switch (attribute.ShowAs)
|
||||
// {
|
||||
// case ShowScheme.普通文本:
|
||||
// column = new DataGridTextColumn
|
||||
// {
|
||||
// Header = attribute.HeaderName,
|
||||
// Binding = new Binding(property.Name),
|
||||
// Width = attribute.Width,
|
||||
// DisplayIndex = attribute.DisplayIndex
|
||||
// };
|
||||
// break;
|
||||
|
||||
// case ShowScheme.自定义:
|
||||
// // 如果需要自定义列,您可以在这里扩展并处理自定义类型的列
|
||||
// break;
|
||||
// }
|
||||
|
||||
// return column;
|
||||
//}
|
||||
}
|
||||
}
|
||||
193
yy-admin-master/YY.Admin/Views/Control/SidebarControl.xaml
Normal file
193
yy-admin-master/YY.Admin/Views/Control/SidebarControl.xaml
Normal file
@@ -0,0 +1,193 @@
|
||||
<UserControl x:Class="YY.Admin.Views.Control.SidebarControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:core="clr-namespace:YY.Admin.Core;assembly=YY.Admin.Core"
|
||||
xmlns:ctls="clr-namespace:YY.Admin.Core.Controls;assembly=YY.Admin.Core"
|
||||
xmlns:local="clr-namespace:YY.Admin.Views.Control">
|
||||
|
||||
<UserControl.Resources>
|
||||
|
||||
<!-- AntDesign 模板 -->
|
||||
<DataTemplate x:Key="AntDesignIconTemplate">
|
||||
<TextBlock
|
||||
FontFamily="{StaticResource AntDesignIcon}"
|
||||
FontSize="22"
|
||||
Text="{Binding Icon}"
|
||||
Margin="0,0,0,5"
|
||||
HorizontalAlignment="Center"/>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- MaterialDesign 模板 -->
|
||||
<DataTemplate x:Key="MaterialDesignIconTemplate">
|
||||
<md:PackIcon
|
||||
Kind="{Binding Icon}"
|
||||
Width="22"
|
||||
Height="22"
|
||||
Margin="0,0,0,5"
|
||||
HorizontalAlignment="Center"/>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- FontAwesome 模板 -->
|
||||
<DataTemplate x:Key="FontawesomeIconTemplate">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon="{Binding Icon}"
|
||||
FontSize="22"
|
||||
Margin="0,0,0,5"
|
||||
HorizontalAlignment="Center"/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="NavItemTemplate">
|
||||
<StackPanel Orientation="Vertical" Margin="5" HorizontalAlignment="Center">
|
||||
<ContentControl>
|
||||
<ContentControl.Style>
|
||||
<Style TargetType="ContentControl">
|
||||
<!-- 默认模板(AntDesign) -->
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource AntDesignIconTemplate}"/>
|
||||
<!-- 绑定数据上下文 -->
|
||||
<Setter Property="Content" Value="{Binding}"/>
|
||||
|
||||
<!-- 触发器根据 IconType 切换模板 -->
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IconType}" Value="{x:Static core:IconTypeEnum.MaterialDesign}">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource MaterialDesignIconTemplate}"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IconType}" Value="{x:Static core:IconTypeEnum.FontAwesome}">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource FontawesomeIconTemplate}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
<TextBlock Text="{Binding Name}" FontSize="12" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" TextAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="NavItemStyle" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItemBaseStyle}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Grid x:Name="templateRoot" Margin="0,0,0,5">
|
||||
<!-- 左侧指示器 -->
|
||||
<Border
|
||||
x:Name="indicator"
|
||||
Width="4"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Margin="6,0,0,0"
|
||||
CornerRadius="2"
|
||||
Background="{DynamicResource PrimaryBrush}"
|
||||
Opacity="0"
|
||||
Panel.ZIndex="1"
|
||||
Height="{Binding ActualHeight, ElementName=templateRoot, Converter={StaticResource PercentageConverter}, ConverterParameter=0.4}">
|
||||
<Border.RenderTransform>
|
||||
<TranslateTransform Y="10"/>
|
||||
</Border.RenderTransform>
|
||||
</Border>
|
||||
|
||||
<!-- 内容边框 -->
|
||||
<Border x:Name="border" CornerRadius="6" Background="Transparent" Margin="5,0">
|
||||
<ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<!-- 选中动画 -->
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter TargetName="content" Property="TextBlock.Foreground" Value="{DynamicResource PrimaryBrush}"/>
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="indicator"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0.8"
|
||||
Duration="0:0:0.25"/>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="indicator"
|
||||
Storyboard.TargetProperty="RenderTransform.(TranslateTransform.Y)"
|
||||
To="0"
|
||||
Duration="0:0:0.25"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.EnterActions>
|
||||
<Trigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="indicator"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0"
|
||||
Duration="0:0:0.25"/>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="indicator"
|
||||
Storyboard.TargetProperty="RenderTransform.(TranslateTransform.Y)"
|
||||
To="10"
|
||||
Duration="0:0:0.25"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.ExitActions>
|
||||
</Trigger>
|
||||
|
||||
<!-- 鼠标悬停 -->
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter TargetName="content" Property="TextBlock.Foreground" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<!-- 鼠标点击触发命令 -->
|
||||
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="OnNavItemMouseDown"/>
|
||||
</Style>
|
||||
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,0,1,0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<!-- 上部占满剩余空间 -->
|
||||
<RowDefinition Height="*"/>
|
||||
<!-- 底部自适应 -->
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 上半部分:主导航 -->
|
||||
<ListBox
|
||||
Grid.Row="0"
|
||||
Padding="0,5,0,0"
|
||||
BorderThickness="0"
|
||||
hc:BorderElement.CornerRadius="0"
|
||||
ItemsSource="{Binding TopNavItems}"
|
||||
SelectedItem="{Binding SelectedTopNavItem, Mode=TwoWay}"
|
||||
ItemTemplate="{StaticResource NavItemTemplate}"
|
||||
ItemContainerStyle="{StaticResource NavItemStyle}">
|
||||
<!--<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<prism:InvokeCommandAction
|
||||
Command="{Binding NavItemClickCommand}"
|
||||
CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType=ListBox}}"/>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>-->
|
||||
</ListBox>
|
||||
|
||||
<!-- 底部部分:固定操作 -->
|
||||
<ListBox
|
||||
Grid.Row="1"
|
||||
Padding="0"
|
||||
BorderThickness="0"
|
||||
hc:BorderElement.CornerRadius="0"
|
||||
ItemsSource="{Binding BottomNavItems}"
|
||||
SelectedItem="{Binding SelectedBottomNavItem, Mode=TwoWay}"
|
||||
ItemTemplate="{StaticResource NavItemTemplate}"
|
||||
ItemContainerStyle="{StaticResource NavItemStyle}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using YY.Admin.Module;
|
||||
|
||||
namespace YY.Admin.Views.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Sidebar.xaml
|
||||
/// </summary>
|
||||
public partial class SidebarControl : UserControl
|
||||
{
|
||||
public SidebarControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void OnNavItemMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is ListBoxItem item && item.DataContext is NavItem navItem)
|
||||
{
|
||||
// 执行命令(如果有)
|
||||
if (navItem.Command?.CanExecute(navItem) == true)
|
||||
{
|
||||
navItem.Command.Execute(navItem);
|
||||
}
|
||||
|
||||
// 如果不可选,阻止选中
|
||||
if (!navItem.IsActive)
|
||||
{
|
||||
// 阻止 ListBox 自动选择该项
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<UserControl x:Class="YY.Admin.Views.Control.TabContentView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:prism="http://prismlibrary.com/">
|
||||
<Grid>
|
||||
<!-- 这个 ContentControl 将被注册为 Prism 区域 -->
|
||||
<ContentControl x:Name="PART_ContentHost" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
371
yy-admin-master/YY.Admin/Views/Control/TabContentView.xaml.cs
Normal file
371
yy-admin-master/YY.Admin/Views/Control/TabContentView.xaml.cs
Normal file
@@ -0,0 +1,371 @@
|
||||
//using Prism.Ioc;
|
||||
//using System;
|
||||
//using System.Windows;
|
||||
//using System.Windows.Controls;
|
||||
//using System.Windows.Threading;
|
||||
|
||||
//namespace YY.Admin.Views.Control
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// TabContentView.xaml 的交互逻辑
|
||||
// /// </summary>
|
||||
// public partial class TabContentView : UserControl
|
||||
// {
|
||||
// public TabContentView()
|
||||
// {
|
||||
// InitializeComponent();
|
||||
// this.Loaded += TabContentView_Loaded;
|
||||
// this.Unloaded += TabContentView_Unloaded;
|
||||
// }
|
||||
|
||||
// private bool _navigated = false;
|
||||
|
||||
// private void TabContentView_Loaded(object sender, RoutedEventArgs e)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (string.IsNullOrWhiteSpace(RegionName))
|
||||
// return;
|
||||
|
||||
// var regionManager = ContainerLocator.Current.Resolve<IRegionManager>();
|
||||
|
||||
// // 把内部 ContentControl 注册为 region(基于 RegionName)
|
||||
// RegionManager.SetRegionName(PART_ContentHost, RegionName);
|
||||
// RegionManager.SetRegionManager(PART_ContentHost, regionManager);
|
||||
|
||||
// // 延迟导航,确保 region 真正注册到 RegionManager 并且模板生成为止
|
||||
// if (!_navigated && !string.IsNullOrEmpty(ViewName))
|
||||
// {
|
||||
// Dispatcher.BeginInvoke(new Action(() =>
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// // 再次检查 region 是否存在并执行导航
|
||||
// if (regionManager.Regions.ContainsRegionWithName(RegionName))
|
||||
// {
|
||||
// regionManager.RequestNavigate(RegionName, ViewName);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // 如果 region 仍然不存在,尝试 RequestNavigate(Prism 通常会创建 region)
|
||||
// regionManager.RequestNavigate(RegionName, ViewName);
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// System.Diagnostics.Debug.WriteLine($"TabContentView 导航异常: {ex.Message}");
|
||||
// }
|
||||
// }), DispatcherPriority.Background);
|
||||
|
||||
// _navigated = true;
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// System.Diagnostics.Debug.WriteLine($"TabContentView_Loaded 出错: {ex.Message}");
|
||||
// }
|
||||
// }
|
||||
|
||||
// private void TabContentView_Unloaded(object sender, RoutedEventArgs e)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (!string.IsNullOrWhiteSpace(RegionName))
|
||||
// {
|
||||
// var regionManager = ContainerLocator.Current.Resolve<IRegionManager>();
|
||||
// if (regionManager.Regions.ContainsRegionWithName(RegionName))
|
||||
// {
|
||||
// var region = regionManager.Regions[RegionName];
|
||||
// region.RemoveAll();
|
||||
// regionManager.Regions.Remove(RegionName);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// System.Diagnostics.Debug.WriteLine($"TabContentView_Unloaded 清理异常: {ex.Message}");
|
||||
// }
|
||||
// }
|
||||
|
||||
// #region RegionName DP
|
||||
// public static readonly DependencyProperty RegionNameProperty =
|
||||
// DependencyProperty.Register(nameof(RegionName), typeof(string), typeof(TabContentView), new PropertyMetadata(null));
|
||||
|
||||
// public string RegionName
|
||||
// {
|
||||
// get => (string)GetValue(RegionNameProperty);
|
||||
// set => SetValue(RegionNameProperty, value);
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
// #region ViewName DP
|
||||
// public static readonly DependencyProperty ViewNameProperty =
|
||||
// DependencyProperty.Register(nameof(ViewName), typeof(string), typeof(TabContentView), new PropertyMetadata(null));
|
||||
|
||||
// public string ViewName
|
||||
// {
|
||||
// get => (string)GetValue(ViewNameProperty);
|
||||
// set => SetValue(ViewNameProperty, value);
|
||||
// }
|
||||
// #endregion
|
||||
// }
|
||||
//}
|
||||
using Prism.Ioc;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace YY.Admin.Views.Control
|
||||
{
|
||||
public partial class TabContentView : UserControl
|
||||
{
|
||||
public TabContentView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.Loaded += TabContentView_Loaded;
|
||||
this.Unloaded += TabContentView_Unloaded;
|
||||
this.IsVisibleChanged += TabContentView_IsVisibleChanged;
|
||||
this.DataContextChanged += TabContentView_DataContextChanged;
|
||||
}
|
||||
|
||||
private bool _navigated = false;
|
||||
private IRegionManager _regionManager;
|
||||
private DispatcherOperation _pendingNavigationOp;
|
||||
|
||||
#region DPs
|
||||
public static readonly DependencyProperty RegionNameProperty =
|
||||
DependencyProperty.Register(nameof(RegionName), typeof(string), typeof(TabContentView), new PropertyMetadata(null, OnRegionOrViewNameChanged));
|
||||
|
||||
public string RegionName
|
||||
{
|
||||
get => (string)GetValue(RegionNameProperty);
|
||||
set => SetValue(RegionNameProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ViewNameProperty =
|
||||
DependencyProperty.Register(nameof(ViewName), typeof(string), typeof(TabContentView), new PropertyMetadata(null, OnRegionOrViewNameChanged));
|
||||
|
||||
public string ViewName
|
||||
{
|
||||
get => (string)GetValue(ViewNameProperty);
|
||||
set => SetValue(ViewNameProperty, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void TabContentView_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(RegionName))
|
||||
return;
|
||||
|
||||
_regionManager = ContainerLocator.Current.Resolve<IRegionManager>();
|
||||
|
||||
// 确保 region/manager 设置在后续导航前准备好(但不要重复注册 region 这里)
|
||||
// We will call PrepareRegionForRegistration inside EnsureNavigateIfNeeded before actual registration.
|
||||
EnsureNavigateIfNeeded();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"TabContentView_Loaded 出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void TabContentView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
=> EnsureNavigateIfNeeded();
|
||||
|
||||
private void TabContentView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
=> EnsureNavigateIfNeeded();
|
||||
|
||||
private void EnsureNavigateIfNeeded()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_navigated)
|
||||
return;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(RegionName) || string.IsNullOrWhiteSpace(ViewName))
|
||||
return;
|
||||
|
||||
if (!IsLoaded || !IsVisible)
|
||||
return;
|
||||
|
||||
if (_regionManager == null)
|
||||
_regionManager = ContainerLocator.Current.Resolve<IRegionManager>();
|
||||
|
||||
// 在注册 region 之前准备 host(清理旧 region 与清空 Content),避免 Prism 抛 Content 非空异常
|
||||
PrepareRegionForRegistration();
|
||||
|
||||
// 取消之前挂起的导航(保证最后一次胜出)
|
||||
if (_pendingNavigationOp != null && _pendingNavigationOp.Status == DispatcherOperationStatus.Pending)
|
||||
{
|
||||
Debug.WriteLine($"取消挂起导航: region={RegionName}, view={ViewName}");
|
||||
_pendingNavigationOp.Abort();
|
||||
_pendingNavigationOp = null;
|
||||
}
|
||||
|
||||
var desiredView = ViewName;
|
||||
var desiredRegion = RegionName;
|
||||
|
||||
_pendingNavigationOp = Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_regionManager == null)
|
||||
_regionManager = ContainerLocator.Current.Resolve<IRegionManager>();
|
||||
|
||||
// 现在把 PART_ContentHost 注册为一个 region(设置 RegionName/RegionManager)
|
||||
// 注意:如果前面清理正确,这里不会再触发 ContentControl already has content 错误
|
||||
RegionManager.SetRegionName(PART_ContentHost, desiredRegion);
|
||||
RegionManager.SetRegionManager(PART_ContentHost, _regionManager);
|
||||
|
||||
Debug.WriteLine($"开始 RequestNavigate -> region={desiredRegion}, view={desiredView}");
|
||||
|
||||
_regionManager.RequestNavigate(desiredRegion, desiredView, result =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (result.Success == true)
|
||||
{
|
||||
_navigated = true;
|
||||
Debug.WriteLine($"导航成功: region={desiredRegion}, view={desiredView}");
|
||||
}
|
||||
else
|
||||
{
|
||||
_navigated = false;
|
||||
Debug.WriteLine($"导航失败: region={desiredRegion}, view={desiredView}, error={result.Exception?.Message}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_navigated = false;
|
||||
Debug.WriteLine($"导航回调异常: {ex.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"调度导航异常: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_pendingNavigationOp = null;
|
||||
}
|
||||
}), DispatcherPriority.Background);
|
||||
|
||||
Debug.WriteLine($"调度导航: Region={RegionName}, View={ViewName}, Loaded={IsLoaded}, Visible={IsVisible}, navigated={_navigated}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"EnsureNavigateIfNeeded 异常: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在注册 region 之前清理宿主控件与 RegionManager 中可能残留的 region。
|
||||
/// 这一步是防止 Prism 在 adapt 时因为 ContentControl.Content 非空而抛异常。
|
||||
/// </summary>
|
||||
private void PrepareRegionForRegistration()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 如果 RegionManager 中已存在同名 region,则先移除它(并 RemoveAll 内容)
|
||||
if (_regionManager != null && _regionManager.Regions.ContainsRegionWithName(RegionName))
|
||||
{
|
||||
try
|
||||
{
|
||||
var existing = _regionManager.Regions[RegionName];
|
||||
existing.RemoveAll();
|
||||
_regionManager.Regions.Remove(RegionName);
|
||||
Debug.WriteLine($"已移除旧 region: {RegionName}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"移除旧 region 发生异常: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 如果宿主 ContentControl 已经有内容,清空它(很关键)
|
||||
if (PART_ContentHost != null && PART_ContentHost.Content != null)
|
||||
{
|
||||
Debug.WriteLine($"清空 PART_ContentHost.Content (原内容类型: {PART_ContentHost.Content.GetType().Name})");
|
||||
PART_ContentHost.Content = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"PrepareRegionForRegistration 异常: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void TabContentView_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 取消挂起导航
|
||||
if (_pendingNavigationOp != null && _pendingNavigationOp.Status == DispatcherOperationStatus.Pending)
|
||||
{
|
||||
_pendingNavigationOp.Abort();
|
||||
_pendingNavigationOp = null;
|
||||
}
|
||||
|
||||
// 清理 region 与宿主内容
|
||||
if (!string.IsNullOrWhiteSpace(RegionName))
|
||||
{
|
||||
var rm = _regionManager ?? ContainerLocator.Current.Resolve<IRegionManager>();
|
||||
try
|
||||
{
|
||||
if (rm != null && rm.Regions.ContainsRegionWithName(RegionName))
|
||||
{
|
||||
var region = rm.Regions[RegionName];
|
||||
region.RemoveAll();
|
||||
rm.Regions.Remove(RegionName);
|
||||
Debug.WriteLine($"卸载并移除 region: {RegionName}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"TabContentView_Unloaded 清理 region 异常: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
if (PART_ContentHost != null && PART_ContentHost.Content != null)
|
||||
{
|
||||
PART_ContentHost.Content = null;
|
||||
Debug.WriteLine($"Unloaded: 清空 PART_ContentHost.Content");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"TabContentView_Unloaded 清理异常: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_navigated = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnRegionOrViewNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is TabContentView tc)
|
||||
{
|
||||
// 新参数到来,允许再次导航
|
||||
tc._navigated = false;
|
||||
|
||||
// 取消旧挂起导航
|
||||
if (tc._pendingNavigationOp != null && tc._pendingNavigationOp.Status == DispatcherOperationStatus.Pending)
|
||||
{
|
||||
tc._pendingNavigationOp.Abort();
|
||||
tc._pendingNavigationOp = null;
|
||||
}
|
||||
|
||||
// 尝试导航(这一调用会在 Loaded/可见时真正执行)
|
||||
tc.EnsureNavigateIfNeeded();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
361
yy-admin-master/YY.Admin/Views/DashboardView.xaml
Normal file
361
yy-admin-master/YY.Admin/Views/DashboardView.xaml
Normal file
@@ -0,0 +1,361 @@
|
||||
<UserControl x:Class="YY.Admin.Views.DashboardView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:ext="clr-namespace:YY.Admin.Core.Extension;assembly=YY.Admin.Core"
|
||||
xmlns:ctls="clr-namespace:YY.Admin.Core.Controls;assembly=YY.Admin.Core"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
|
||||
xmlns:cuslvc="clr-namespace:YY.Admin.Core.LiveCharts2;assembly=YY.Admin.Core"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True">
|
||||
|
||||
<hc:ScrollViewer IsInertiaEnabled="True">
|
||||
<StackPanel Style="{StaticResource BaseViewStyle}">
|
||||
<ItemsControl ItemsSource="{Binding StatisticCards}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ctls:GridPanel MinWidth="180" Gap="20"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border
|
||||
Background="{DynamicResource ThirdlyRegionBrush}"
|
||||
CornerRadius="8"
|
||||
Padding="24"
|
||||
Effect="{StaticResource EffectShadow1}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock
|
||||
Text="{Binding Title}"
|
||||
FontSize="14"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}"
|
||||
Margin="0,0,0,8"/>
|
||||
<TextBlock
|
||||
Text="{Binding Value}"
|
||||
FontSize="28"
|
||||
FontWeight="Bold"
|
||||
Margin="0,0,0,4"/>
|
||||
<TextBlock
|
||||
Text="{Binding Trend}"
|
||||
FontSize="12"
|
||||
Foreground="#52c41a"/>
|
||||
</StackPanel>
|
||||
|
||||
<Border
|
||||
Grid.Column="1"
|
||||
Background="{Binding Color}"
|
||||
Width="48"
|
||||
Height="48"
|
||||
CornerRadius="24"
|
||||
Opacity="0.1"/>
|
||||
<TextBlock Grid.Column="1"
|
||||
Text=""
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
FontSize="24"
|
||||
Foreground="{Binding Color}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<!-- 图表区域 -->
|
||||
<Grid Margin="0,20,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 访问趋势图 -->
|
||||
<Border
|
||||
Grid.Column="0"
|
||||
Background="{DynamicResource ThirdlyRegionBrush}"
|
||||
CornerRadius="8"
|
||||
Padding="24"
|
||||
Effect="{StaticResource EffectShadow1}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
Text="访问趋势"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Margin="0,0,0,16"/>
|
||||
<Border Grid.Row="1" CornerRadius="4">
|
||||
<lvc:CartesianChart Background="Transparent">
|
||||
<lvc:CartesianChart.XAxes>
|
||||
<lvc:AxesCollection>
|
||||
<lvc:XamlAxis>
|
||||
<lvc:XamlAxis.LabelsPaint>
|
||||
<Binding Path="SkinType" Converter="{StaticResource BrushToSolidColorPaintConverter}">
|
||||
<Binding.ConverterParameter>
|
||||
<cuslvc:CusSolidColorPaint CusColor="PrimaryTextColor"/>
|
||||
</Binding.ConverterParameter>
|
||||
</Binding>
|
||||
</lvc:XamlAxis.LabelsPaint>
|
||||
</lvc:XamlAxis>
|
||||
</lvc:AxesCollection>
|
||||
</lvc:CartesianChart.XAxes>
|
||||
|
||||
<lvc:CartesianChart.YAxes>
|
||||
<lvc:AxesCollection>
|
||||
<lvc:XamlAxis>
|
||||
<lvc:XamlAxis.LabelsPaint>
|
||||
<Binding Path="SkinType" Converter="{StaticResource BrushToSolidColorPaintConverter}">
|
||||
<Binding.ConverterParameter>
|
||||
<cuslvc:CusSolidColorPaint CusColor="PrimaryTextColor"/>
|
||||
</Binding.ConverterParameter>
|
||||
</Binding>
|
||||
</lvc:XamlAxis.LabelsPaint>
|
||||
<lvc:XamlAxis.SeparatorsPaint>
|
||||
<Binding Path="SkinType" Converter="{StaticResource BrushToSolidColorPaintConverter}">
|
||||
<Binding.ConverterParameter>
|
||||
<cuslvc:CusSolidColorPaint CusColor="ThirdlyBorderBrush"/>
|
||||
</Binding.ConverterParameter>
|
||||
</Binding>
|
||||
</lvc:XamlAxis.SeparatorsPaint>
|
||||
</lvc:XamlAxis>
|
||||
</lvc:AxesCollection>
|
||||
</lvc:CartesianChart.YAxes>
|
||||
|
||||
<lvc:CartesianChart.Series>
|
||||
<lvc:SeriesCollection>
|
||||
<lvc:XamlColumnSeries
|
||||
Values="{Binding Values1}"
|
||||
Padding="2"
|
||||
PointMeasuredCommand="{Binding PointMeasuredCommand}"
|
||||
/>
|
||||
<lvc:XamlColumnSeries
|
||||
Values="{Binding Values2}"
|
||||
Padding="0"
|
||||
PointMeasuredCommand="{Binding PointMeasuredCommand}"/>
|
||||
</lvc:SeriesCollection>
|
||||
</lvc:CartesianChart.Series>
|
||||
</lvc:CartesianChart>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 最近活动 -->
|
||||
<Border
|
||||
Grid.Column="2"
|
||||
Background="{DynamicResource ThirdlyRegionBrush}"
|
||||
CornerRadius="8"
|
||||
Padding="24"
|
||||
Effect="{StaticResource EffectShadow1}">
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
Text="最近活动"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Margin="0,0,0,16"/>
|
||||
|
||||
<ItemsControl ItemsSource="{Binding RecentActivities}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border BorderBrush="{DynamicResource ThirdlyBorderBrush}"
|
||||
BorderThickness="0,0,0,1"
|
||||
Padding="0,12">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border
|
||||
Grid.Column="0"
|
||||
Background="#1890ff"
|
||||
Width="32"
|
||||
Height="32"
|
||||
CornerRadius="16"
|
||||
Margin="0,0,12,0">
|
||||
<TextBlock
|
||||
Text=""
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
FontSize="12"
|
||||
Foreground="White"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<StackPanel Grid.Column="1">
|
||||
<TextBlock
|
||||
Text="{Binding Title}"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
Margin="0,0,0,4"/>
|
||||
<TextBlock
|
||||
Text="{Binding Description}"
|
||||
FontSize="12"
|
||||
Foreground="{DynamicResource SecondaryTextBrush}"
|
||||
TextWrapping="Wrap"
|
||||
Margin="0,0,0,4"/>
|
||||
<TextBlock
|
||||
Text="{Binding Time, StringFormat='{}{0:MM-dd HH:mm}'}"
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource ThirdlyTextBrush}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<!-- 快捷操作 -->
|
||||
<Border
|
||||
Background="{DynamicResource ThirdlyRegionBrush}"
|
||||
CornerRadius="8"
|
||||
Padding="24"
|
||||
Margin="0,20,0,0"
|
||||
Effect="{StaticResource EffectShadow1}">
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
Text="快捷操作"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Margin="0,0,0,16"/>
|
||||
|
||||
<UniformGrid Rows="1" Columns="4">
|
||||
<Button
|
||||
Style="{StaticResource ButtonCustom}"
|
||||
Padding="0,8">
|
||||
<StackPanel>
|
||||
<Grid>
|
||||
<Border
|
||||
Background="#52c41a"
|
||||
Width="48"
|
||||
Height="48"
|
||||
CornerRadius="24"
|
||||
Opacity="0.1"/>
|
||||
<TextBlock
|
||||
Text=""
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
FontSize="24"
|
||||
Foreground="#52c41a"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
|
||||
<TextBlock
|
||||
Text="添加用户"
|
||||
FontSize="14"
|
||||
Margin="0,5,0,0"
|
||||
HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
Style="{StaticResource ButtonCustom}"
|
||||
Padding="0,8">
|
||||
<StackPanel>
|
||||
<Grid>
|
||||
<Border
|
||||
Background="#faad14"
|
||||
Width="48"
|
||||
Height="48"
|
||||
CornerRadius="24"
|
||||
Opacity="0.1"/>
|
||||
<TextBlock
|
||||
Text=""
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
FontSize="24"
|
||||
Foreground="#faad14"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
<TextBlock
|
||||
Text="系统设置"
|
||||
FontSize="14"
|
||||
Margin="0,5,0,0"
|
||||
HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
Style="{StaticResource ButtonCustom}"
|
||||
Padding="0,8">
|
||||
<StackPanel>
|
||||
<Grid>
|
||||
<Border
|
||||
Background="#1890ff"
|
||||
Width="48"
|
||||
Height="48"
|
||||
CornerRadius="24"
|
||||
Opacity="0.1"/>
|
||||
<TextBlock
|
||||
Text=""
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
FontSize="24"
|
||||
Foreground="#1890ff"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
<TextBlock
|
||||
Text="数据备份"
|
||||
FontSize="14"
|
||||
Margin="0,5,0,0"
|
||||
HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
Style="{StaticResource ButtonCustom}"
|
||||
Padding="0,8">
|
||||
<StackPanel>
|
||||
<Grid>
|
||||
<Border
|
||||
Background="#1890ff"
|
||||
Width="48"
|
||||
Height="48"
|
||||
CornerRadius="24"
|
||||
Opacity="0.1"/>
|
||||
<TextBlock
|
||||
Text=""
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
FontSize="24"
|
||||
Foreground="#1890ff"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
<TextBlock
|
||||
Text="查看日志"
|
||||
FontSize="14"
|
||||
Margin="0,5,0,0"
|
||||
HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</UniformGrid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 加载指示器 -->
|
||||
<!--<Border Visibility="{Binding IsLoading, Converter={StaticResource Boolean2VisibilityConverter}}"
|
||||
Background="White"
|
||||
CornerRadius="8"
|
||||
Padding="24"
|
||||
Margin="0,16,0,0">
|
||||
<StackPanel HorizontalAlignment="Center">
|
||||
<hc:LoadingCircle Width="50" Height="50"/>
|
||||
<TextBlock Text="数据加载中..."
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,10,0,0"
|
||||
Foreground="#666"/>
|
||||
</StackPanel>
|
||||
</Border>-->
|
||||
</StackPanel>
|
||||
</hc:ScrollViewer>
|
||||
</UserControl>
|
||||
17
yy-admin-master/YY.Admin/Views/DashboardView.xaml.cs
Normal file
17
yy-admin-master/YY.Admin/Views/DashboardView.xaml.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace YY.Admin.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// DashboardView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DashboardView : UserControl
|
||||
{
|
||||
public DashboardView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
101
yy-admin-master/YY.Admin/Views/Dialogs/AlertDialogView.xaml
Normal file
101
yy-admin-master/YY.Admin/Views/Dialogs/AlertDialogView.xaml
Normal file
@@ -0,0 +1,101 @@
|
||||
<UserControl x:Class="YY.Admin.Views.Dialogs.AlertDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
xmlns:ctls="clr-namespace:YY.Admin.Core.Controls;assembly=YY.Admin.Core"
|
||||
Width="400" Height="260">
|
||||
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="DialogButton" TargetType="Button">
|
||||
<Setter Property="Background" Value="#1890ff"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Height" Value="32"/>
|
||||
<Setter Property="Width" Value="80"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border Background="White"
|
||||
CornerRadius="8"
|
||||
BorderBrush="#f0f0f0"
|
||||
BorderThickness="1"
|
||||
>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<Border Grid.Row="0"
|
||||
Background="#1890ff"
|
||||
CornerRadius="8,8,0,0"
|
||||
Height="50">
|
||||
<Grid Margin="16,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 图标和标题 -->
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
Foreground="White"
|
||||
FontSize="16"
|
||||
Margin="0,0,8,0"/>
|
||||
<TextBlock Text="{Binding Title}"
|
||||
Foreground="White"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- 关闭按钮 -->
|
||||
<Button Grid.Column="2"
|
||||
Command="{Binding CloseCommand}"
|
||||
Style="{StaticResource ButtonIcon}"
|
||||
Foreground="White"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Width="24" Height="24"
|
||||
hc:IconElement.Geometry="{StaticResource ErrorGeometry}"
|
||||
Padding="0"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<Border Grid.Row="1" Padding="20">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock Text="{Binding Message}"
|
||||
TextWrapping="Wrap"
|
||||
TextAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="14"
|
||||
Foreground="#666666"
|
||||
LineHeight="20"/>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
|
||||
<!-- 按钮区域 -->
|
||||
<Border Grid.Row="2"
|
||||
Background="#fafafa"
|
||||
CornerRadius="0,0,8,8"
|
||||
Height="60">
|
||||
<Button Content="确定"
|
||||
Command="{Binding CloseCommand}"
|
||||
Style="{StaticResource DialogButton}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace YY.Admin.Views.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// AlertDialogView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AlertDialogView : UserControl
|
||||
{
|
||||
public AlertDialogView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
116
yy-admin-master/YY.Admin/Views/Dialogs/ConfirmDialogView.xaml
Normal file
116
yy-admin-master/YY.Admin/Views/Dialogs/ConfirmDialogView.xaml
Normal file
@@ -0,0 +1,116 @@
|
||||
<UserControl x:Class="YY.Admin.Views.Dialogs.ConfirmDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:YY.Admin.Views.Dialogs"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
mc:Ignorable="d"
|
||||
Width="420" Height="280">
|
||||
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="PrimaryButtonStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="#1890ff"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Height" Value="32"/>
|
||||
<Setter Property="Width" Value="80"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#40a9ff"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" Value="#096dd9"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SecondaryButtonStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="#666666"/>
|
||||
<Setter Property="BorderBrush" Value="#d9d9d9"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Height" Value="32"/>
|
||||
<Setter Property="Width" Value="80"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#f5f5f5"/>
|
||||
<Setter Property="BorderBrush" Value="#40a9ff"/>
|
||||
<Setter Property="Foreground" Value="#40a9ff"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" Value="#e6f7ff"/>
|
||||
<Setter Property="BorderBrush" Value="#096dd9"/>
|
||||
<Setter Property="Foreground" Value="#096dd9"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border Background="White"
|
||||
BorderBrush="#f0f0f0"
|
||||
BorderThickness="1"
|
||||
CornerRadius="4">
|
||||
<Grid Margin="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<Border Grid.Row="0"
|
||||
Background="#fafafa"
|
||||
Height="40"
|
||||
CornerRadius="4,4,0,0"
|
||||
BorderThickness="0,0,0,1"
|
||||
BorderBrush="#f0f0f0">
|
||||
<StackPanel Orientation="Horizontal" Margin="16,0">
|
||||
<TextBlock Text="提示"
|
||||
VerticalAlignment="Center"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="#333333"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 消息内容 -->
|
||||
<ScrollViewer Grid.Row="1"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Padding="16">
|
||||
<TextBlock Text="{Binding Message}"
|
||||
TextWrapping="Wrap"
|
||||
TextAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="14"
|
||||
Foreground="#666666"
|
||||
LineHeight="20"/>
|
||||
</ScrollViewer>
|
||||
|
||||
<!-- 按钮区域 -->
|
||||
<Border Grid.Row="2"
|
||||
Background="#fafafa"
|
||||
Height="60"
|
||||
CornerRadius="0,0,4,4"
|
||||
BorderThickness="0,1,0,0"
|
||||
BorderBrush="#f0f0f0">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
<Button Content="确定"
|
||||
Command="{Binding YesCommand}"
|
||||
Style="{StaticResource PrimaryButtonStyle}"
|
||||
Margin="0,0,12,0"/>
|
||||
<Button Content="取消"
|
||||
Command="{Binding NoCommand}"
|
||||
Style="{StaticResource SecondaryButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace YY.Admin.Views.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// ConfirmDialogView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ConfirmDialogView : UserControl
|
||||
{
|
||||
public ConfirmDialogView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
78
yy-admin-master/YY.Admin/Views/Dialogs/ErrorDialogView.xaml
Normal file
78
yy-admin-master/YY.Admin/Views/Dialogs/ErrorDialogView.xaml
Normal file
@@ -0,0 +1,78 @@
|
||||
<UserControl x:Class="YY.Admin.Views.Dialogs.ErrorDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:ctls="clr-namespace:YY.Admin.Core.Controls;assembly=YY.Admin.Core"
|
||||
Width="420" Height="280">
|
||||
<Border Background="White"
|
||||
CornerRadius="8"
|
||||
BorderBrush="#f0f0f0"
|
||||
BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<Border Grid.Row="0"
|
||||
Background="#ff4d4f"
|
||||
CornerRadius="8,8,0,0"
|
||||
Height="50">
|
||||
<Grid Margin="16,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
Foreground="White"
|
||||
FontSize="16"
|
||||
Margin="0,0,8,0"/>
|
||||
<TextBlock Text="错误提示"
|
||||
Foreground="White"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<Button Grid.Column="2"
|
||||
Command="{Binding CloseCommand}"
|
||||
Style="{StaticResource ButtonIcon}"
|
||||
Foreground="White"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Width="24" Height="24"
|
||||
hc:IconElement.Geometry="{StaticResource ErrorGeometry}"
|
||||
Padding="0"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<Border Grid.Row="1" Padding="20">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- 错误消息 -->
|
||||
<ScrollViewer Grid.Column="1" VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock Text="{Binding Message}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Foreground="#666666"
|
||||
LineHeight="20"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace YY.Admin.Views.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// ErrorDialogView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ErrorDialogView : UserControl
|
||||
{
|
||||
public ErrorDialogView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<UserControl x:Class="YY.Admin.Views.Dialogs.ServerSettingsDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ctls="clr-namespace:YY.Admin.Core.Controls;assembly=YY.Admin.Core"
|
||||
Width="460" Height="360">
|
||||
<Border Background="White" BorderBrush="#f0f0f0" BorderThickness="1" CornerRadius="4">
|
||||
<Grid Margin="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border Grid.Row="0" Background="#fafafa" Height="42" CornerRadius="4,4,0,0" BorderThickness="0,0,0,1" BorderBrush="#f0f0f0">
|
||||
<StackPanel Orientation="Horizontal" Margin="16,0">
|
||||
<TextBlock Text="服务器设置" VerticalAlignment="Center" FontWeight="SemiBold" Foreground="#333333"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<StackPanel Grid.Row="1" Margin="20,16,20,0">
|
||||
<TextBlock Text="IP" Margin="0,0,0,6"/>
|
||||
<TextBox Text="{Binding Ip, UpdateSourceTrigger=PropertyChanged}" Height="32"/>
|
||||
|
||||
<TextBlock Text="端口" Margin="0,12,0,6"/>
|
||||
<TextBox Text="{Binding Port, UpdateSourceTrigger=PropertyChanged}" Height="32"/>
|
||||
|
||||
<TextBlock Text="WebSocket 地址(可选)" Margin="0,12,0,6"/>
|
||||
<TextBox Text="{Binding WebSocketUrl, UpdateSourceTrigger=PropertyChanged}" Height="32"/>
|
||||
|
||||
<TextBlock Text="后端上下文路径" Margin="0,12,0,6"/>
|
||||
<TextBox Text="{Binding BasePath, UpdateSourceTrigger=PropertyChanged}" Height="32"/>
|
||||
|
||||
<TextBlock Text="{Binding ErrorMessage}" Foreground="Red" Margin="0,12,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<Border Grid.Row="2" Background="#fafafa" Height="62" CornerRadius="0,0,4,4" BorderThickness="0,1,0,0" BorderBrush="#f0f0f0">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button Command="{Binding SaveCommand}" Width="90" Height="34" Margin="0,0,12,0" Background="#1890ff" Foreground="White" BorderThickness="0">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<ctls:FontAwesomeIcon Icon="" IconFamily="Solid" Margin="0,0,6,0"/>
|
||||
<TextBlock Text="保存"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Command="{Binding CancelCommand}" Width="90" Height="34" Background="Transparent" BorderBrush="#d9d9d9">
|
||||
<TextBlock Text="取消"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace YY.Admin.Views.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// ServerSettingsDialogView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ServerSettingsDialogView : UserControl
|
||||
{
|
||||
public ServerSettingsDialogView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
110
yy-admin-master/YY.Admin/Views/Dialogs/SuccessDialogView.xaml
Normal file
110
yy-admin-master/YY.Admin/Views/Dialogs/SuccessDialogView.xaml
Normal file
@@ -0,0 +1,110 @@
|
||||
<UserControl x:Class="YY.Admin.Views.Dialogs.SuccessDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:ctls="clr-namespace:YY.Admin.Core.Controls;assembly=YY.Admin.Core"
|
||||
Width="420" Height="280">
|
||||
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="SuccessButton" TargetType="Button" BasedOn="{StaticResource DialogButton}">
|
||||
<Setter Property="Background" Value="#52c41a"/>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border Background="White"
|
||||
CornerRadius="8"
|
||||
BorderBrush="#f0f0f0"
|
||||
BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<Border Grid.Row="0"
|
||||
Background="#52c41a"
|
||||
CornerRadius="8,8,0,0"
|
||||
Height="50">
|
||||
<Grid Margin="16,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
Foreground="White"
|
||||
FontSize="16"
|
||||
Margin="0,0,8,0"/>
|
||||
<TextBlock Text="操作成功"
|
||||
Foreground="White"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<Button Grid.Column="2"
|
||||
Command="{Binding CloseCommand}"
|
||||
Style="{StaticResource ButtonIcon}"
|
||||
Foreground="White"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Width="24" Height="24"
|
||||
hc:IconElement.Geometry="{StaticResource ErrorGeometry}"
|
||||
Padding="0"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<Border Grid.Row="1" Padding="20">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 成功图标 -->
|
||||
<Border Grid.Column="0"
|
||||
Background="#f6ffed"
|
||||
Width="48" Height="48"
|
||||
CornerRadius="24"
|
||||
Margin="0,0,16,0">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
Foreground="#52c41a"
|
||||
FontSize="20"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<!-- 成功消息 -->
|
||||
<ScrollViewer Grid.Column="1" VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock Text="{Binding Message}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Foreground="#666666"
|
||||
LineHeight="20"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 按钮区域 -->
|
||||
<Border Grid.Row="2"
|
||||
Background="#fafafa"
|
||||
CornerRadius="0,0,8,8"
|
||||
Height="60">
|
||||
<Button Content="确定"
|
||||
Command="{Binding CloseCommand}"
|
||||
Style="{StaticResource SuccessButton}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace YY.Admin.Views.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// SuccessDialogView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class SuccessDialogView : UserControl
|
||||
{
|
||||
public SuccessDialogView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
110
yy-admin-master/YY.Admin/Views/Dialogs/WarningDialogView.xaml
Normal file
110
yy-admin-master/YY.Admin/Views/Dialogs/WarningDialogView.xaml
Normal file
@@ -0,0 +1,110 @@
|
||||
<UserControl x:Class="YY.Admin.Views.Dialogs.WarningDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:ctls="clr-namespace:YY.Admin.Core.Controls;assembly=YY.Admin.Core"
|
||||
Width="420" Height="280">
|
||||
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="WarningButton" TargetType="Button">
|
||||
<Setter Property="Background" Value="#faad14"/>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border Background="White"
|
||||
CornerRadius="8"
|
||||
BorderBrush="#f0f0f0"
|
||||
BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<Border Grid.Row="0"
|
||||
Background="#faad14"
|
||||
CornerRadius="8,8,0,0"
|
||||
Height="50">
|
||||
<Grid Margin="16,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
Foreground="White"
|
||||
FontSize="16"
|
||||
Margin="0,0,8,0"/>
|
||||
<TextBlock Text="警告提示"
|
||||
Foreground="White"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<Button Grid.Column="2"
|
||||
Command="{Binding CloseCommand}"
|
||||
Style="{StaticResource ButtonIcon}"
|
||||
Foreground="White"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Width="24" Height="24"
|
||||
hc:IconElement.Geometry="{StaticResource ErrorGeometry}"
|
||||
Padding="0"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<Border Grid.Row="1" Padding="20">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 警告图标 -->
|
||||
<Border Grid.Column="0"
|
||||
Background="#fffbe6"
|
||||
Width="48" Height="48"
|
||||
CornerRadius="24"
|
||||
Margin="0,0,16,0">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
Foreground="#faad14"
|
||||
FontSize="20"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<!-- 警告消息 -->
|
||||
<ScrollViewer Grid.Column="1" VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock Text="{Binding Message}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Foreground="#666666"
|
||||
LineHeight="20"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 按钮区域 -->
|
||||
<Border Grid.Row="2"
|
||||
Background="#fafafa"
|
||||
CornerRadius="0,0,8,8"
|
||||
Height="60">
|
||||
<Button Content="确定"
|
||||
Command="{Binding CloseCommand}"
|
||||
Style="{StaticResource WarningButton}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace YY.Admin.Views.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// WarningDialogView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class WarningDialogView : UserControl
|
||||
{
|
||||
public WarningDialogView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
168
yy-admin-master/YY.Admin/Views/LoginWindow.xaml
Normal file
168
yy-admin-master/YY.Admin/Views/LoginWindow.xaml
Normal file
@@ -0,0 +1,168 @@
|
||||
<hc:Window x:Class="YY.Admin.Views.LoginWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:consts="clr-namespace:YY.Admin.Core.Const;assembly=YY.Admin.Core"
|
||||
xmlns:ctls="clr-namespace:YY.Admin.Core.Controls;assembly=YY.Admin.Core"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
Icon="/Resources/Icon/logo.ico"
|
||||
Title="{Binding Title}"
|
||||
Width="650"
|
||||
Height="500"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ResizeMode="CanMinimize"
|
||||
ShowInTaskbar="True"
|
||||
KeyDown="Window_KeyDown"
|
||||
FontSize="{StaticResource FontSize }">
|
||||
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- 使用独立的HandyControl主题资源,不受主题切换影响 -->
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<Grid Background="{DynamicResource RegionBrush}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="260"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image
|
||||
Source="/Resources/Icon/login.png"
|
||||
Stretch="Uniform"/>
|
||||
|
||||
<Border Grid.Column="1">
|
||||
<Grid>
|
||||
<Button
|
||||
Command="{Binding OpenServerSettingsCommand}"
|
||||
Width="34"
|
||||
Height="34"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Margin="0,8,8,0"
|
||||
ToolTip="服务器设置">
|
||||
<ctls:FontAwesomeIcon Icon="" IconFamily="Solid"/>
|
||||
</Button>
|
||||
<StackPanel Margin="20 0 20 20">
|
||||
<!-- Logo和标题 -->
|
||||
<StackPanel HorizontalAlignment="Center" Margin="0,20,0,40">
|
||||
<TextBlock
|
||||
Text="{x:Static consts:CommonConst.SystemName}"
|
||||
FontSize="24"
|
||||
FontWeight="Bold"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,15,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- 登录表单 -->
|
||||
<StackPanel x:Name="LoginForm">
|
||||
<!-- 用户名 -->
|
||||
<Grid VerticalAlignment="Center">
|
||||
<hc:TextBox
|
||||
Text="{Binding LoginInput.Username, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.Placeholder="请输入用户名"
|
||||
hc:InfoElement.Title="用户名"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
hc:InfoElement.ContentHeight="32"
|
||||
Margin="0,0,0,20"
|
||||
Padding="30 0 8 0 "/>
|
||||
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
IconFamily="Solid"
|
||||
Foreground="#c0c4cc"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="8,4,0,0"/>
|
||||
</Grid>
|
||||
|
||||
<Grid VerticalAlignment="Center">
|
||||
<hc:PasswordBox
|
||||
UnsafePassword="{Binding LoginInput.Password, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.Placeholder="请输入密码"
|
||||
hc:InfoElement.Title="密码"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
hc:InfoElement.ContentHeight="32"
|
||||
IsSafeEnabled="False"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,0,20"
|
||||
Padding="30,0,8,0"/>
|
||||
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
IconFamily="Solid"
|
||||
Foreground="#c0c4cc"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="8,4,0,0"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 记住我 -->
|
||||
<CheckBox
|
||||
Content="记住我"
|
||||
IsChecked="{Binding LoginInput.RememberMe}"
|
||||
Margin="0,0,0,20"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="{StaticResource FontSize}"/>
|
||||
|
||||
<!-- 错误信息 -->
|
||||
<TextBlock
|
||||
Text="{Binding LoginMessage}"
|
||||
Foreground="Red"
|
||||
TextWrapping="Wrap"
|
||||
Margin="0,0,0,10"
|
||||
Visibility="{Binding LoginMessage, Converter={StaticResource String2VisibilityConverter}}"/>
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
<Button
|
||||
x:Name="LoginButton"
|
||||
Click="Submit_Click"
|
||||
Style="{StaticResource ButtonPrimary}"
|
||||
Height="32"
|
||||
FontSize="{StaticResource FontSize}"
|
||||
HorizontalAlignment="Stretch"
|
||||
IsEnabled="{Binding CanInteractWithLogin}"
|
||||
Margin="0,10,0,8">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<ctls:FontAwesomeIcon Icon="" Spin="True" Margin="0 0 10 0" Visibility="{Binding IsLoading, Converter={StaticResource Boolean2VisibilityConverter}}"/>
|
||||
<TextBlock Text="{Binding LoginButtonText}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<!-- 一键同步 Jeecg 用户到本地库(SCADA 免登录接口) -->
|
||||
<Button
|
||||
Command="{Binding SyncJeecgUsersCommand}"
|
||||
Style="{StaticResource ButtonDefault}"
|
||||
Height="32"
|
||||
FontSize="{StaticResource FontSize}"
|
||||
HorizontalAlignment="Stretch"
|
||||
Margin="0,0,0,20"
|
||||
ToolTip="无需登录,从 Jeecg SCADA 接口拉取用户写入 SQLite(需在配置中启用 Jeecg 且 UserListPath 为 scada/queryUser)">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<ctls:FontAwesomeIcon Icon="" Margin="0 0 8 0" Spin="{Binding IsSyncingJeecgUsers}"/>
|
||||
<TextBlock Text="{Binding SyncJeecgUsersButtonText}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<!-- 后端连接状态指示器 -->
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,8">
|
||||
<Ellipse Width="10" Height="10" Fill="{Binding BackendConnectionStatusBrush}" VerticalAlignment="Center" Margin="0,0,6,0"/>
|
||||
<TextBlock Text="{Binding BackendConnectionStatusText}" Foreground="#666666" FontSize="12" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- 其他链接 -->
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<TextBlock Text="忘记密码?" Foreground="#1890ff" Cursor="Hand" Margin="0,0,20,0"/>
|
||||
<TextBlock Text="注册账号" Foreground="#1890ff" Cursor="Hand"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</hc:Window>
|
||||
124
yy-admin-master/YY.Admin/Views/LoginWindow.xaml.cs
Normal file
124
yy-admin-master/YY.Admin/Views/LoginWindow.xaml.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using Npgsql.Replication.PgOutput.Messages;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using YY.Admin.Core.FluentValidation;
|
||||
using YY.Admin.Services.Service.AutoUpdate;
|
||||
using YY.Admin.ViewModels;
|
||||
using Window = HandyControl.Controls.Window;
|
||||
namespace YY.Admin.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// LoginWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class LoginWindow : Window
|
||||
{
|
||||
private readonly IAutoUpdateService _autoUpdateService;
|
||||
public LoginWindow(IAutoUpdateService autoUpdateService)
|
||||
{
|
||||
InitializeComponent();
|
||||
_autoUpdateService = autoUpdateService;
|
||||
// 窗口加载完成后检查更新
|
||||
Loaded += async (s, e) => await CheckForUpdatesAsync();
|
||||
// 当 DataContext 设置后附加验证
|
||||
DataContextChanged += OnDataContextChanged;
|
||||
}
|
||||
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.NewValue != null)
|
||||
{
|
||||
// 附加验证到 UI 控件
|
||||
FluentValidationHelper.Attach(LoginForm, typeof(LoginWindowViewModel));
|
||||
}
|
||||
}
|
||||
private async Task CheckForUpdatesAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 延迟一点时间,确保UI已经加载完成
|
||||
await Task.Delay(1000);
|
||||
|
||||
var hasUpdate = await _autoUpdateService.CheckForUpdatesAsync();
|
||||
if (hasUpdate)
|
||||
{
|
||||
await ShowUpdateDialogAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 更新检查失败不影响登录
|
||||
System.Diagnostics.Debug.WriteLine($"更新检查异常: {ex.Message}");
|
||||
}
|
||||
}
|
||||
private async Task ShowUpdateDialogAsync()
|
||||
{
|
||||
await Dispatcher.InvokeAsync(async () =>
|
||||
{
|
||||
// 检查窗口是否仍然打开
|
||||
if (!IsLoaded || !IsVisible || Visibility == Visibility.Collapsed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var versionInfo =await _autoUpdateService.GetVersionInfo();
|
||||
if (versionInfo == null) return;
|
||||
|
||||
var currentVersion = _autoUpdateService.GetCurrentVersion();
|
||||
|
||||
var updateWindow = new UpdateWindow
|
||||
{
|
||||
CurrentVersion = currentVersion,
|
||||
LatestVersion = versionInfo.LatestVersion,
|
||||
PublishDate = versionInfo.PublishDate,
|
||||
Changelog = versionInfo.Changelog,
|
||||
DownloadUrl = versionInfo.DownloadUrl,
|
||||
ApplicationName = versionInfo.ApplicationName,
|
||||
IsMandatory = versionInfo.Mandatory,
|
||||
Owner = this
|
||||
};
|
||||
|
||||
updateWindow.UpdateRequested += (downloadUrl) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_autoUpdateService.StartUpdate(downloadUrl);
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"更新启动失败: {ex.Message}", "更新错误",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
};
|
||||
|
||||
updateWindow.ShowDialog();
|
||||
});
|
||||
}
|
||||
private void LoginWindow_Closed(object? sender, EventArgs e)
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
private void Window_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
Submit_Click(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void Submit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var vm = (LoginWindowViewModel)DataContext;
|
||||
vm.LoginMessage = string.Empty;
|
||||
bool valid = FluentValidationHelper.ValidateAll(LoginForm, vm.LoginInput!, vm.LoginInputValidator);
|
||||
if (valid)
|
||||
{
|
||||
if (vm.LoginCommand.CanExecute())
|
||||
{
|
||||
vm.LoginCommand.Execute();
|
||||
}
|
||||
}
|
||||
// 阻止事件继续冒泡
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
597
yy-admin-master/YY.Admin/Views/MainWindow.xaml
Normal file
597
yy-admin-master/YY.Admin/Views/MainWindow.xaml
Normal file
@@ -0,0 +1,597 @@
|
||||
<hc:Window x:Class="YY.Admin.Views.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
||||
xmlns:views="clr-namespace:YY.Admin.Views.Control"
|
||||
xmlns:helper="clr-namespace:YY.Admin.Core.Helper;assembly=YY.Admin.Core"
|
||||
xmlns:beh="clr-namespace:YY.Admin.Core.Behavior;assembly=YY.Admin.Core"
|
||||
xmlns:consts="clr-namespace:YY.Admin.Core.Const;assembly=YY.Admin.Core"
|
||||
xmlns:core="clr-namespace:YY.Admin.Core;assembly=YY.Admin.Core"
|
||||
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:ctls="clr-namespace:YY.Admin.Core.Controls;assembly=YY.Admin.Core"
|
||||
xmlns:converter="clr-namespace:YY.Admin.Core.Converter;assembly=YY.Admin.Core"
|
||||
Icon="/Resources/Icon/logo.ico"
|
||||
Title="{x:Static consts:CommonConst.SystemName}"
|
||||
Width="1200"
|
||||
Height="800"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
WindowState="Maximized"
|
||||
FontSize="{StaticResource FontSize}">
|
||||
|
||||
<Grid>
|
||||
<DockPanel>
|
||||
<!-- 顶部导航栏 -->
|
||||
<Border
|
||||
DockPanel.Dock="Top"
|
||||
Height="60"
|
||||
BorderThickness="0 0 0 1"
|
||||
BorderBrush="{DynamicResource BorderBrush}"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 左侧标题 -->
|
||||
<StackPanel
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Center"
|
||||
Margin="20,0,0,0">
|
||||
<Image
|
||||
Source="/Resources/Icon/logo.png"
|
||||
Width="60"
|
||||
Height="60"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBlock
|
||||
Text="{x:Static consts:CommonConst.SystemName}"
|
||||
FontSize="24"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
Margin="5,0,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- 右侧用户信息 -->
|
||||
<StackPanel
|
||||
Grid.Column="1"
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Center"
|
||||
Margin="20,0">
|
||||
|
||||
<!-- 服务器设置 -->
|
||||
<Button BorderThickness="0" Height="60" Padding="12,0" ToolTip="服务器设置" Command="{Binding OpenServerSettingsCommand}">
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
|
||||
<ctls:FontAwesomeIcon FontSize="16" Icon="" Margin="0,0,0,2"/>
|
||||
<TextBlock Text="服务器设置" FontSize="11" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<!-- 消息通知 -->
|
||||
<hc:Badge
|
||||
Value="100"
|
||||
BadgeMargin="0,4,-10,0"
|
||||
FontSize="12"
|
||||
Style="{StaticResource BadgeDanger}"
|
||||
Margin="10,0">
|
||||
<Button BorderThickness="0" Height="60" Padding="20,0" ToolTip="消息通知">
|
||||
<ctls:FontAwesomeIcon FontSize="20" Icon=""/>
|
||||
</Button>
|
||||
</hc:Badge>
|
||||
|
||||
<!-- 用户信息 -->
|
||||
<StackPanel
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Center"
|
||||
Margin="10,0">
|
||||
<hc:Gravatar Width="40" Height="40" Style="{StaticResource GravatarCircleImg}" Source="/Resources/Icon/avatar.png"/>
|
||||
<StackPanel Margin="8,0,0,0" VerticalAlignment="Center">
|
||||
<TextBlock
|
||||
Text="{Binding CurrentUser.RealName, FallbackValue=管理员}"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
Margin="0,0,0,3"/>
|
||||
<TextBlock
|
||||
Text="{Binding CurrentUser.AccountType, FallbackValue=Administrator}"
|
||||
FontSize="12"
|
||||
Foreground="{DynamicResource SecondaryTextBrush}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 底部版权栏 -->
|
||||
<Border
|
||||
DockPanel.Dock="Bottom"
|
||||
Height="30"
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
BorderThickness="0,1,0,0"
|
||||
BorderBrush="{DynamicResource BorderBrush}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 左侧系统名称 -->
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0">
|
||||
<Ellipse Width="8"
|
||||
Height="8"
|
||||
Fill="{Binding BackendConnectionStatusBrush}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,6,0"/>
|
||||
<TextBlock Text="星数连科技科技有限公司"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="12"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- 右侧版权信息 -->
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
Text="Copyright © 2026 XSL All rights reserved."
|
||||
VerticalAlignment="Center"
|
||||
Margin="10,0"
|
||||
FontSize="12"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- Sidebar侧边栏 -->
|
||||
<views:SidebarControl x:Name="LeftSidebar" DockPanel.Dock="Left" Width="80"/>
|
||||
|
||||
<Grid x:Name="MainContentGrid">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition
|
||||
x:Name="LeftMenuTreeCol"
|
||||
Width="250"
|
||||
MinWidth="50"
|
||||
MaxWidth="{Binding ActualWidth, ElementName=MainContentGrid, Converter={StaticResource MaxWidthConverter}, ConverterParameter=50}"/>
|
||||
<ColumnDefinition Width="4"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Sidebar侧边栏区域 -->
|
||||
<Border
|
||||
x:Name="LeftMenuTree"
|
||||
BorderThickness="0,0,1,0"
|
||||
BorderBrush="{DynamicResource BorderBrush}"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<ContentControl prism:RegionManager.RegionName="{x:Static consts:CommonConst.MenuRegion}"/>
|
||||
</Border>
|
||||
<!-- 拖拽分隔条 -->
|
||||
<GridSplitter
|
||||
Grid.Column="1"
|
||||
x:Name="GridSplitter"
|
||||
Width="4"
|
||||
ResizeBehavior="PreviousAndNext"
|
||||
ShowsPreview="True"
|
||||
Cursor="SizeWE"
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
PreviewStyle="{StaticResource GridSplitterPreviewStyle}"/>
|
||||
<!-- 主内容区域 -->
|
||||
<Border
|
||||
Grid.Column="2"
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
BorderBrush="{DynamicResource BorderBrush}"
|
||||
BorderThickness="1,0,0,0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<hc:TabControl
|
||||
ItemsSource="{Binding OpenTabs}"
|
||||
SelectedItem="{Binding SelectedTab, Mode=TwoWay}"
|
||||
OverflowMenuDisplayMemberPath="Header"
|
||||
IsAnimationEnabled="True"
|
||||
IsDraggable="True"
|
||||
ShowCloseButton="True"
|
||||
TabItemWidth="120"
|
||||
FontSize="12"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
Visibility="{Binding AppSettingsViewModel.IsTabControlVisible, Converter={StaticResource Boolean2VisibilityConverter}}"
|
||||
PreviewMouseRightButtonDown="TabControl_PreviewMouseRightButtonDown">
|
||||
|
||||
<!-- 定义资源 -->
|
||||
<hc:TabControl.Resources>
|
||||
<!-- AntDesign 模板 -->
|
||||
<DataTemplate x:Key="AntDesignIconTemplate">
|
||||
<TextBlock
|
||||
FontFamily="{StaticResource AntDesignIcon}"
|
||||
FontSize="14"
|
||||
Text="{Binding Icon}"
|
||||
Margin="0,0,5,0"
|
||||
VerticalAlignment="Center"/>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- MaterialDesign 模板 -->
|
||||
<DataTemplate x:Key="MaterialDesignIconTemplate">
|
||||
<md:PackIcon
|
||||
Kind="{Binding Icon}"
|
||||
Width="16"
|
||||
Height="16"
|
||||
Margin="0,0,5,0"
|
||||
VerticalAlignment="Center"/>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- FontAwesome 模板 -->
|
||||
<DataTemplate x:Key="FontawesomeIconTemplate">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon="{Binding Icon}"
|
||||
FontSize="14"
|
||||
Margin="0,0,5,0"
|
||||
VerticalAlignment="Center"/>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="CusTabItemPlusBaseStyle" TargetType="hc:TabItem" BasedOn="{StaticResource TabItemPlusBaseStyle}">
|
||||
<Setter Property="BorderThickness" Value="0,0,1,1"/>
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="hc:TabItem">
|
||||
<Grid x:Name="templateRoot" SnapsToDevicePixels="true" ContextMenu="{TemplateBinding Menu}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 外层边框 -->
|
||||
<Border Grid.ColumnSpan="3" BorderThickness="{TemplateBinding BorderThickness}" x:Name="mainBorder" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Margin="0">
|
||||
<Border Margin="0,0,0,-1" x:Name="innerBorder" Background="{DynamicResource RegionBrush}" Visibility="Collapsed" />
|
||||
</Border>
|
||||
|
||||
<!-- 图标 -->
|
||||
<Path x:Name="PathMain" Margin="10,0,0,0" Grid.Column="0" Width="{TemplateBinding hc:IconElement.Width}" Height="{TemplateBinding hc:IconElement.Height}" Fill="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Stretch="Uniform" Data="{TemplateBinding hc:IconElement.Geometry}" />
|
||||
|
||||
<!-- Header 内容 -->
|
||||
<ContentPresenter Grid.Column="1" x:Name="contentPresenter" ContentSource="Header" Focusable="False" HorizontalAlignment="Stretch" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" />
|
||||
|
||||
<!-- 遮罩 -->
|
||||
<Border Name="BorderMask" Grid.Column="1" HorizontalAlignment="Right" Width="20" Background="{TemplateBinding Background}" Margin="0,0,1,1">
|
||||
<Border.OpacityMask>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="White" Offset="1" />
|
||||
<GradientStop Offset="0" />
|
||||
</LinearGradientBrush>
|
||||
</Border.OpacityMask>
|
||||
</Border>
|
||||
|
||||
<!-- 关闭按钮 -->
|
||||
<Button
|
||||
Grid.Column="2"
|
||||
Focusable="False"
|
||||
Command="{Binding CloseTabCommand}"
|
||||
CommandParameter="{Binding}"
|
||||
Background="Transparent"
|
||||
Width="28"
|
||||
Visibility="{Binding IsClosable, Converter={StaticResource Boolean2VisibilityConverter}}"
|
||||
OverridesDefaultStyle="True"
|
||||
Cursor="Hand">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<!-- 使用稍大的容器保证圆形和图标居中 -->
|
||||
<Grid Width="28" Height="28" HorizontalAlignment="Center" VerticalAlignment="Center" Opacity="1">
|
||||
<!-- 圆形 hover 背景(默认透明) -->
|
||||
<Ellipse x:Name="bg"
|
||||
Width="16"
|
||||
Height="16"
|
||||
Fill="Transparent"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
<Path x:Name="icon"
|
||||
Style="{StaticResource ClosePathStyle}"
|
||||
Width="8"
|
||||
Height="8"
|
||||
Fill="{DynamicResource PrimaryTextBrush}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
SnapsToDevicePixels="True"/>
|
||||
</Grid>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<!-- Hover:显示圆形背景并加深图标颜色 -->
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="bg" Property="Fill" Value="#E5E5E5"/>
|
||||
<Setter TargetName="icon" Property="Fill" Value="#333"/>
|
||||
</Trigger>
|
||||
|
||||
<!-- Pressed:背景更深 -->
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="bg" Property="Fill" Value="#CCCCCC"/>
|
||||
</Trigger>
|
||||
|
||||
<!-- Disabled 状态下淡化(可选) -->
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter TargetName="icon" Property="Opacity" Value="0.4"/>
|
||||
<Setter TargetName="bg" Property="Opacity" Value="0.4"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter Property="Panel.ZIndex" Value="1"/>
|
||||
<Setter Property="Visibility" TargetName="innerBorder" Value="Visible"/>
|
||||
<Setter Property="TextElement.Foreground" Value="{DynamicResource PrimaryBrush}" TargetName="contentPresenter"/>
|
||||
<Setter Property="Background" TargetName="BorderMask" Value="{DynamicResource RegionBrush}"/>
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="hc:IconElement.Geometry" Value="{x:Null}">
|
||||
<Setter Property="Visibility" Value="Collapsed" TargetName="PathMain"/>
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Opacity" Value="0.4" TargetName="contentPresenter"/>
|
||||
</Trigger>
|
||||
|
||||
<!-- Hover 效果 -->
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<!--<Setter Property="Background" TargetName="mainBorder" Value="{DynamicResource SecondaryRegionBrush}" />-->
|
||||
<Setter Property="TextElement.Foreground" Value="{DynamicResource PrimaryBrush}" TargetName="contentPresenter"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</hc:TabControl.Resources>
|
||||
|
||||
<hc:TabControl.ItemContainerStyle>
|
||||
<Style TargetType="hc:TabItem" BasedOn="{StaticResource CusTabItemPlusBaseStyle}">
|
||||
<Setter Property="Menu">
|
||||
<Setter.Value>
|
||||
<ContextMenu MinWidth="140" Padding="3,5" Background="{DynamicResource ThirdlyRegionBrush}">
|
||||
<ContextMenu.ItemContainerStyle>
|
||||
<Style TargetType="MenuItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="MenuItem">
|
||||
<Border x:Name="Border" Background="{TemplateBinding Background}" CornerRadius="2" Padding="0,5">
|
||||
<ContentPresenter ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsHighlighted" Value="True">
|
||||
<Setter TargetName="Border" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextIconBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Opacity" Value="0.4"/>
|
||||
<Setter Property="Cursor" Value="No"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ContextMenu.ItemContainerStyle>
|
||||
<MenuItem
|
||||
Header="刷新页面"
|
||||
Command="{Binding PlacementTarget.DataContext.RefreshTabCommand,
|
||||
RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext,
|
||||
RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
|
||||
<MenuItem
|
||||
Header="关闭当前"
|
||||
Command="{Binding PlacementTarget.DataContext.CloseTabCommand,
|
||||
RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext,
|
||||
RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
IsEnabled="{Binding PlacementTarget.DataContext.IsClosable, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
|
||||
<MenuItem
|
||||
Header="关闭左侧"
|
||||
Command="{Binding PlacementTarget.DataContext.CloseLeftTabsCommand,
|
||||
RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext,
|
||||
RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
IsEnabled="{Binding PlacementTarget.DataContext.HasClosableLeft, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
|
||||
<MenuItem
|
||||
Header="关闭右侧"
|
||||
Command="{Binding PlacementTarget.DataContext.CloseRightTabsCommand,
|
||||
RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext,
|
||||
RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
IsEnabled="{Binding PlacementTarget.DataContext.HasClosableRight, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
|
||||
<MenuItem
|
||||
Header="关闭其他"
|
||||
Command="{Binding PlacementTarget.DataContext.CloseOtherTabsCommand,
|
||||
RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext,
|
||||
RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
IsEnabled="{Binding PlacementTarget.DataContext.HasClosableOther, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
|
||||
<MenuItem
|
||||
Header="关闭全部"
|
||||
Command="{Binding PlacementTarget.DataContext.CloseAllTabsCommand,
|
||||
RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext,
|
||||
RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
IsEnabled="{Binding PlacementTarget.DataContext.HasClosableAny, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
|
||||
</ContextMenu>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</hc:TabControl.ItemContainerStyle>
|
||||
|
||||
<hc:TabControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
|
||||
<!-- ContentControl:动态选择图标模板 -->
|
||||
<ContentControl>
|
||||
<ContentControl.Style>
|
||||
<Style TargetType="ContentControl">
|
||||
<!-- 默认模板(AntDesign) -->
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource AntDesignIconTemplate}" />
|
||||
<!-- 绑定数据上下文 -->
|
||||
<Setter Property="Content" Value="{Binding}" />
|
||||
|
||||
<!-- 触发器根据 IconType 切换模板 -->
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IconType}" Value="{x:Static core:IconTypeEnum.MaterialDesign}">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource MaterialDesignIconTemplate}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IconType}" Value="{x:Static core:IconTypeEnum.FontAwesome}">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource FontawesomeIconTemplate}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
|
||||
<!-- 文本标题 -->
|
||||
<TextBlock Text="{Binding Header}" VerticalAlignment="Center"/>
|
||||
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</hc:TabControl.ItemTemplate>
|
||||
|
||||
<!-- 内容模板设为空(因为内容在外部显示),不能省略,不然会显示SelectedTab类型的全路径名称 -->
|
||||
<hc:TabControl.ContentTemplate>
|
||||
<DataTemplate/>
|
||||
</hc:TabControl.ContentTemplate>
|
||||
</hc:TabControl>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<hc:TransitioningContentControl Grid.Row="1" prism:RegionManager.RegionName="{x:Static consts:CommonConst.ContentRegion}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
|
||||
<hc:Drawer
|
||||
IsOpen="{Binding IsAppSettingsOpen}"
|
||||
Dock="Left"
|
||||
ShowMask="True">
|
||||
<Border
|
||||
Background="{DynamicResource ThirdlyRegionBrush}"
|
||||
Effect="{StaticResource EffectShadow1}"
|
||||
Width="220">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<!-- 内容区域 -->
|
||||
<RowDefinition Height="*"/>
|
||||
<!-- 按钮区域 -->
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 可滚动的内容区域 -->
|
||||
<hc:ScrollViewer
|
||||
x:Name="ContentScrollViewer"
|
||||
IsInertiaEnabled="True"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Grid.Row="0">
|
||||
<StackPanel Margin="20" x:Name="ContentPanel">
|
||||
<TextBlock HorizontalAlignment="Left" Text="主题设置" FontSize="16" Style="{StaticResource TextBlockTitle}"/>
|
||||
<Border BorderThickness="0,0,0,1" BorderBrush="{DynamicResource ThirdlyBorderBrush}" Margin="0,10,0,20"/>
|
||||
|
||||
<DockPanel LastChildFill="False" Margin="0,0,0,20">
|
||||
<TextBlock Text="与系统同步" DockPanel.Dock="Left"/>
|
||||
<ToggleButton
|
||||
IsChecked="{Binding AppSettingsViewModel.SyncWithSystem}"
|
||||
Style="{StaticResource ToggleButtonSwitch}"
|
||||
hc:VisualElement.HighlightBrush="{DynamicResource PrimaryBrush}"
|
||||
DockPanel.Dock="Right"/>
|
||||
</DockPanel>
|
||||
<WrapPanel
|
||||
Orientation="Horizontal"
|
||||
Button.Click="OnSkinTypeChanged"
|
||||
IsEnabled="{Binding AppSettingsViewModel.IsNotSyncWithSystem}">
|
||||
<Button Tag="{x:Static hc:SkinType.Default}" Style="{StaticResource ButtonCustom}" Margin="0,0,8,8" ToolTip="默认主题">
|
||||
<Grid>
|
||||
<Border Background="White" Width="48" Height="48" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/>
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
IconFamily="Solid"
|
||||
FontSize="16"
|
||||
Foreground="{DynamicResource SuccessBrush}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Visibility="{Binding AppSettingsViewModel.SkinType, Converter={StaticResource EnumToVisibilityConverter}, ConverterParameter={x:Static hc:SkinType.Default}}"/>
|
||||
</Grid>
|
||||
</Button>
|
||||
<Button Tag="{x:Static hc:SkinType.Dark}" Style="{StaticResource ButtonCustom}" Margin="0,0,8,8" ToolTip="暗黑主题">
|
||||
<Grid>
|
||||
<Border Background="Black" Width="48" Height="48" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/>
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
IconFamily="Solid"
|
||||
FontSize="16"
|
||||
Foreground="{DynamicResource SuccessBrush}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Visibility="{Binding AppSettingsViewModel.SkinType, Converter={StaticResource EnumToVisibilityConverter}, ConverterParameter={x:Static hc:SkinType.Dark}}"/>
|
||||
</Grid>
|
||||
</Button>
|
||||
<Button Tag="{x:Static hc:SkinType.Violet}" Style="{StaticResource ButtonCustom}" Margin="0,0,8,8" ToolTip="紫色主题">
|
||||
<Grid>
|
||||
<Border Background="DarkViolet" Width="48" Height="48" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/>
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
IconFamily="Solid"
|
||||
FontSize="16"
|
||||
Foreground="{DynamicResource SuccessBrush}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Visibility="{Binding AppSettingsViewModel.SkinType, Converter={StaticResource EnumToVisibilityConverter}, ConverterParameter={x:Static hc:SkinType.Violet}}"/>
|
||||
</Grid>
|
||||
</Button>
|
||||
</WrapPanel>
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" Text="布局设置" FontSize="16" Margin="0,40,0,0" Style="{StaticResource TextBlockTitle}"/>
|
||||
<Border BorderThickness="0,0,0,1" BorderBrush="{DynamicResource ThirdlyBorderBrush}" Margin="0,10,0,20"/>
|
||||
<DockPanel LastChildFill="False">
|
||||
<TextBlock Text="显示选项卡" DockPanel.Dock="Left"/>
|
||||
<ToggleButton
|
||||
IsChecked="{Binding AppSettingsViewModel.IsTabControlVisible}"
|
||||
Style="{StaticResource ToggleButtonSwitch}"
|
||||
hc:VisualElement.HighlightBrush="{DynamicResource PrimaryBrush}"
|
||||
DockPanel.Dock="Right"/>
|
||||
</DockPanel>
|
||||
|
||||
<!-- 无滚动条时,按钮放在内容内部 -->
|
||||
<Button
|
||||
x:Name="InnerButton"
|
||||
Grid.Row="1"
|
||||
Style="{StaticResource ButtonPrimary}"
|
||||
Command="{Binding ResetAppSettingsCommand}"
|
||||
HorizontalAlignment="Stretch"
|
||||
Margin="0,40,0,0"
|
||||
Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<md:PackIcon Kind="Refresh" Width="18" Height="18" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="重置" FontSize="14" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</hc:ScrollViewer>
|
||||
|
||||
<!-- 有滚动条时,按钮固定在底部 -->
|
||||
<Button
|
||||
x:Name="FixedButton"
|
||||
Grid.Row="1"
|
||||
Style="{StaticResource ButtonPrimary}"
|
||||
Command="{Binding ResetAppSettingsCommand}"
|
||||
HorizontalAlignment="Stretch"
|
||||
Margin="20"
|
||||
Visibility="Visible">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<md:PackIcon Kind="Refresh" Width="18" Height="18" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="重置" FontSize="14" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
</hc:Drawer>
|
||||
</Grid>
|
||||
</hc:Window>
|
||||
108
yy-admin-master/YY.Admin/Views/MainWindow.xaml.cs
Normal file
108
yy-admin-master/YY.Admin/Views/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using HandyControl.Data;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using YY.Admin.ViewModels;
|
||||
using Window = HandyControl.Controls.Window;
|
||||
|
||||
namespace YY.Admin.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
//this.Closed += MainWindow_Closed;
|
||||
ContentScrollViewer.SizeChanged += OnScrollViewerSizeChanged;
|
||||
}
|
||||
|
||||
private void MainWindow_Closed(object? sender, EventArgs e)
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
private void UserMenuButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button button && button.ContextMenu != null)
|
||||
{
|
||||
button.ContextMenu.PlacementTarget = button;
|
||||
button.ContextMenu.IsOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void Splitter_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
|
||||
{
|
||||
double newWidth = LeftMenuTree.Width + e.HorizontalChange;
|
||||
|
||||
// 获取主窗口宽度
|
||||
double windowWidth = this.ActualWidth;
|
||||
|
||||
// 最小宽度
|
||||
double minWidth = 50;
|
||||
|
||||
// 最大宽度
|
||||
double maxWidth = windowWidth - LeftSidebar.Width - GridSplitter.Width - minWidth;
|
||||
|
||||
if (newWidth < minWidth)
|
||||
newWidth = minWidth;
|
||||
else if (newWidth > maxWidth)
|
||||
newWidth = maxWidth;
|
||||
|
||||
LeftMenuTree.Width = newWidth;
|
||||
}
|
||||
|
||||
private void TabControl_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
// 查找点击点是否在 TabItem Header 上
|
||||
var dep = e.OriginalSource as DependencyObject;
|
||||
|
||||
while (dep != null && dep is not TabItem)
|
||||
{
|
||||
dep = VisualTreeHelper.GetParent(dep);
|
||||
}
|
||||
|
||||
// 如果右键点在 TabItem 上
|
||||
if (dep is TabItem)
|
||||
{
|
||||
// 阻止 TabControl 切换 SelectedItem
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnScrollViewerSizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
// 检查是否需要显示滚动条
|
||||
//bool needsScroll = ContentPanel.ActualHeight > ContentScrollViewer.ActualHeight;
|
||||
|
||||
//bool needsScroll = ContentScrollViewer.ScrollableHeight > 0;
|
||||
|
||||
bool needsScroll = ContentScrollViewer.ComputedVerticalScrollBarVisibility == Visibility.Visible;
|
||||
|
||||
if (needsScroll)
|
||||
{
|
||||
// 有滚动条:显示固定按钮,隐藏内部按钮
|
||||
FixedButton.Visibility = Visibility.Visible;
|
||||
InnerButton.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 无滚动条:隐藏固定按钮,显示内部按钮
|
||||
FixedButton.Visibility = Visibility.Collapsed;
|
||||
InnerButton.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSkinTypeChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (e.OriginalSource is Button { Tag: SkinType skinType })
|
||||
{
|
||||
var vm = DataContext as MainWindowViewModel;
|
||||
vm?.AppSettingsViewModel?.SkinType = skinType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
yy-admin-master/YY.Admin/Views/NotFoundView.xaml
Normal file
25
yy-admin-master/YY.Admin/Views/NotFoundView.xaml
Normal file
@@ -0,0 +1,25 @@
|
||||
<UserControl x:Class="YY.Admin.Views.NotFoundView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol">
|
||||
<Grid>
|
||||
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<Image
|
||||
Source="/Resources/Icon/404.png"
|
||||
Width="200"
|
||||
Height="200"/>
|
||||
<TextBlock Text="404 - 页面未找到"
|
||||
FontSize="22"
|
||||
FontWeight="Bold"
|
||||
HorizontalAlignment="Center"/>
|
||||
<TextBlock Text="抱歉,您访问的页面不存在"
|
||||
FontSize="16"
|
||||
Margin="0,10,0,20"
|
||||
HorizontalAlignment="Center"/>
|
||||
<!--<Button Content="返回首页"
|
||||
Command="{Binding GoHomeCommand}"
|
||||
Style="{StaticResource ButtonPrimary}"
|
||||
Width="120"/>-->
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
yy-admin-master/YY.Admin/Views/NotFoundView.xaml.cs
Normal file
28
yy-admin-master/YY.Admin/Views/NotFoundView.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace YY.Admin.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// NotFoundView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class NotFoundView : UserControl
|
||||
{
|
||||
public NotFoundView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<UserControl x:Class="YY.Admin.Views.SysManage.DataDictionaryManagementView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:core="clr-namespace:YY.Admin.Core;assembly=YY.Admin.Core"
|
||||
xmlns:components="clr-namespace:YY.Admin.Views.Control"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Style="{StaticResource BaseViewStyle}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border Grid.Row="0" CornerRadius="4" Margin="0 0 -10 0">
|
||||
<hc:Row>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:TextBox
|
||||
Text="{Binding Input.DictCode, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.Placeholder="请输入字典编码"
|
||||
hc:InfoElement.Title="字典编码"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:TextBox
|
||||
Text="{Binding Input.DictName, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.Placeholder="请输入字典名称"
|
||||
hc:InfoElement.Title="字典名称"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:TextBox
|
||||
Text="{Binding Input.ItemText, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.Placeholder="请输入字典项文本"
|
||||
hc:InfoElement.Title="字典项文本"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:TextBox
|
||||
Text="{Binding Input.ItemValue, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.Placeholder="请输入字典项值"
|
||||
hc:InfoElement.Title="字典项值"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:ComboBox
|
||||
SelectedValue="{Binding Input.Status, Converter={StaticResource EnumToIntConverter}, ConverterParameter={x:Type core:StatusEnum}}"
|
||||
ItemsSource="{Binding StatusList}"
|
||||
DisplayMemberPath="Key"
|
||||
SelectedValuePath="Value"
|
||||
hc:InfoElement.Placeholder="请选择状态"
|
||||
hc:InfoElement.Title="状态"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
</hc:Row>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="1" Margin="0,10">
|
||||
<hc:UniformSpacingPanel Spacing="10">
|
||||
<Button Style="{StaticResource ButtonPrimary}" Command="{Binding SearchCommand}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="Search"/>
|
||||
<TextBlock Text="搜索" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Style="{StaticResource ButtonDefault}" Command="{Binding ResetCommand}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="Refresh"/>
|
||||
<TextBlock Text="重置" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Style="{StaticResource ButtonSuccess}" Command="{Binding SyncCommand}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="CloudSyncOutline"/>
|
||||
<TextBlock Text="同步数据字典" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</hc:UniformSpacingPanel>
|
||||
</Border>
|
||||
|
||||
<DataGrid
|
||||
Grid.Row="2"
|
||||
AutoGenerateColumns="False"
|
||||
HeadersVisibility="All"
|
||||
ItemsSource="{Binding PaginationDataGridViewModel.Data}"
|
||||
ColumnHeaderStyle="{StaticResource CusDataGridColumnHeaderStyle}"
|
||||
Style="{StaticResource CusDataGridStyle}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding DictCode}" Header="字典编码" Width="150" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding DictName}" Header="字典名称" Width="170" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding ItemText}" Header="字典项文本" Width="170" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding ItemValue}" Header="字典项值" Width="140" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding ItemDescription}" Header="描述" Width="220" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding SortOrder}" Header="排序" Width="80" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Status, Converter={StaticResource EnumDescriptionConverter}}" Header="状态" Width="80" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding CreateTime, StringFormat='yyyy-MM-dd HH:mm:ss'}" Header="创建时间" Width="170" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding UpdateTime, StringFormat='yyyy-MM-dd HH:mm:ss'}" Header="更新时间" Width="170" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<components:PaginationDataGridControl Grid.Row="3" DataContext="{Binding PaginationDataGridViewModel}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace YY.Admin.Views.SysManage
|
||||
{
|
||||
/// <summary>
|
||||
/// DataDictionaryManagementView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DataDictionaryManagementView : UserControl
|
||||
{
|
||||
public DataDictionaryManagementView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="YY.Admin.Views.SysManage.RoleManagementView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:YY.Admin.Views.SysManage"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid Style="{StaticResource BaseViewStyle}">
|
||||
<Button Content="AlertDialogView" x:Name="AlertDialogView" Command="{Binding AlertDialogCommand}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace YY.Admin.Views.SysManage
|
||||
{
|
||||
/// <summary>
|
||||
/// RoleManagementView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class RoleManagementView : UserControl
|
||||
{
|
||||
|
||||
public RoleManagementView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<UserControl x:Class="YY.Admin.Views.SysManage.TenantManagementView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:core="clr-namespace:YY.Admin.Core;assembly=YY.Admin.Core"
|
||||
xmlns:components="clr-namespace:YY.Admin.Views.Control"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Style="{StaticResource BaseViewStyle}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border Grid.Row="0" CornerRadius="4" Margin="0 0 -10 0">
|
||||
<hc:Row>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:TextBox
|
||||
Text="{Binding Input.Name, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.Placeholder="请输入租户名称"
|
||||
hc:InfoElement.Title="租户名称"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:ComboBox
|
||||
SelectedValue="{Binding Input.Status, Converter={StaticResource EnumToIntConverter}, ConverterParameter={x:Type core:StatusEnum}}"
|
||||
ItemsSource="{Binding StatusList}"
|
||||
DisplayMemberPath="Key"
|
||||
SelectedValuePath="Value"
|
||||
hc:InfoElement.Placeholder="请选择状态"
|
||||
hc:InfoElement.Title="状态"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
</hc:Row>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="1" Margin="0,10">
|
||||
<hc:UniformSpacingPanel Spacing="10">
|
||||
<Button Style="{StaticResource ButtonPrimary}" Command="{Binding SearchCommand}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="Search"/>
|
||||
<TextBlock Text="搜索" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Style="{StaticResource ButtonDefault}" Command="{Binding ResetCommand}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="Refresh"/>
|
||||
<TextBlock Text="重置" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Style="{StaticResource ButtonSuccess}" Command="{Binding SyncCommand}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="CloudSyncOutline"/>
|
||||
<TextBlock Text="从Jeecg同步" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</hc:UniformSpacingPanel>
|
||||
</Border>
|
||||
|
||||
<DataGrid
|
||||
Grid.Row="2"
|
||||
AutoGenerateColumns="False"
|
||||
HeadersVisibility="All"
|
||||
ItemsSource="{Binding PaginationDataGridViewModel.Data}"
|
||||
ColumnHeaderStyle="{StaticResource CusDataGridColumnHeaderStyle}"
|
||||
Style="{StaticResource CusDataGridStyle}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Id}" Header="租户ID" Width="130" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Title}" Header="租户名称" Width="220" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Status, Converter={StaticResource EnumDescriptionConverter}}" Header="状态" Width="100" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Logo}" Header="Logo" Width="280" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding CreateTime, StringFormat='yyyy-MM-dd HH:mm:ss'}" Header="创建时间" Width="180" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding UpdateTime, StringFormat='yyyy-MM-dd HH:mm:ss'}" Header="更新时间" Width="180" CellStyle="{StaticResource CusDataGridCellStyle}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<components:PaginationDataGridControl Grid.Row="3" DataContext="{Binding PaginationDataGridViewModel}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace YY.Admin.Views.SysManage
|
||||
{
|
||||
/// <summary>
|
||||
/// TenantManagementView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class TenantManagementView : UserControl
|
||||
{
|
||||
public TenantManagementView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
185
yy-admin-master/YY.Admin/Views/SysManage/UserEditDialogView.xaml
Normal file
185
yy-admin-master/YY.Admin/Views/SysManage/UserEditDialogView.xaml
Normal file
@@ -0,0 +1,185 @@
|
||||
<UserControl x:Class="YY.Admin.Views.SysManage.UserEditDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:local="clr-namespace:YY.Admin.Views.SysManage"
|
||||
xmlns:core="clr-namespace:YY.Admin.Core;assembly=YY.Admin.Core"
|
||||
xmlns:corefv="clr-namespace:YY.Admin.Core.FluentValidation;assembly=YY.Admin.Core"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
mc:Ignorable="d"
|
||||
Width="650"
|
||||
MinHeight="300">
|
||||
|
||||
<Grid Background="{DynamicResource ThirdlyRegionBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<hc:SimplePanel Margin="20">
|
||||
<TextBlock FontSize="18" Foreground="{DynamicResource PrimaryTextBrush}" Text="{Binding DialogTitle}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||
<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource PrimaryBrush}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,4,0"/>
|
||||
</hc:SimplePanel>
|
||||
|
||||
<hc:ScrollViewer Grid.Row="1" IsInertiaEnabled="True">
|
||||
<StackPanel x:Name="RootPanel" Margin="20 0 20 0">
|
||||
<hc:Row Gutter="10">
|
||||
<hc:Col Span="12" Visibility="{Binding IsAddMode, Converter={StaticResource Boolean2VisibilityConverter}}">
|
||||
<hc:TextBox
|
||||
Text="{Binding SysUser.Account, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
Margin="0,0,0,20"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.Placeholder="请输入账号"
|
||||
hc:InfoElement.Title="账号"
|
||||
hc:InfoElement.Necessary="True"
|
||||
hc:InfoElement.Symbol="*"
|
||||
hc:IsEnabled="{Binding IsAddMode}"/>
|
||||
</hc:Col>
|
||||
<hc:Col Span="12" Visibility="{Binding IsAddMode, Converter={StaticResource Boolean2VisibilityConverter}}">
|
||||
<hc:PasswordBox
|
||||
UnsafePassword="{Binding SysUser.Password, UpdateSourceTrigger=PropertyChanged}"
|
||||
IsSafeEnabled="False"
|
||||
Margin="0,0,0,20"
|
||||
ShowEyeButton="True"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
hc:InfoElement.Necessary="True"
|
||||
hc:InfoElement.Symbol="*"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.Placeholder="请输入密码"
|
||||
hc:InfoElement.Title="密码"
|
||||
hc:IsEnabled="{Binding IsAddMode}"/>
|
||||
</hc:Col>
|
||||
<hc:Col Span="12">
|
||||
<hc:TextBox
|
||||
Text="{Binding SysUser.RealName, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
Margin="0,0,0,20"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
Validation.ErrorTemplate="{StaticResource BottomLeftErrorTemplate_ForInfoElement}"
|
||||
hc:InfoElement.Necessary="True"
|
||||
hc:InfoElement.Symbol="*"
|
||||
corefv:FluentValidationHelper.SkipValidation="False"
|
||||
hc:InfoElement.Placeholder="请输入姓名"
|
||||
hc:InfoElement.Title="姓名"/>
|
||||
</hc:Col>
|
||||
<hc:Col Span="12">
|
||||
<hc:TextBox
|
||||
Text="{Binding SysUser.NickName, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
Margin="0,0,0,20"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.Placeholder="请输入昵称"
|
||||
hc:InfoElement.Title="昵称"/>
|
||||
</hc:Col>
|
||||
<hc:Col Span="12">
|
||||
<hc:ComboBox
|
||||
SelectedItem="{Binding SysUser.Sex}"
|
||||
Margin="0 0 0 20"
|
||||
ItemsSource="{Binding GenderList}"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
hc:InfoElement.Necessary="True"
|
||||
hc:InfoElement.Symbol="*"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.Placeholder="请选择性别"
|
||||
hc:InfoElement.Title="性别">
|
||||
<hc:ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}"/>
|
||||
</DataTemplate>
|
||||
</hc:ComboBox.ItemTemplate>
|
||||
</hc:ComboBox>
|
||||
</hc:Col>
|
||||
<hc:Col Span="12">
|
||||
<hc:DatePicker
|
||||
SelectedDate="{Binding SysUser.Birthday}"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.Placeholder="请选择出生日期"
|
||||
hc:InfoElement.Title="出生日期"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 0 20"/>
|
||||
</hc:Col>
|
||||
<hc:Col Span="12">
|
||||
<hc:NumericUpDown
|
||||
Value="{Binding SysUser.Age}"
|
||||
Minimum="0"
|
||||
Maximum="150"
|
||||
Style="{StaticResource NumericUpDownPlus}"
|
||||
hc:InfoElement.TitleWidth="70"
|
||||
hc:InfoElement.Necessary="True"
|
||||
hc:InfoElement.Symbol="*"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.Placeholder="请输入年龄"
|
||||
hc:InfoElement.Title="年龄"
|
||||
Margin="0 0 0 20"/>
|
||||
</hc:Col>
|
||||
<hc:Col Span="12">
|
||||
<Grid Margin="0,0,0,20">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="70" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<TextBlock Text="状态" VerticalAlignment="Center" />
|
||||
<!--<TextBlock Text="*" Foreground="Red" Margin="6,0,0,0" VerticalAlignment="Center"/>-->
|
||||
</StackPanel>
|
||||
<ItemsControl Grid.Column="1" ItemsSource="{Binding StatusOptions}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<RadioButton
|
||||
Margin="0,0,15,0"
|
||||
GroupName="StatusGroup"
|
||||
Tag="{Binding}"
|
||||
Content="{Binding Converter={StaticResource EnumDescriptionConverter}}"
|
||||
Command="{Binding DataContext.StatusSelectedCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
CommandParameter="{Binding}">
|
||||
<RadioButton.IsChecked>
|
||||
<MultiBinding Converter="{StaticResource RadioButtonEnumMultiConverter}">
|
||||
<!-- 当前选项 -->
|
||||
<Binding Path="Tag" RelativeSource="{RelativeSource Self}"/>
|
||||
<!-- SysUser.Status -->
|
||||
<Binding Path="DataContext.SysUser.Status" RelativeSource="{RelativeSource AncestorType=UserControl}"/>
|
||||
</MultiBinding>
|
||||
</RadioButton.IsChecked>
|
||||
</RadioButton>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</hc:Col>
|
||||
</hc:Row>
|
||||
</StackPanel>
|
||||
</hc:ScrollViewer>
|
||||
|
||||
<!-- 按钮区域 -->
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="20">
|
||||
<Button Content="取消"
|
||||
Command="{Binding CancelCommand}"
|
||||
Style="{StaticResource ButtonDefault}"
|
||||
Margin="0,0,15,0"
|
||||
Width="100"/>
|
||||
|
||||
<Button Content="确定"
|
||||
Click="Submit_Click"
|
||||
Style="{StaticResource ButtonPrimary}"
|
||||
Width="100"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using YY.Admin.Core.FluentValidation;
|
||||
using YY.Admin.ViewModels.SysManage;
|
||||
|
||||
namespace YY.Admin.Views.SysManage
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for UserEditDialog.xaml
|
||||
/// </summary>
|
||||
public partial class UserEditDialogView : UserControl
|
||||
{
|
||||
public UserEditDialogView()
|
||||
{
|
||||
InitializeComponent();
|
||||
FluentValidationHelper.Attach(RootPanel, typeof(UserEditDialogViewModel));
|
||||
}
|
||||
|
||||
private void Submit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var vm = (UserEditDialogViewModel)DataContext;
|
||||
bool valid = FluentValidationHelper.ValidateAll(RootPanel, vm.SysUser!, vm.SysUserValidator);
|
||||
if (valid)
|
||||
{
|
||||
_ = vm.SaveUserAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
258
yy-admin-master/YY.Admin/Views/SysManage/UserManagementView.xaml
Normal file
258
yy-admin-master/YY.Admin/Views/SysManage/UserManagementView.xaml
Normal file
@@ -0,0 +1,258 @@
|
||||
<UserControl x:Class="YY.Admin.Views.SysManage.UserManagementView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:local="clr-namespace:YY.Admin.Views.SysManage"
|
||||
xmlns:core="clr-namespace:YY.Admin.Core;assembly=YY.Admin.Core"
|
||||
xmlns:components="clr-namespace:YY.Admin.Views.Control"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Style="{StaticResource BaseViewStyle}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 搜索条件区域 -->
|
||||
<Border Grid.Row="0" CornerRadius="4" Margin="0 0 -10 0">
|
||||
<hc:Row>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:TextBox
|
||||
Text="{Binding UserInput.Account, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.Placeholder="请输入账号"
|
||||
hc:InfoElement.Title="账号"
|
||||
hc:InfoElement.TitleWidth="65"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:TextBox
|
||||
Text="{Binding UserInput.RealName, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.Placeholder="请输入姓名"
|
||||
hc:InfoElement.Title="姓名"
|
||||
hc:InfoElement.TitleWidth="65"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:TextBox
|
||||
Text="{Binding UserInput.NickName, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.Placeholder="请输入昵称"
|
||||
hc:InfoElement.Title="昵称"
|
||||
hc:InfoElement.TitleWidth="65"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:ComboBox
|
||||
SelectedValue="{Binding UserInput.Sex}"
|
||||
ItemsSource="{Binding GenderList}"
|
||||
hc:InfoElement.Placeholder="请选择性别"
|
||||
hc:InfoElement.Title="性别"
|
||||
hc:InfoElement.TitleWidth="65"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10">
|
||||
<hc:ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
||||
</DataTemplate>
|
||||
</hc:ComboBox.ItemTemplate>
|
||||
</hc:ComboBox>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:TextBox
|
||||
Text="{Binding UserInput.Phone, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.Placeholder="请输入手机号码"
|
||||
hc:InfoElement.Title="手机号码"
|
||||
hc:InfoElement.TitleWidth="65"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:ComboBox
|
||||
SelectedValue="{Binding UserInput.Status, Converter={StaticResource EnumToIntConverter}, ConverterParameter={x:Type core:StatusEnum}}"
|
||||
ItemsSource="{Binding StatusList}"
|
||||
DisplayMemberPath="Key"
|
||||
SelectedValuePath="Value"
|
||||
hc:InfoElement.Placeholder="请选择状态"
|
||||
hc:InfoElement.Title="状态"
|
||||
hc:InfoElement.TitleWidth="65"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:DateTimePicker
|
||||
x:Name="BeginTimePicker"
|
||||
Style="{StaticResource DateTimePickerPlus}"
|
||||
SelectedDateTime="{Binding UserInput.BeginTime}"
|
||||
DateTimeFormat="yyyy-MM-dd HH:mm:ss"
|
||||
hc:InfoElement.Title="创建时间"
|
||||
hc:InfoElement.Placeholder="开始时间"
|
||||
hc:InfoElement.TitleWidth="65"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:DateTimePicker
|
||||
x:Name="EndTimePicker"
|
||||
Style="{StaticResource DateTimePickerPlus}"
|
||||
SelectedDateTime="{Binding UserInput.EndTime}"
|
||||
DateTimeFormat="yyyy-MM-dd HH:mm:ss"
|
||||
hc:InfoElement.Title="至"
|
||||
hc:InfoElement.Placeholder="结束时间"
|
||||
hc:InfoElement.TitleWidth="65"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.ShowClearButton="True"
|
||||
Margin="0 0 10 10"/>
|
||||
</hc:Col>
|
||||
</hc:Row>
|
||||
</Border>
|
||||
|
||||
<!-- 批量操作工具栏 -->
|
||||
<Border Grid.Row="1" Margin="0,10">
|
||||
<hc:UniformSpacingPanel Spacing="10">
|
||||
<!-- 搜索按钮 -->
|
||||
<Button
|
||||
Style="{StaticResource ButtonPrimary}"
|
||||
Command="{Binding SearchCommand}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="Search"/>
|
||||
<TextBlock Text="搜索" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<!-- 重置按钮 -->
|
||||
<Button
|
||||
Style="{StaticResource ButtonDefault}"
|
||||
Click="ResetButton_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="Refresh"/>
|
||||
<TextBlock Text="重置" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
Command="{Binding AddCommand}"
|
||||
Style="{StaticResource ButtonSuccess}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="Plus"/>
|
||||
<TextBlock Text="新增" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button
|
||||
Style="{StaticResource ButtonDanger}"
|
||||
IsEnabled="{Binding HasSelectedItems}"
|
||||
Command="{Binding BatchDeleteCommand}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="TrashCanOutline"/>
|
||||
<TextBlock Text="删除" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</hc:UniformSpacingPanel>
|
||||
</Border>
|
||||
|
||||
<DataGrid
|
||||
Grid.Row="2"
|
||||
RowHeaderWidth="55"
|
||||
AutoGenerateColumns="False"
|
||||
HeadersVisibility="All"
|
||||
SelectionMode="Extended"
|
||||
SelectionUnit="FullRow"
|
||||
ItemsSource="{Binding PaginationDataGridViewModel.Data}"
|
||||
ColumnHeaderStyle="{StaticResource CusDataGridColumnHeaderStyle}"
|
||||
Style="{StaticResource CusDataGridStyle}"
|
||||
hc:DataGridAttach.ShowSelectAllButton="True"
|
||||
SelectionChanged="DataGrid_SelectionChanged">
|
||||
|
||||
<!-- 同步行选择和数据选择 -->
|
||||
<DataGrid.ItemContainerStyle>
|
||||
<Style TargetType="DataGridRow">
|
||||
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</DataGrid.ItemContainerStyle>
|
||||
|
||||
<DataGrid.RowHeaderTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox IsChecked="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow}}"/>
|
||||
</DataTemplate>
|
||||
</DataGrid.RowHeaderTemplate>
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Account}" Header="账号" CellStyle="{StaticResource CusDataGridCellStyle}" Width="100"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding RealName}" Header="姓名" CellStyle="{StaticResource CusDataGridCellStyle}" Width="100"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding NickName}" Header="昵称" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Phone}" Header="手机号码" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Birthday, StringFormat='yyyy-MM-dd'}" Header="出生日期" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Sex, Converter={StaticResource EnumDescriptionConverter}}" Header="性别" CellStyle="{StaticResource CusDataGridCellStyle}" Width="100"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding AccountType, Converter={StaticResource EnumDescriptionConverter}}" Header="用户类型" CellStyle="{StaticResource CusDataGridCellStyle}" Width="100"/>
|
||||
<DataGridTemplateColumn Header="状态" Width="80" CellStyle="{StaticResource CusDataGridCellStyle}">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ToggleButton
|
||||
Command="{Binding DataContext.StatusToggleCommand,
|
||||
RelativeSource={RelativeSource AncestorType=DataGrid}}"
|
||||
CommandParameter="{Binding}"
|
||||
IsChecked="{Binding Status, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter=Enable}"
|
||||
Cursor="Hand"
|
||||
Style="{StaticResource ToggleButtonSwitch}"
|
||||
hc:VisualElement.HighlightBrush="{DynamicResource PrimaryBrush}"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn IsReadOnly="True" Binding="{Binding CreateTime, StringFormat='yyyy-MM-dd HH:mm:ss'}" Header="创建时间" CellStyle="{StaticResource CusDataGridCellStyle}" Width="180"/>
|
||||
<!-- 操作列 -->
|
||||
<DataGridTemplateColumn Header="操作" Width="150" CellStyle="{StaticResource CusOperDataGridCellStyle}">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<hc:UniformSpacingPanel Spacing="5">
|
||||
<!-- 修改 -->
|
||||
<Border Style="{DynamicResource DataGridOpeButtonStyle}">
|
||||
<Border.InputBindings>
|
||||
<MouseBinding
|
||||
Command="{Binding DataContext.EditCommand,
|
||||
RelativeSource={RelativeSource AncestorType=DataGrid}}"
|
||||
CommandParameter="{Binding}"
|
||||
MouseAction="LeftClick"/>
|
||||
</Border.InputBindings>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="SquareEditOutline" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="修改" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 删除 -->
|
||||
<Border Style="{DynamicResource DataGridOpeButtonStyle}">
|
||||
<Border.InputBindings>
|
||||
<MouseBinding
|
||||
Command="{Binding DataContext.DeleteCommand,
|
||||
RelativeSource={RelativeSource AncestorType=DataGrid}}"
|
||||
CommandParameter="{Binding Id}"
|
||||
MouseAction="LeftClick"/>
|
||||
</Border.InputBindings>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="TrashCanOutline" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="删除" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</hc:UniformSpacingPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<components:PaginationDataGridControl Grid.Row="3" DataContext="{Binding PaginationDataGridViewModel}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,87 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using YY.Admin.Services.Service;
|
||||
using YY.Admin.ViewModels.SysManage;
|
||||
|
||||
namespace YY.Admin.Views.SysManage
|
||||
{
|
||||
/// <summary>
|
||||
/// UserManagementView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class UserManagementView : UserControl
|
||||
{
|
||||
public UserManagementView()
|
||||
{
|
||||
InitializeComponent();
|
||||
//this.Loaded += UserManagementView_Loaded;
|
||||
}
|
||||
|
||||
//private void UserManagementView_Loaded(object sender, RoutedEventArgs e)
|
||||
//{
|
||||
// if (DataContext is UserManagementViewModel viewModel)
|
||||
// {
|
||||
// Task.Run(viewModel.PaginationDataGridViewModel.LoadData);
|
||||
// }
|
||||
|
||||
// // 记得取消事件订阅,避免重复执行
|
||||
// this.Loaded -= UserManagementView_Loaded;
|
||||
//}
|
||||
|
||||
// 在 Window 或 UserControl 的代码后台
|
||||
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (sender is DataGrid dataGrid && dataGrid.DataContext is UserManagementViewModel viewModel)
|
||||
{
|
||||
// 获取所有新增选中的项
|
||||
foreach (var addedItem in e.AddedItems)
|
||||
{
|
||||
if (addedItem is UserOutput user)
|
||||
{
|
||||
user.IsSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取所有取消选中的项
|
||||
foreach (var removedItem in e.RemovedItems)
|
||||
{
|
||||
if (removedItem is UserOutput user)
|
||||
{
|
||||
user.IsSelected = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 通知 ViewModel 更新状态
|
||||
viewModel.UpdateSelectionState();
|
||||
}
|
||||
}
|
||||
|
||||
private async void ResetButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 手动清除 DateTimePicker
|
||||
// TO-DO HC DateTimePicker控件存在Bug,这里需要显示地清除,Bug已修复已提交PR
|
||||
//BeginTimePicker.Text = string.Empty;
|
||||
//EndTimePicker.Text = string.Empty;
|
||||
|
||||
// 通过反射获取内部 TextBox
|
||||
//var searchTextBoxField = typeof(AutoCompleteTextBox).GetField("_searchTextBox",
|
||||
// System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
|
||||
//if (searchTextBoxField?.GetValue(AutoCompleteTextBox) is System.Windows.Controls.TextBox textBox)
|
||||
//{
|
||||
// // 直接清空内部 TextBox
|
||||
// textBox.Text = string.Empty;
|
||||
//}
|
||||
|
||||
//// 清空其他状态
|
||||
//AutoCompleteTextBox.SelectedItem = null;
|
||||
//AutoCompleteTextBox.SelectedIndex = -1;
|
||||
|
||||
|
||||
// 调用 ViewModel 的重置方法
|
||||
if (DataContext is UserManagementViewModel viewModel)
|
||||
{
|
||||
await viewModel.ResetFormAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
267
yy-admin-master/YY.Admin/Views/UpdateWindow.xaml
Normal file
267
yy-admin-master/YY.Admin/Views/UpdateWindow.xaml
Normal file
@@ -0,0 +1,267 @@
|
||||
<hc:Window x:Class="YY.Admin.Views.UpdateWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:ctls="clr-namespace:YY.Admin.Core.Controls;assembly=YY.Admin.Core"
|
||||
Width="520"
|
||||
Height="480"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize"
|
||||
Background="White"
|
||||
BorderBrush="#f0f0f0"
|
||||
BorderThickness="1"
|
||||
Title="发现新版本">
|
||||
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="UpdatePrimaryButton" TargetType="Button" BasedOn="{StaticResource ButtonPrimary}">
|
||||
<Setter Property="Background" Value="#1890ff"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Height" Value="36"/>
|
||||
<Setter Property="Width" Value="100"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="UpdateSecondaryButton" TargetType="Button" BasedOn="{StaticResource ButtonDefault}">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="#666666"/>
|
||||
<Setter Property="BorderBrush" Value="#d9d9d9"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Height" Value="36"/>
|
||||
<Setter Property="Width" Value="100"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid Background="White" Margin="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<Border Grid.Row="0"
|
||||
Background="#fafafa"
|
||||
Height="50"
|
||||
BorderThickness="0,0,0,1"
|
||||
BorderBrush="#f0f0f0">
|
||||
<Grid Margin="20,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
Foreground="#1890ff"
|
||||
FontSize="18"
|
||||
Margin="0,0,12,0"/>
|
||||
<TextBlock Text="发现新版本"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="#333333"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="{Binding ApplicationName, StringFormat='{} {0}'}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"
|
||||
Foreground="#666666"
|
||||
FontSize="12"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 主要内容区域 -->
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" Padding="20">
|
||||
<StackPanel>
|
||||
<!-- 版本信息卡片 -->
|
||||
<Border Background="#f8f9fa"
|
||||
CornerRadius="6"
|
||||
Padding="16"
|
||||
Margin="0,0,0,16"
|
||||
BorderThickness="1"
|
||||
BorderBrush="#e9ecef">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 版本图标 -->
|
||||
<Border Grid.Column="0"
|
||||
Background="#e6f7ff"
|
||||
Width="40"
|
||||
Height="40"
|
||||
CornerRadius="20"
|
||||
Margin="0,0,16,0">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
Foreground="#1890ff"
|
||||
FontSize="16"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<!-- 版本信息 -->
|
||||
<StackPanel Grid.Column="1" VerticalAlignment="Center">
|
||||
<TextBlock Text="版本信息"
|
||||
FontWeight="SemiBold"
|
||||
FontSize="14"
|
||||
Foreground="#333333"
|
||||
Margin="0,0,0,8"/>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0" Margin="0,0,16,0">
|
||||
<TextBlock Text="当前版本:" Foreground="#666666" Margin="0,0,0,6"/>
|
||||
<TextBlock Text="最新版本:" Foreground="#666666" Margin="0,0,0,6"/>
|
||||
<TextBlock Text="发布日期:" Foreground="#666666"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="1">
|
||||
<TextBlock Text="{Binding CurrentVersion}"
|
||||
FontWeight="SemiBold"
|
||||
Margin="0,0,0,6"/>
|
||||
<TextBlock Text="{Binding LatestVersion}"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="#1890ff"
|
||||
Margin="0,0,0,6"/>
|
||||
<TextBlock Text="{Binding PublishDate}"
|
||||
FontWeight="SemiBold"
|
||||
Margin="0,0,0,6"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 更新内容卡片 -->
|
||||
<Border Background="White"
|
||||
CornerRadius="6"
|
||||
Padding="0"
|
||||
Margin="0,0,0,16"
|
||||
BorderThickness="1"
|
||||
BorderBrush="#e9ecef">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 卡片标题 -->
|
||||
<Border Grid.Row="0"
|
||||
Background="#f8f9fa"
|
||||
CornerRadius="6,6,0,0"
|
||||
Padding="16,12"
|
||||
BorderThickness="0,0,0,1"
|
||||
BorderBrush="#e9ecef">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
Foreground="#faad14"
|
||||
FontSize="14"
|
||||
Margin="0,0,8,0"/>
|
||||
<TextBlock Text="更新内容"
|
||||
FontWeight="SemiBold"
|
||||
FontSize="14"
|
||||
Foreground="#333333"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 更新内容 -->
|
||||
<Border Grid.Row="1" Padding="16,12">
|
||||
<ScrollViewer MaxHeight="150" VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock Text="{Binding Changelog}"
|
||||
TextWrapping="Wrap"
|
||||
Foreground="#666666"
|
||||
LineHeight="20"
|
||||
FontSize="13"/>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 强制更新提示(如果需要) -->
|
||||
<Border x:Name="MandatoryUpdatePanel"
|
||||
Background="#fff2f0"
|
||||
CornerRadius="4"
|
||||
Padding="12"
|
||||
Margin="0,0,0,16"
|
||||
BorderThickness="1"
|
||||
BorderBrush="#ffccc7"
|
||||
Visibility="Collapsed">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
Foreground="#ff4d4f"
|
||||
FontSize="14"
|
||||
Margin="0,0,8,0"/>
|
||||
<TextBlock Text="此为强制更新,必须更新后才能继续使用应用程序。"
|
||||
Foreground="#a8071a"
|
||||
FontSize="12"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="SemiBold"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 更新提示 -->
|
||||
<Border Background="#fffbe6"
|
||||
CornerRadius="4"
|
||||
Padding="12"
|
||||
Margin="0,0,0,16"
|
||||
BorderThickness="1"
|
||||
BorderBrush="#ffe58f">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ctls:FontAwesomeIcon
|
||||
Icon=""
|
||||
Foreground="#faad14"
|
||||
FontSize="14"
|
||||
Margin="0,0,8,0"/>
|
||||
<TextBlock Text="更新过程中请不要关闭应用程序,更新完成后将自动重启。"
|
||||
Foreground="#876800"
|
||||
FontSize="12"
|
||||
TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
<!-- 按钮区域 -->
|
||||
<Border Grid.Row="2"
|
||||
Background="#fafafa"
|
||||
Height="70"
|
||||
BorderThickness="0,1,0,0"
|
||||
BorderBrush="#f0f0f0">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Margin="20,0">
|
||||
<Button x:Name="LaterButton"
|
||||
Content="稍后提醒"
|
||||
Style="{StaticResource UpdateSecondaryButton}"
|
||||
Click="LaterButton_Click"
|
||||
Margin="0,0,12,0"/>
|
||||
<Button Content="立即更新"
|
||||
Style="{StaticResource UpdatePrimaryButton}"
|
||||
Click="UpdateButton_Click"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</hc:Window>
|
||||
53
yy-admin-master/YY.Admin/Views/UpdateWindow.xaml.cs
Normal file
53
yy-admin-master/YY.Admin/Views/UpdateWindow.xaml.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using YY.Admin.Services;
|
||||
using Window = HandyControl.Controls.Window;
|
||||
namespace YY.Admin.Views
|
||||
{
|
||||
public partial class UpdateWindow : Window
|
||||
{
|
||||
public event Action<string> UpdateRequested;
|
||||
|
||||
public UpdateWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
public string CurrentVersion { get; set; } = "1.0.0.0";
|
||||
public string LatestVersion { get; set; } = "1.0.0";
|
||||
public string PublishDate { get; set; } = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
public string Changelog { get; set; } = "暂无更新内容";
|
||||
public string DownloadUrl { get; set; } = "";
|
||||
public string ApplicationName { get; set; } = "应用程序";
|
||||
public bool IsMandatory { get; set; }
|
||||
|
||||
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
base.OnPropertyChanged(e);
|
||||
|
||||
if (e.Property == DataContextProperty && e.NewValue != null)
|
||||
{
|
||||
// 如果是强制更新,隐藏"稍后提醒"按钮并显示提示
|
||||
if (IsMandatory)
|
||||
{
|
||||
MandatoryUpdatePanel.Visibility = Visibility.Visible;
|
||||
LaterButton.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
UpdateRequested?.Invoke(DownloadUrl);
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void LaterButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = false;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user