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

@@ -126,7 +126,7 @@ public partial class DevDebugWindow : Window
try
{
// 等待用户点击开始按钮
await oobeWindow.WaitForEnterAsync();
await oobeWindow.WaitForCompletionAsync();
// 用户点击后窗口会自动关闭通过OobeWindow内部的动画和关闭逻辑
Console.WriteLine("[DevDebugWindow] OOBE completed by user");

View File

@@ -17,10 +17,11 @@ public partial class OobeWindow : Window
private const int AnimationDurationMs = 300;
private const int TypingDelayMs = 100;
private readonly TaskCompletionSource<bool> _completionSource = new();
private readonly TaskCompletionSource<OobeSessionDraft?> _completionSource = new(TaskCreationOptions.RunContinuationsAsynchronously);
private readonly DataLocationResolver _resolver;
private bool _isTransitioning;
private bool _isDebugMode;
private bool _isCompleting;
private int _currentStep = 1;
// 数据位置选择
@@ -40,6 +41,7 @@ public partial class OobeWindow : Window
AvaloniaXamlLoader.Load(this);
Loaded += OnWindowLoaded;
Opened += OnWindowOpened;
Closed += OnWindowClosed;
var appRoot = AppDomain.CurrentDomain.BaseDirectory;
_resolver = new DataLocationResolver(appRoot);
@@ -51,7 +53,7 @@ public partial class OobeWindow : Window
_isDebugMode = isDebugMode;
}
public Task WaitForEnterAsync() => _completionSource.Task;
internal Task<OobeSessionDraft?> WaitForCompletionAsync() => _completionSource.Task;
private void OnWindowLoaded(object? sender, RoutedEventArgs e)
{
@@ -261,6 +263,14 @@ public partial class OobeWindow : Window
await PlayTypingAnimationAsync();
}
private void OnWindowClosed(object? sender, EventArgs e)
{
if (!_isCompleting)
{
_completionSource.TrySetResult(null);
}
}
private async Task PlayTypingAnimationAsync()
{
var typingTextBlock = this.FindControl<TextBlock>("TypingTextBlock");
@@ -477,11 +487,6 @@ public partial class OobeWindow : Window
if (_isTransitioning) return;
// 应用数据位置选择
if (!_isDebugMode)
{
_resolver.ApplyLocationChoice(_selectedDataLocationMode, null, _migrateExistingData);
}
await NavigateToStep(4);
}
@@ -495,7 +500,6 @@ public partial class OobeWindow : Window
private async void OnStartupPresentationNextClick(object? sender, RoutedEventArgs e)
{
if (_isTransitioning) return;
SaveOobeStartupPresentation();
await NavigateToStep(5);
}
@@ -521,7 +525,7 @@ public partial class OobeWindow : Window
private void RefreshOobeStartupPresentationFromDisk()
{
var path = HostAppSettingsOobeMerger.GetSettingsFilePath(_resolver.ResolveDataRoot());
var path = HostAppSettingsOobeMerger.GetSettingsFilePath(ResolveSelectedDataRoot());
var defaults = HostAppSettingsOobeMerger.LoadStartupDefaults(path);
if (this.FindControl<Border>("OobeSlideTransitionSection") is { } slideSection)
@@ -675,8 +679,6 @@ public partial class OobeWindow : Window
if (_isTransitioning) return;
// 保存隐私设置
SavePrivacySettings();
await NavigateToStep(6);
}
@@ -725,13 +727,15 @@ public partial class OobeWindow : Window
try
{
await PlayExitAnimationAsync();
_completionSource.TrySetResult(true);
_isCompleting = true;
_completionSource.TrySetResult(BuildSessionDraft());
Close();
}
catch (Exception ex)
{
Console.Error.WriteLine($"[OobeWindow] Error: {ex.Message}");
_completionSource.TrySetResult(true);
_isCompleting = true;
_completionSource.TrySetResult(BuildSessionDraft());
Close();
}
}
@@ -978,6 +982,43 @@ public partial class OobeWindow : Window
}
}
private OobeSessionDraft BuildSessionDraft()
{
var privacy = BuildPrivacyConfig();
return new OobeSessionDraft
{
DataLocationMode = _selectedDataLocationMode,
MigrateExistingData = _migrateExistingData,
StartupChoices = CollectOobeStartupChoices(),
PrivacyConfig = privacy,
PrivacyAgreementAccepted = this.FindControl<CheckBox>("PrivacyAgreementCheckBox")?.IsChecked ?? false,
PrivacyUserId = privacy.TelemetryId,
PrivacyDeviceId = GetDeviceIdentifier()
};
}
private PrivacyConfig BuildPrivacyConfig()
{
return new PrivacyConfig
{
CrashTelemetryEnabled = this.FindControl<ToggleSwitch>("CrashTelemetryToggle")?.IsChecked ?? true,
UsageTelemetryEnabled = this.FindControl<ToggleSwitch>("UsageTelemetryToggle")?.IsChecked ?? true,
TelemetryId = this.FindControl<TextBox>("TelemetryIdTextBox")?.Text ?? Guid.NewGuid().ToString("N")
};
}
private string ResolveSelectedDataRoot()
{
try
{
return _resolver.ResolveDataRoot(_selectedDataLocationMode);
}
catch
{
return _resolver.DefaultSystemDataPath;
}
}
private static double EaseOutCubic(double t) => 1 - Math.Pow(1 - t, 3);
private static double EaseOutQuad(double t) => 1 - Math.Pow(1 - t, 2);
private static double EaseOutBack(double t)