Files
LanMountainDesktop/LanMountainDesktop.Launcher/Services/ThemeService.cs
lincube 5b4b9f32b5 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.
2026-04-25 17:29:25 +08:00

69 lines
1.5 KiB
C#

using Avalonia;
using Avalonia.Styling;
using FluentAvalonia.Styling;
namespace LanMountainDesktop.Launcher.Services;
/// <summary>
/// 主题服务,管理启动器的主题设置
/// </summary>
public static class ThemeService
{
private static ThemeVariant _currentTheme = ThemeVariant.Light;
private static string _accentColor = "#0078D4";
/// <summary>
/// 获取当前主题
/// </summary>
public static ThemeVariant CurrentTheme => _currentTheme;
/// <summary>
/// 获取当前主题色
/// </summary>
public static string AccentColor => _accentColor;
/// <summary>
/// 应用主题设置
/// </summary>
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;
}
}
/// <summary>
/// 应用浅色主题
/// </summary>
public static void ApplyLightTheme(string accentColor)
{
ApplyTheme(ThemeMode.Light, accentColor);
}
/// <summary>
/// 应用深色主题
/// </summary>
public static void ApplyDarkTheme(string accentColor)
{
ApplyTheme(ThemeMode.Dark, accentColor);
}
}
/// <summary>
/// 主题模式
/// </summary>
public enum ThemeMode
{
Light,
Dark
}