2026-05-14 19:44:01 +08:00
|
|
|
using Avalonia;
|
2026-05-18 08:30:40 +08:00
|
|
|
using LanMountainDesktop.Services;
|
2026-05-14 19:44:01 +08:00
|
|
|
|
|
|
|
|
namespace LanMountainDesktop.AirAppHost;
|
|
|
|
|
|
|
|
|
|
internal static class Program
|
|
|
|
|
{
|
|
|
|
|
[STAThread]
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
2026-05-18 08:30:40 +08:00
|
|
|
AppLogger.Initialize();
|
|
|
|
|
AppDataPathProvider.Initialize(args);
|
|
|
|
|
RegisterGlobalExceptionLogging();
|
|
|
|
|
AppLogger.Info("AirAppHost", $"Starting. Args='{string.Join(" ", args)}'.");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
BuildAvaloniaApp()
|
|
|
|
|
.StartWithClassicDesktopLifetime(args);
|
|
|
|
|
AppLogger.Info("AirAppHost", "Exited normally.");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Critical("AirAppHost", "Unhandled startup exception.", ex);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2026-05-14 19:44:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static AppBuilder BuildAvaloniaApp()
|
|
|
|
|
{
|
|
|
|
|
return AppBuilder.Configure<AirApp>()
|
|
|
|
|
.UsePlatformDetect()
|
|
|
|
|
.WithInterFont()
|
|
|
|
|
.LogToTrace();
|
|
|
|
|
}
|
2026-05-18 08:30:40 +08:00
|
|
|
|
|
|
|
|
private static void RegisterGlobalExceptionLogging()
|
|
|
|
|
{
|
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Critical(
|
|
|
|
|
"AirAppHost",
|
|
|
|
|
"Unhandled AppDomain exception.",
|
|
|
|
|
e.ExceptionObject as Exception);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TaskScheduler.UnobservedTaskException += (_, e) =>
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Error("AirAppHost", "Unobserved task exception.", e.Exception);
|
|
|
|
|
e.SetObserved();
|
|
|
|
|
};
|
|
|
|
|
}
|
2026-05-14 19:44:01 +08:00
|
|
|
}
|