mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-22 00:54:26 +08:00
Add launcher debug settings, recovery & version fixes
Introduce a persistent LauncherDebugSettingsStore and wire it into ErrorWindow and SplashWindow so dev-mode and custom host path can be saved/loaded. Harden DeploymentLocator/FlexibleHostLocator to safely normalize and validate saved debug paths and log warnings for malformed values. Add a WaitingForShell startup state and recoverable-activation logic across App and LauncherFlowCoordinator (with registry updates) so Launcher can attach to an in-progress desktop shell rather than failing. Clean up ErrorDebugWindow UI/flow (WasAccepted flag, localization fixes, event wiring) and improve splash version population. Improve AppVersionProvider to trim surrounding quotes, robustly parse version.json via JsonDocument and read string properties; add unit tests for AppVersionProvider, DeploymentLocator and LauncherDebugSettingsStore. Also quote Exec commands in the csproj and harden scripts/Generate-VersionFile.ps1 (argument normalization, LiteralPath, error handling).
This commit is contained in:
@@ -185,17 +185,23 @@ public partial class ErrorWindow : Window
|
||||
|
||||
debugWindow.Closed += (_, _) =>
|
||||
{
|
||||
if (!debugWindow.WasAccepted)
|
||||
{
|
||||
_isDebugMode = false;
|
||||
_iconClickCount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
_devModeEnabled = debugWindow.IsDevModeEnabled;
|
||||
_customHostPath = debugWindow.SelectedHostPath;
|
||||
SaveDevModeStateInternal(_devModeEnabled);
|
||||
SaveCustomHostPathInternal(_customHostPath);
|
||||
|
||||
if (_devModeEnabled && string.IsNullOrWhiteSpace(_customHostPath))
|
||||
{
|
||||
ScanDevPaths();
|
||||
SaveCustomHostPathInternal(_customHostPath);
|
||||
}
|
||||
|
||||
LauncherDebugSettingsStore.Save(new LauncherDebugSettings(_devModeEnabled, _customHostPath));
|
||||
|
||||
_isDebugMode = false;
|
||||
_iconClickCount = 0;
|
||||
};
|
||||
@@ -285,74 +291,17 @@ public partial class ErrorWindow : Window
|
||||
|
||||
private static string GetConfigBaseDirectory()
|
||||
{
|
||||
var appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
if (!string.IsNullOrWhiteSpace(appData))
|
||||
{
|
||||
return Path.Combine(appData, "LanMountainDesktop", ".launcher");
|
||||
}
|
||||
|
||||
return Path.Combine(AppContext.BaseDirectory, ".launcher");
|
||||
return LauncherDebugSettingsStore.ConfigBaseDirectory;
|
||||
}
|
||||
|
||||
private static string GetDevModePath() => Path.Combine(GetConfigBaseDirectory(), "dev-mode.flag");
|
||||
|
||||
private static string GetCustomHostPathFile() => Path.Combine(GetConfigBaseDirectory(), "custom-host-path.txt");
|
||||
|
||||
private static bool LoadDevModeStateInternal()
|
||||
{
|
||||
try
|
||||
{
|
||||
return File.Exists(GetDevModePath()) &&
|
||||
bool.TryParse(File.ReadAllText(GetDevModePath()).Trim(), out var enabled) &&
|
||||
enabled;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveDevModeStateInternal(bool enabled)
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(GetConfigBaseDirectory());
|
||||
File.WriteAllText(GetDevModePath(), enabled.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return LauncherDebugSettingsStore.IsDevModeEnabled();
|
||||
}
|
||||
|
||||
private static string? LoadCustomHostPathInternal()
|
||||
{
|
||||
try
|
||||
{
|
||||
var pathFile = GetCustomHostPathFile();
|
||||
if (!File.Exists(pathFile))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var savedPath = File.ReadAllText(pathFile).Trim();
|
||||
return string.IsNullOrWhiteSpace(savedPath) ? null : savedPath;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveCustomHostPathInternal(string? customHostPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(GetConfigBaseDirectory());
|
||||
File.WriteAllText(GetCustomHostPathFile(), customHostPath ?? string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return LauncherDebugSettingsStore.GetSavedCustomHostPath();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user