changed.调整融合桌面组库的相关圆角

This commit is contained in:
lincube
2026-05-25 09:32:58 +08:00
parent 69bcf2c6eb
commit 01cf32a610
5 changed files with 59 additions and 3 deletions

View File

@@ -107,4 +107,18 @@ public sealed class ComponentCategoryIconResolverTests
var result = ComponentCategoryIconResolver.ResolveCategoryIcon("File", components);
Assert.Equal(Icon.Folder, result);
}
[Fact]
public void ResolveCategoryIcon_Date_ResolvesCorrectly()
{
var result = ComponentCategoryIconResolver.ResolveCategoryIcon("Date", []);
Assert.Equal(Icon.Calendar, result);
}
[Fact]
public void ResolveCategoryIcon_Study_ResolvesCorrectly()
{
var result = ComponentCategoryIconResolver.ResolveCategoryIcon("Study", []);
Assert.Equal(Icon.Book, result);
}
}

View File

@@ -14,15 +14,34 @@ public static class ComponentCategoryIconResolver
return Icon.Apps;
}
var icon = categoryId.ToLowerInvariant() switch
{
"clock" => Icon.Clock,
"date" => Icon.Calendar,
"weather" => Icon.WeatherSunny,
"board" => Icon.Edit,
"media" => Icon.Play,
"info" => Icon.News,
"calculator" => Icon.Calculator,
"study" => Icon.Book,
"file" => Icon.Folder,
_ => (Icon?)null
};
if (icon.HasValue)
{
return icon.Value;
}
var firstComponent = categoryComponents.FirstOrDefault();
if (firstComponent is null || string.IsNullOrWhiteSpace(firstComponent.IconKey))
{
return Icon.Apps;
}
if (Enum.TryParse<Icon>(firstComponent.IconKey, ignoreCase: true, out var icon))
if (Enum.TryParse<Icon>(firstComponent.IconKey, ignoreCase: true, out var resolvedIcon))
{
return icon;
return resolvedIcon;
}
return Icon.Apps;

View File

@@ -54,7 +54,7 @@
Background="{DynamicResource AdaptiveNavItemBackgroundBrush}">
<Grid ColumnDefinitions="Auto,*"
ColumnSpacing="8">
<fi:SymbolIcon Symbol="{Binding Icon}"
<fi:FluentIcon Icon="{Binding Icon}"
IconVariant="Regular"
FontSize="16" />
<TextBlock Grid.Column="1"

View File

@@ -23,6 +23,7 @@
HorizontalAlignment="Center"
VerticalAlignment="Center"
Padding="0"
CornerRadius="{DynamicResource DesignCornerRadiusLg}"
ClipToBounds="True">
<Grid RowDefinitions="Auto,*,Auto">
<Border Height="64"

View File

@@ -4,7 +4,9 @@ using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Input;
using Avalonia.Interactivity;
using LanMountainDesktop.Appearance;
using LanMountainDesktop.Services;
using LanMountainDesktop.Settings.Core;
namespace LanMountainDesktop.Views;
@@ -15,6 +17,7 @@ public partial class FusedDesktopComponentLibraryWindow : Window
public FusedDesktopComponentLibraryWindow()
{
InitializeComponent();
ApplyFluentCornerRadius();
LibraryControl.AddComponentRequested += OnAddComponentRequested;
KeyDown += OnWindowKeyDown;
@@ -23,6 +26,25 @@ public partial class FusedDesktopComponentLibraryWindow : Window
mainWindow?.RegisterFusedLibraryWindow(this);
}
private void ApplyFluentCornerRadius()
{
if (RootGrid is null)
{
return;
}
var tokens = AppearanceCornerRadiusTokenFactory.Create(
GlobalAppearanceSettings.CornerRadiusStyleFluent);
RootGrid.Resources["DesignCornerRadiusMicro"] = tokens.Micro;
RootGrid.Resources["DesignCornerRadiusXs"] = tokens.Xs;
RootGrid.Resources["DesignCornerRadiusSm"] = tokens.Sm;
RootGrid.Resources["DesignCornerRadiusMd"] = tokens.Md;
RootGrid.Resources["DesignCornerRadiusLg"] = tokens.Lg;
RootGrid.Resources["DesignCornerRadiusXl"] = tokens.Xl;
RootGrid.Resources["DesignCornerRadiusIsland"] = tokens.Island;
RootGrid.Resources["DesignCornerRadiusComponent"] = tokens.Component;
}
public bool PreserveEditModeOnClose { get; private set; }
public void SetOverlayWindow(TransparentOverlayWindow overlayWindow)