2025-06-24 20:48:38 +08:00
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
2025-06-25 22:33:57 +08:00
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
2025-06-24 20:48:38 +08:00
|
|
|
|
using PMSWPF.Data.Entities;
|
|
|
|
|
|
using PMSWPF.Data.Repositories;
|
2025-06-25 22:33:57 +08:00
|
|
|
|
using PMSWPF.Models;
|
2025-06-10 20:55:39 +08:00
|
|
|
|
using PMSWPF.Services;
|
2025-05-29 08:58:58 +08:00
|
|
|
|
|
2025-06-23 17:01:06 +08:00
|
|
|
|
namespace PMSWPF.ViewModels;
|
2025-06-10 20:55:39 +08:00
|
|
|
|
|
2025-06-23 17:01:06 +08:00
|
|
|
|
public partial class MainViewModel : ViewModelBase
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly NavgatorServices _navgatorServices;
|
2025-06-10 20:55:39 +08:00
|
|
|
|
|
2025-06-23 17:01:06 +08:00
|
|
|
|
[ObservableProperty] private ViewModelBase currentViewModel;
|
2025-06-24 20:48:38 +08:00
|
|
|
|
[ObservableProperty]
|
2025-06-25 22:33:57 +08:00
|
|
|
|
private ObservableCollection<MenuBean> _menus;
|
2025-05-29 08:58:58 +08:00
|
|
|
|
|
2025-06-23 17:01:06 +08:00
|
|
|
|
public MainViewModel(NavgatorServices navgatorServices)
|
|
|
|
|
|
{
|
|
|
|
|
|
_navgatorServices = navgatorServices;
|
|
|
|
|
|
_navgatorServices.OnViewModelChanged += () => { CurrentViewModel = _navgatorServices.CurrentViewModel; };
|
|
|
|
|
|
CurrentViewModel = new HomeViewModel();
|
2025-06-24 20:48:38 +08:00
|
|
|
|
CurrentViewModel.OnLoaded();
|
2025-06-23 17:01:06 +08:00
|
|
|
|
}
|
2025-05-29 08:58:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-06-25 22:33:57 +08:00
|
|
|
|
|
2025-06-24 20:48:38 +08:00
|
|
|
|
public override async void OnLoaded()
|
2025-06-25 22:33:57 +08:00
|
|
|
|
{
|
2025-06-24 20:48:38 +08:00
|
|
|
|
MenuRepositories mr = new MenuRepositories();
|
|
|
|
|
|
var menuList= await mr.GetMenu();
|
2025-06-25 22:33:57 +08:00
|
|
|
|
Menus=new ObservableCollection<MenuBean>(menuList);
|
2025-05-29 08:58:58 +08:00
|
|
|
|
}
|
2025-06-23 17:01:06 +08:00
|
|
|
|
}
|