64 lines
1.6 KiB
C#
64 lines
1.6 KiB
C#
|
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;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 内容页面视图模型
|
|||
|
/// </summary>
|
|||
|
[Component, GlobalTry]
|
|||
|
public class ContainerViewModel : DynamicViewModel
|
|||
|
{
|
|||
|
private string _currentPage = "IndexView";
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 去首页
|
|||
|
/// </summary>
|
|||
|
public ReactiveCommand<Unit, Unit> ToIndexView { get; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 去设置页
|
|||
|
/// </summary>
|
|||
|
public ReactiveCommand<Unit, Unit> 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);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 处理跳转首页命令
|
|||
|
/// </summary>
|
|||
|
[Operation("主菜单跳转-前往主页面")]
|
|||
|
private void ToIndexViewCmd()
|
|||
|
{
|
|||
|
CurrentPage = "IndexView";
|
|||
|
EventBus<Type>.Publish(EventType.PageChanged, typeof(ProductIndexVM));
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 处理跳转设置页命令
|
|||
|
/// </summary>
|
|||
|
[Operation("主菜单跳转-前往设置页面")]
|
|||
|
private void ToSettingsViewCmd()
|
|||
|
{
|
|||
|
CurrentPage = "SettingView";
|
|||
|
EventBus<Type>.Publish(EventType.PageChanged, typeof(SettingsVM));
|
|||
|
}
|
|||
|
}
|