From 01cf32a610b8ba1b5d6eaca7666a9c93f86310bf Mon Sep 17 00:00:00 2001 From: lincube Date: Mon, 25 May 2026 09:32:58 +0800 Subject: [PATCH] =?UTF-8?q?changed.=E8=B0=83=E6=95=B4=E8=9E=8D=E5=90=88?= =?UTF-8?q?=E6=A1=8C=E9=9D=A2=E7=BB=84=E5=BA=93=E7=9A=84=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=9C=86=E8=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComponentCategoryIconResolverTests.cs | 14 +++++++++++ .../ComponentCategoryIconResolver.cs | 23 +++++++++++++++++-- .../Views/ComponentLibraryWindow.axaml | 2 +- .../FusedDesktopComponentLibraryWindow.axaml | 1 + ...usedDesktopComponentLibraryWindow.axaml.cs | 22 ++++++++++++++++++ 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/LanMountainDesktop.Tests/ComponentCategoryIconResolverTests.cs b/LanMountainDesktop.Tests/ComponentCategoryIconResolverTests.cs index d6fa02f..643103c 100644 --- a/LanMountainDesktop.Tests/ComponentCategoryIconResolverTests.cs +++ b/LanMountainDesktop.Tests/ComponentCategoryIconResolverTests.cs @@ -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); + } } diff --git a/LanMountainDesktop/ComponentSystem/ComponentCategoryIconResolver.cs b/LanMountainDesktop/ComponentSystem/ComponentCategoryIconResolver.cs index 1c85e44..78e4f69 100644 --- a/LanMountainDesktop/ComponentSystem/ComponentCategoryIconResolver.cs +++ b/LanMountainDesktop/ComponentSystem/ComponentCategoryIconResolver.cs @@ -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(firstComponent.IconKey, ignoreCase: true, out var icon)) + if (Enum.TryParse(firstComponent.IconKey, ignoreCase: true, out var resolvedIcon)) { - return icon; + return resolvedIcon; } return Icon.Apps; diff --git a/LanMountainDesktop/Views/ComponentLibraryWindow.axaml b/LanMountainDesktop/Views/ComponentLibraryWindow.axaml index 6589f1f..46519e9 100644 --- a/LanMountainDesktop/Views/ComponentLibraryWindow.axaml +++ b/LanMountainDesktop/Views/ComponentLibraryWindow.axaml @@ -54,7 +54,7 @@ Background="{DynamicResource AdaptiveNavItemBackgroundBrush}"> -