fix.在线安装器,启动器

This commit is contained in:
lincube
2026-06-05 11:08:11 +08:00
parent bb4e90ea8d
commit 8c88e305ee
42 changed files with 1507 additions and 393 deletions

View File

@@ -15,43 +15,9 @@ public sealed partial class InstallerStepViewModel(
[ObservableProperty]
private bool _isSelected;
[ObservableProperty]
private bool _isCompleted;
public InstallerStepId StepId { get; } = stepId;
public string Title { get; } = title;
public Icon Icon { get; } = icon;
public bool IsLocked => !IsUnlocked;
public Icon DisplayIcon => IsLocked
? Icon.LockClosed
: IsCompleted
? Icon.CheckmarkCircle
: Icon;
public bool IsAvailable => IsUnlocked && !IsSelected && !IsCompleted;
partial void OnIsUnlockedChanged(bool value)
{
_ = value;
OnPropertyChanged(nameof(IsLocked));
OnPropertyChanged(nameof(IsAvailable));
OnPropertyChanged(nameof(DisplayIcon));
}
partial void OnIsSelectedChanged(bool value)
{
_ = value;
OnPropertyChanged(nameof(IsAvailable));
}
partial void OnIsCompletedChanged(bool value)
{
_ = value;
OnPropertyChanged(nameof(DisplayIcon));
OnPropertyChanged(nameof(IsAvailable));
}
}

View File

@@ -15,7 +15,6 @@ public sealed partial class MainWindowViewModel : ObservableObject
private readonly IPrivacyDeviceIdentityProvider _privacyIdentity;
private readonly InstallerPrivacyConsentStore _privacyConsentStore;
private CancellationTokenSource? _installCts;
private bool _isNavigatingInternally;
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(NextCommand))]
@@ -72,9 +71,6 @@ public sealed partial class MainWindowViewModel : ObservableObject
[ObservableProperty]
private bool _createStartupShortcut;
[ObservableProperty]
private InstallerStepViewModel? _selectedStep;
public MainWindowViewModel(
IOnlineInstallService installService,
IPrivacyDeviceIdentityProvider privacyIdentity,
@@ -92,7 +88,6 @@ public sealed partial class MainWindowViewModel : ObservableObject
new InstallerStepViewModel(InstallerStepId.Complete, "完成安装", Icon.Circle)
];
SyncSteps();
SelectedStep = Steps[0];
DeviceIdPreview = _privacyIdentity.GetOrCreateDeviceId();
PrivacyConfirmed = _privacyConsentStore.HasConfirmed(DeviceIdPreview);
}
@@ -173,22 +168,6 @@ public sealed partial class MainWindowViewModel : ObservableObject
OnPropertyChanged(nameof(CanStartInstall));
}
partial void OnSelectedStepChanged(InstallerStepViewModel? value)
{
if (_isNavigatingInternally || value is null)
{
return;
}
if (!IsInstalling && value.StepId <= MaxUnlockedStep)
{
CurrentStep = value.StepId;
return;
}
SyncSteps();
}
[RelayCommand(CanExecute = nameof(CanGoNext))]
private async Task NextAsync()
{
@@ -231,6 +210,17 @@ public sealed partial class MainWindowViewModel : ObservableObject
}
}
[RelayCommand]
private void SelectStep(InstallerStepViewModel? step)
{
if (step is null || IsInstalling || step.StepId > MaxUnlockedStep)
{
return;
}
CurrentStep = step.StepId;
}
[RelayCommand]
private async Task BrowseAsync()
{
@@ -245,7 +235,7 @@ public sealed partial class MainWindowViewModel : ObservableObject
var selected = await BrowseRequested(InstallPath);
if (!string.IsNullOrWhiteSpace(selected))
{
InstallPath = selected;
InstallPath = InstallerPathGuard.GetInstallPathForSelectedFolder(selected);
}
}
catch (Exception ex)
@@ -348,23 +338,10 @@ public sealed partial class MainWindowViewModel : ObservableObject
private void SyncSteps()
{
_isNavigatingInternally = true;
try
foreach (var step in Steps)
{
foreach (var step in Steps)
{
step.IsUnlocked = step.StepId <= MaxUnlockedStep;
step.IsSelected = step.StepId == CurrentStep;
step.IsCompleted = step.StepId < CurrentStep;
if (step.StepId == CurrentStep && !ReferenceEquals(SelectedStep, step))
{
SelectedStep = step;
}
}
}
finally
{
_isNavigatingInternally = false;
step.IsUnlocked = step.StepId <= MaxUnlockedStep;
step.IsSelected = step.StepId == CurrentStep;
}
}