给菜单添加TargetViewKey

This commit is contained in:
2025-07-26 16:32:01 +08:00
parent 825f51d1ce
commit eedc9f9c7b
8 changed files with 93 additions and 34 deletions

View File

@@ -1,7 +1,10 @@
using System.Collections.ObjectModel;
using System.Windows.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using DMS.Application.DTOs;
using DMS.Core.Enums;
using DMS.WPF.Services;
namespace DMS.WPF.ViewModels.Items;
@@ -23,6 +26,8 @@ public partial class MenuBeanItemViewModel : ObservableObject
[ObservableProperty]
private int _targetId;
[ObservableProperty]
private string _targetViewKey;
[ObservableProperty]
private string _navigationParameter;
@@ -31,16 +36,26 @@ public partial class MenuBeanItemViewModel : ObservableObject
private int _displayOrder;
[ObservableProperty]
private ObservableCollection<MenuBeanItemViewModel> _children=new ();
/// <summary>
/// 菜单项点击时执行的导航命令。
/// </summary>
public ICommand NavigateCommand { get; }
public MenuBeanItemViewModel(MenuBeanDto dto)
public MenuBeanItemViewModel(MenuBeanDto dto,INavigationService navigationService)
{
Id = dto.Id;
_parentId = dto.ParentId;
_header = dto.Header;
_icon = dto.Icon;
_menuType = dto.MenuType;
_targetViewKey=dto.TargetViewKey;
_targetId = dto.TargetId;
_navigationParameter = dto.NavigationParameter;
_displayOrder = dto.DisplayOrder;
NavigateCommand = new AsyncRelayCommand(async () =>
{
await navigationService.NavigateToAsync(_targetViewKey, _navigationParameter);
});
}
}