detect/detect.gui/ViewModels/WebViewModel.cs

34 lines
894 B
C#
Raw Normal View History

2024-11-13 17:09:15 +08:00
using System;
using ReactiveUI;
using Serilog;
using xwd.utils;
namespace detect.gui.ViewModels;
public class WebViewModel : ViewModelBase
{
private readonly string[] _localRoutes =
[
2024-11-15 17:46:05 +08:00
"#/data/task",
"#/data/device",
2024-11-13 17:09:15 +08:00
"#/system/log",
"#/system/user"
];
private string? _address;
public string? Address
{
get => _address;
set => this.RaiseAndSetIfChanged(ref _address, value);
}
public void SetAddress(int index)
{
var isOnLine = AppSettingsManager.Manager().GetBool("Embedded.IsOnline");
var path = AppSettingsManager.Manager().GetString("Embedded.Path", "./dist/index.html");
var prefix = isOnLine ? path : AppDomain.CurrentDomain.BaseDirectory + path;
Address = $"{prefix}{_localRoutes[index]}";
Log.Information("current address: {address}", Address);
}
}