using System;
using System.Reactive;
using DispenserCommon.Aop;
using DispenserCommon.Events;
using DispenserCommon.Ioc;
using DispenserUI.ViewModels.Product;
using DispenserUI.ViewModels.Setting;
using ReactiveUI;
namespace DispenserUI.ViewModels;
///
/// 内容页面视图模型
///
[Component, GlobalTry]
public class ContainerViewModel : DynamicViewModel
{
private string _currentPage = "IndexView";
///
/// 去首页
///
public ReactiveCommand ToIndexView { get; }
///
/// 去设置页
///
public ReactiveCommand ToSettingsView { get; }
public ContainerViewModel()
{
Visible = true;
ToIndexView = ReactiveCommand.Create(ToIndexViewCmd);
ToSettingsView = ReactiveCommand.Create(ToSettingsViewCmd);
}
public string CurrentPage
{
get => _currentPage;
set => this.RaiseAndSetIfChanged(ref _currentPage, value);
}
///
/// 处理跳转首页命令
///
[Operation("主菜单跳转-前往主页面")]
private void ToIndexViewCmd()
{
CurrentPage = "IndexView";
EventBus.Publish(EventType.PageChanged, typeof(ProductIndexVM));
}
///
/// 处理跳转设置页命令
///
[Operation("主菜单跳转-前往设置页面")]
private void ToSettingsViewCmd()
{
CurrentPage = "SettingView";
EventBus.Publish(EventType.PageChanged, typeof(SettingsVM));
}
}