using Avalonia; using Avalonia.Styling; using FluentAvalonia.Styling; namespace LanMountainDesktop.Launcher.Shell; /// /// 主题服务,管理启动器的主题设置 /// public static class ThemeService { private static ThemeVariant _currentTheme = ThemeVariant.Light; private static string _accentColor = "#0078D4"; /// /// 获取当前主题 /// public static ThemeVariant CurrentTheme => _currentTheme; /// /// 获取当前主题色 /// public static string AccentColor => _accentColor; /// /// 应用主题设置 /// public static void ApplyTheme(ThemeMode mode, string accentColor) { _currentTheme = mode switch { ThemeMode.Dark => ThemeVariant.Dark, _ => ThemeVariant.Light }; _accentColor = accentColor; // 应用到当前应用程序 if (Application.Current is { } app) { app.RequestedThemeVariant = _currentTheme; } } /// /// 应用浅色主题 /// public static void ApplyLightTheme(string accentColor) { ApplyTheme(ThemeMode.Light, accentColor); } /// /// 应用深色主题 /// public static void ApplyDarkTheme(string accentColor) { ApplyTheme(ThemeMode.Dark, accentColor); } } /// /// 主题模式 /// public enum ThemeMode { Light, Dark }