mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 23:54:26 +08:00
Refactor DataLocationResolver to centralize data path resolution (ResolveLauncherDataPath, ResolveDesktopDataPath, ResolveConfigPath, ResolveLauncherLogsPath, ResolveLauncherStatePath) and replace usages of the previous ".launcher" layout with a "Launcher" folder. Update API: LoadConfig/SaveConfig reorganized and ApplyLocationChoice now accepts an optional custom path and migration flag; migration logic updated accordingly. Update dependent services and views (Logger, DeploymentLocator, UpdateEngineService, OobeStateService, StartupAttemptRegistry, LauncherDebugSettingsStore, OobeWindow) to use the new resolver APIs and paths. Add LauncherBackgroundService to load/validate/cache a custom splash background image and wire it into SplashWindow (AXAML/Axaml.cs) with UI placeholders and overlay. Misc: minor cleanup of Oobe/Splash XAML and related code adjustments and logging improvements.
68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using Avalonia.Threading;
|
|
using LanMountainDesktop.Launcher.Models;
|
|
using LanMountainDesktop.Launcher.Views;
|
|
|
|
namespace LanMountainDesktop.Launcher.Services;
|
|
|
|
internal sealed class DataLocationOobeStep : IOobeStep
|
|
{
|
|
private readonly DataLocationResolver _resolver;
|
|
|
|
public DataLocationOobeStep(DataLocationResolver resolver)
|
|
{
|
|
_resolver = resolver;
|
|
}
|
|
|
|
public async Task RunAsync(CancellationToken cancellationToken)
|
|
{
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
var existingConfig = _resolver.LoadConfig();
|
|
if (existingConfig is not null)
|
|
{
|
|
Logger.Info("DataLocation OOBE step skipped: config already exists.");
|
|
return;
|
|
}
|
|
|
|
DataLocationPromptWindow? window = null;
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
{
|
|
window = new DataLocationPromptWindow(_resolver);
|
|
window.Show();
|
|
});
|
|
|
|
if (window is null)
|
|
{
|
|
Logger.Warn("DataLocation OOBE step failed: window could not be created.");
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
var result = await window.WaitForChoiceAsync().ConfigureAwait(false);
|
|
if (result is null)
|
|
{
|
|
Logger.Info("DataLocation OOBE step: user cancelled or closed window. Using default system location.");
|
|
_resolver.ApplyLocationChoice(DataLocationMode.System, null, false);
|
|
}
|
|
else
|
|
{
|
|
var success = _resolver.ApplyLocationChoice(result.SelectedMode, null, result.MigrateExistingData);
|
|
Logger.Info(
|
|
$"DataLocation OOBE step: user selected '{result.SelectedMode}'. " +
|
|
$"Migrate={result.MigrateExistingData}; Success={success}.");
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
{
|
|
if (window.IsVisible)
|
|
{
|
|
window.Close();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|