using Avalonia; using Avalonia_PC.Views; using Avalonia_Services.Services; using Microsoft.Extensions.DependencyInjection; using System; namespace Avalonia_PC { internal sealed class Program { public static IServiceProvider Services { get; private set; } = null!; // Initialization code. Don't use any Avalonia, third-party APIs or any // SynchronizationContext-reliant code before AppMain is called: things aren't initialized // yet and stuff might break. [STAThread] public static void Main(string[] args) { ConfigureServices(); #if DEBUG // 开启 WebView2 远程调试,启动后在 Edge 中访问 edge://inspect 调试网页 Environment.SetEnvironmentVariable( "WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--remote-debugging-port=9222 --auto-open-devtools-for-tabs"); #endif BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); } private static void ConfigureServices() { var services = new ServiceCollection(); services.AddSingleton(); services.AddTransient(sp => new MainWindow(sp)); Services = services.BuildServiceProvider(); } // Avalonia configuration, don't remove; also used by visual designer. public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() .UsePlatformDetect() #if DEBUG .WithDeveloperTools() #endif .WithInterFont() .LogToTrace(); } }