2026-04-21 20:59:52 +08:00
|
|
|
|
using Avalonia.Controls;
|
|
|
|
|
|
using Avalonia.Markup.Xaml;
|
2026-05-18 12:26:23 +08:00
|
|
|
|
using LanMountainDesktop.Launcher.Resources;
|
2026-04-21 20:59:52 +08:00
|
|
|
|
using LanMountainDesktop.Launcher.Services;
|
|
|
|
|
|
using LanMountainDesktop.Launcher.ViewModels;
|
|
|
|
|
|
using LanMountainDesktop.Launcher.Views;
|
|
|
|
|
|
|
|
|
|
|
|
namespace LanMountainDesktop.Launcher.Views;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 开发调试窗口
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class DevDebugWindow : Window
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly DevDebugWindowViewModel _viewModel;
|
|
|
|
|
|
|
|
|
|
|
|
public DevDebugWindow()
|
|
|
|
|
|
{
|
|
|
|
|
|
AvaloniaXamlLoader.Load(this);
|
|
|
|
|
|
|
|
|
|
|
|
_viewModel = new DevDebugWindowViewModel();
|
|
|
|
|
|
DataContext = _viewModel;
|
|
|
|
|
|
|
|
|
|
|
|
// 订阅事件
|
|
|
|
|
|
_viewModel.OpenSplashRequested += OnOpenSplashRequested;
|
|
|
|
|
|
_viewModel.OpenErrorRequested += OnOpenErrorRequested;
|
|
|
|
|
|
_viewModel.OpenUpdateRequested += OnOpenUpdateRequested;
|
|
|
|
|
|
_viewModel.OpenOobeRequested += OnOpenOobeRequested;
|
Launcher fix (#6)
* fix.hy3试图修复中
* Resolve dev paths and fix splash UI thread
Compute a solutionRoot and expand development search paths (LanMountainDesktop and dev-test) in DeploymentLocator, add logging when scanning/finding hosts, and return distinct full paths. Ensure backward-compatible path checks. Fix cross-thread UI calls: invoke splashWindow.DismissAsync on the UI thread in LauncherFlowCoordinator, and make SplashWindow.DismissAsync ensure it runs on the UI thread before closing (simplified Close call). These changes improve development host discovery and prevent UI-thread access issues during shutdown.
* Add configurable data location (portable/system)
Introduce support for choosing and resolving the application's data root (system user dir vs. portable app folder). Adds DataLocationConfig model, DataLocationResolver (load/save/resolve/migrate), a UI prompt (DataLocationPromptWindow) and an OOBE step (DataLocationOobeStep) to let users pick and optionally migrate existing data. Wire the chosen data root into the launcher flow and host launch plan (forwarded via --data-root and LMD_DATA_ROOT), and add AppDataPathProvider to let runtime services read the effective data root (initialized in Program.Main). Update various services (logging, settings, DB, plugin/market, startup registry, etc.) to use the new provider/resolver and register the config type in the JSON context. This enables portable installs, safe migration, and runtime overrides via CLI or environment variable.
* Add dev/debug startup flow and launch profiles
Handle design-time initialization and add a developer debug startup path: App now skips normal startup when in design mode and shows a DevDebugWindow when running in debug (unless a preview or apply-update command). CommandContext.IsDebugMode is extended to include DOTNET_ENVIRONMENT=Development via a new IsDevelopmentEnvironment helper. Program.Main and BuildAvaloniaApp are made public to aid tooling. Added multiple launchSettings profiles for debug and preview commands that set DOTNET_ENVIRONMENT=Development to simplify IDE debugging and UI previewing.
* Simplify splash to fade; add themed about banners
Simplify splash startup visuals by removing the multi-mode/slide behavior and always using a fade animation. Update App to create SplashWindow without a StartupVisualMode parameter and remove related fields, layout configuration, slide animation, and easing helpers from SplashWindow. Clean up unused using. Replace the single about_banner asset with theme-aware variants (about_banner_dark.png and about_banner_light.png), delete the old about_banner.png, and update AboutSettingsPage to use a DynamicResource ImageBrush (AboutBannerBrush) that selects the appropriate banner per theme.
* Use AppJsonContext for startup state serialization
Switch serialization to the source-generated System.Text.Json context: add JsonSerializable(typeof(StartupAttemptRecord)) to AppJsonContext and replace the previous JsonSerializerOptions-based Serialize/Deserialize calls with AppJsonContext.Default.StartupAttemptRecord. Also remove the now-unused SerializerOptions field. Additionally, update .gitignore to exclude /test-aot-publish.
* Add OOBE redesign, theme & data location support
Introduce a redesigned OOBE flow and data-location/theme support across the launcher. Adds a new ThemeService for applying light/dark and accent colors; integrates FluentIcons.Avalonia package for icons. Overhauls OobeWindow (UX animations, typing effect, multi-step theme and data-location pages, Monet options, and final welcome step) and its code-behind to handle step navigation, accent selection, and data-location resolution. Adds DataLocation UI and handlers (DataLocationPromptWindow changes, DataLocation resolver usage) and wires a DevDebug UI for toggling/opening the data-location page. UpdateEngineService now resolves the launcher root via DataLocationResolver. Misc: update various view models, localization entries and remove TrimmerRoots.xml.
* Refactor data location paths and add background service
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.
2026-04-25 18:41:26 +08:00
|
|
|
|
_viewModel.OpenDataLocationRequested += OnOpenDataLocationRequested;
|
2026-04-21 20:59:52 +08:00
|
|
|
|
_viewModel.CloseRequested += OnCloseRequested;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开启动画面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnOpenSplashRequested(object? sender, SplashOpenEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var splashWindow = new SplashWindow();
|
|
|
|
|
|
|
|
|
|
|
|
if (!e.IsFunctional)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 查看模式:显示模拟内容
|
|
|
|
|
|
splashWindow.SetDebugMode(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
splashWindow.Show();
|
|
|
|
|
|
|
|
|
|
|
|
if (e.IsFunctional)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 功能模式:模拟正常启动流程
|
|
|
|
|
|
_ = SimulateSplashProgress(splashWindow);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开错误页面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnOpenErrorRequested(object? sender, ErrorOpenEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var errorWindow = new ErrorWindow();
|
|
|
|
|
|
|
|
|
|
|
|
if (!e.IsFunctional)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 查看模式:显示模拟错误
|
|
|
|
|
|
errorWindow.SetDebugMode(true);
|
2026-05-18 12:26:23 +08:00
|
|
|
|
errorWindow.SetErrorMessage(Strings.Preview_ErrorMessage);
|
2026-04-21 20:59:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// 功能模式:显示真实错误
|
2026-05-18 12:26:23 +08:00
|
|
|
|
errorWindow.SetErrorMessage(Strings.Error_HostNotFoundMessage);
|
2026-04-21 20:59:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
errorWindow.Show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开更新页面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnOpenUpdateRequested(object? sender, UpdateOpenEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var updateWindow = new UpdateWindow();
|
|
|
|
|
|
|
|
|
|
|
|
if (!e.IsFunctional)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 查看模式:显示模拟更新
|
|
|
|
|
|
updateWindow.SetDebugMode(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateWindow.Show();
|
|
|
|
|
|
|
|
|
|
|
|
if (e.IsFunctional)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 功能模式:模拟更新进度
|
|
|
|
|
|
_ = SimulateUpdateProgress(updateWindow);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开OOBE页面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnOpenOobeRequested(object? sender, OobeOpenEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var oobeWindow = new OobeWindow();
|
|
|
|
|
|
|
|
|
|
|
|
if (!e.IsFunctional)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 查看模式:显示调试标记(通过标题)
|
|
|
|
|
|
oobeWindow.Title = "[调试模式] 欢迎使用阑山桌面";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
oobeWindow.Show();
|
|
|
|
|
|
|
|
|
|
|
|
if (e.IsFunctional)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 功能模式:等待用户点击后自动关闭
|
|
|
|
|
|
_ = SimulateOobeProgress(oobeWindow);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 模拟OOBE流程
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private async Task SimulateOobeProgress(OobeWindow oobeWindow)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
// 等待用户点击开始按钮
|
|
|
|
|
|
await oobeWindow.WaitForEnterAsync();
|
|
|
|
|
|
|
|
|
|
|
|
// 用户点击后,窗口会自动关闭(通过OobeWindow内部的动画和关闭逻辑)
|
|
|
|
|
|
Console.WriteLine("[DevDebugWindow] OOBE completed by user");
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.Error.WriteLine($"[DevDebugWindow] Error during OOBE simulation: {ex.Message}");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Launcher fix (#6)
* fix.hy3试图修复中
* Resolve dev paths and fix splash UI thread
Compute a solutionRoot and expand development search paths (LanMountainDesktop and dev-test) in DeploymentLocator, add logging when scanning/finding hosts, and return distinct full paths. Ensure backward-compatible path checks. Fix cross-thread UI calls: invoke splashWindow.DismissAsync on the UI thread in LauncherFlowCoordinator, and make SplashWindow.DismissAsync ensure it runs on the UI thread before closing (simplified Close call). These changes improve development host discovery and prevent UI-thread access issues during shutdown.
* Add configurable data location (portable/system)
Introduce support for choosing and resolving the application's data root (system user dir vs. portable app folder). Adds DataLocationConfig model, DataLocationResolver (load/save/resolve/migrate), a UI prompt (DataLocationPromptWindow) and an OOBE step (DataLocationOobeStep) to let users pick and optionally migrate existing data. Wire the chosen data root into the launcher flow and host launch plan (forwarded via --data-root and LMD_DATA_ROOT), and add AppDataPathProvider to let runtime services read the effective data root (initialized in Program.Main). Update various services (logging, settings, DB, plugin/market, startup registry, etc.) to use the new provider/resolver and register the config type in the JSON context. This enables portable installs, safe migration, and runtime overrides via CLI or environment variable.
* Add dev/debug startup flow and launch profiles
Handle design-time initialization and add a developer debug startup path: App now skips normal startup when in design mode and shows a DevDebugWindow when running in debug (unless a preview or apply-update command). CommandContext.IsDebugMode is extended to include DOTNET_ENVIRONMENT=Development via a new IsDevelopmentEnvironment helper. Program.Main and BuildAvaloniaApp are made public to aid tooling. Added multiple launchSettings profiles for debug and preview commands that set DOTNET_ENVIRONMENT=Development to simplify IDE debugging and UI previewing.
* Simplify splash to fade; add themed about banners
Simplify splash startup visuals by removing the multi-mode/slide behavior and always using a fade animation. Update App to create SplashWindow without a StartupVisualMode parameter and remove related fields, layout configuration, slide animation, and easing helpers from SplashWindow. Clean up unused using. Replace the single about_banner asset with theme-aware variants (about_banner_dark.png and about_banner_light.png), delete the old about_banner.png, and update AboutSettingsPage to use a DynamicResource ImageBrush (AboutBannerBrush) that selects the appropriate banner per theme.
* Use AppJsonContext for startup state serialization
Switch serialization to the source-generated System.Text.Json context: add JsonSerializable(typeof(StartupAttemptRecord)) to AppJsonContext and replace the previous JsonSerializerOptions-based Serialize/Deserialize calls with AppJsonContext.Default.StartupAttemptRecord. Also remove the now-unused SerializerOptions field. Additionally, update .gitignore to exclude /test-aot-publish.
* Add OOBE redesign, theme & data location support
Introduce a redesigned OOBE flow and data-location/theme support across the launcher. Adds a new ThemeService for applying light/dark and accent colors; integrates FluentIcons.Avalonia package for icons. Overhauls OobeWindow (UX animations, typing effect, multi-step theme and data-location pages, Monet options, and final welcome step) and its code-behind to handle step navigation, accent selection, and data-location resolution. Adds DataLocation UI and handlers (DataLocationPromptWindow changes, DataLocation resolver usage) and wires a DevDebug UI for toggling/opening the data-location page. UpdateEngineService now resolves the launcher root via DataLocationResolver. Misc: update various view models, localization entries and remove TrimmerRoots.xml.
* Refactor data location paths and add background service
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.
2026-04-25 18:41:26 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开数据位置选择页面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnOpenDataLocationRequested(object? sender, DataLocationOpenEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var appRoot = AppDomain.CurrentDomain.BaseDirectory;
|
|
|
|
|
|
var resolver = new DataLocationResolver(appRoot);
|
|
|
|
|
|
var window = new DataLocationPromptWindow(resolver);
|
|
|
|
|
|
window.Show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-21 20:59:52 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关闭窗口
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnCloseRequested(object? sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 模拟启动画面进度
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private async Task SimulateSplashProgress(SplashWindow splashWindow)
|
|
|
|
|
|
{
|
2026-05-18 12:26:23 +08:00
|
|
|
|
var stages = new[] { Strings.Preview_SplashInitializing, Strings.Preview_SplashCheckingUpdates, Strings.Preview_SplashCheckingPlugins, Strings.Preview_SplashLaunchingHost };
|
2026-04-21 20:59:52 +08:00
|
|
|
|
var reporter = (ISplashStageReporter)splashWindow;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < stages.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
reporter.ReportStage(stages[i], (i + 1) * 25);
|
|
|
|
|
|
await Task.Delay(500);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 3秒后关闭
|
|
|
|
|
|
await Task.Delay(3000);
|
|
|
|
|
|
splashWindow.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 模拟更新进度
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private async Task SimulateUpdateProgress(UpdateWindow updateWindow)
|
|
|
|
|
|
{
|
|
|
|
|
|
var stages = new[] { "下载", "验证", "安装", "清理" };
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var stage in stages)
|
|
|
|
|
|
{
|
|
|
|
|
|
updateWindow.Report(stage, $"正在{stage}...", Array.IndexOf(stages, stage) * 25 + 10);
|
|
|
|
|
|
await Task.Delay(800);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateWindow.ReportComplete(true, null);
|
|
|
|
|
|
|
|
|
|
|
|
// 2秒后关闭
|
|
|
|
|
|
await Task.Delay(2000);
|
|
|
|
|
|
updateWindow.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnClosed(EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 取消订阅事件
|
|
|
|
|
|
_viewModel.OpenSplashRequested -= OnOpenSplashRequested;
|
|
|
|
|
|
_viewModel.OpenErrorRequested -= OnOpenErrorRequested;
|
|
|
|
|
|
_viewModel.OpenUpdateRequested -= OnOpenUpdateRequested;
|
|
|
|
|
|
_viewModel.OpenOobeRequested -= OnOpenOobeRequested;
|
|
|
|
|
|
_viewModel.CloseRequested -= OnCloseRequested;
|
|
|
|
|
|
|
|
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|