mirror of
https://github.com/yaobiao131/downkyicore.git
synced 2025-08-10 00:52:31 +00:00
82 lines
2.5 KiB
C#
82 lines
2.5 KiB
C#
using System.Collections.ObjectModel;
|
|
using Avalonia.Controls.Documents;
|
|
using DownKyi.Utils;
|
|
using Prism.Commands;
|
|
using Prism.Services.Dialogs;
|
|
using SqlSugar;
|
|
using System.Linq;
|
|
using DownKyi.Core.Settings;
|
|
using DownKyi.Models;
|
|
|
|
namespace DownKyi.ViewModels.Dialogs
|
|
{
|
|
public class NewVersionAvailableDialogViewModel : BaseDialogViewModel
|
|
{
|
|
public const string Tag = "NewVersionAvailable";
|
|
|
|
|
|
private DelegateCommand? _allowCommand;
|
|
|
|
private DelegateCommand? _skipCurrentVersionCommand;
|
|
|
|
public DelegateCommand SkipCurrentVersionCommand => _skipCurrentVersionCommand ??= new DelegateCommand(ExecuteSkipCurrentVersionCommand);
|
|
public DelegateCommand AllowCommand => _allowCommand ??= new DelegateCommand(ExecuteAllowCommand);
|
|
|
|
private void ExecuteAllowCommand()
|
|
{
|
|
const ButtonResult result = ButtonResult.OK;
|
|
PlatformHelper.Open($"https://github.com/{App.RepoOwner}/{App.RepoName}/releases/tag/{TagName}");
|
|
RaiseRequestClose(new DialogResult(result));
|
|
}
|
|
|
|
|
|
private void ExecuteSkipCurrentVersionCommand()
|
|
{
|
|
SettingsManager.GetInstance().SetSkipVersionOnLaunch(NewVersion);
|
|
RaiseRequestClose(new DialogResult());
|
|
}
|
|
|
|
private string _tagName;
|
|
|
|
public string TagName
|
|
{
|
|
get => _tagName;
|
|
set => SetProperty(ref _tagName, value);
|
|
}
|
|
|
|
private string _markdownText;
|
|
|
|
public string MarkdownText
|
|
{
|
|
get => _markdownText;
|
|
set => SetProperty(ref _markdownText, value);
|
|
}
|
|
|
|
private bool _enableSkipVersionOnLaunch = false;
|
|
|
|
|
|
private string _newVersion;
|
|
|
|
private string NewVersion
|
|
{
|
|
get => _newVersion;
|
|
set => SetProperty(ref _newVersion, value);
|
|
}
|
|
|
|
public bool EnableSkipVersionOnLaunch
|
|
{
|
|
get => _enableSkipVersionOnLaunch;
|
|
set => SetProperty(ref _enableSkipVersionOnLaunch, value);
|
|
}
|
|
|
|
public override void OnDialogOpened(IDialogParameters parameters)
|
|
{
|
|
var release = parameters.GetValue<GitHubRelease>("release");
|
|
EnableSkipVersionOnLaunch = parameters.GetValue<bool>("enableSkipVersion");
|
|
MarkdownText = release.Body;
|
|
TagName = release.TagName;
|
|
NewVersion = release.TagName.TrimStart('v');
|
|
}
|
|
}
|
|
}
|