From 87ffa48265e48e9659e0b75d15513df1a2b9e802 Mon Sep 17 00:00:00 2001 From: unknown <2564608840@qq.com> Date: Wed, 16 Jul 2025 14:02:54 +0800 Subject: [PATCH] =?UTF-8?q?improve:=E6=8F=92=E4=BB=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BuiltIn/SuperLauncher/LauncherModels.cs | 26 +++++++++++++++++++ .../Plugins/BuiltIn/SuperLauncherPlugin.cs | 2 +- Ink Canvas/Helpers/Plugins/PluginBase.cs | 17 ++++++++++++ Ink Canvas/Windows/PluginSettingsWindow.xaml | 7 ++--- .../Windows/PluginSettingsWindow.xaml.cs | 25 +++++++++++++++++- 5 files changed, 72 insertions(+), 5 deletions(-) diff --git a/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherModels.cs b/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherModels.cs index 9749f8dc..51e52ef6 100644 --- a/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherModels.cs +++ b/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherModels.cs @@ -163,6 +163,32 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher // 对于资源管理器,使用特定图标 if (Path.EndsWith("explorer.exe", StringComparison.OrdinalIgnoreCase)) { + try + { + // 直接从C:\Windows\explorer.exe获取图标 + string explorerPath = @"C:\Windows\explorer.exe"; + if (File.Exists(explorerPath)) + { + Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(explorerPath); + if (icon != null) + { + _iconCache = Imaging.CreateBitmapSourceFromHIcon( + icon.Handle, + Int32Rect.Empty, + BitmapSizeOptions.FromEmptyOptions()); + + icon.Dispose(); + return _iconCache; + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"获取资源管理器图标时出错: {ex.Message}", LogHelper.LogType.Warning); + // 如果获取Windows图标失败,回退到默认图标 + } + + // 回退到备用图标 string explorerIconPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "Icons-Fluent", "ic_fluent_folder_24_regular.png"); if (File.Exists(explorerIconPath)) { diff --git a/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncherPlugin.cs b/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncherPlugin.cs index 20cc2972..7a8a6d6c 100644 --- a/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncherPlugin.cs +++ b/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncherPlugin.cs @@ -272,7 +272,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn new LauncherItem { Name = "资源管理器", - Path = "explorer.exe", + Path = @"C:\Windows\explorer.exe", IsVisible = true, Position = 0 } diff --git a/Ink Canvas/Helpers/Plugins/PluginBase.cs b/Ink Canvas/Helpers/Plugins/PluginBase.cs index 6fee53ab..3a0010f1 100644 --- a/Ink Canvas/Helpers/Plugins/PluginBase.cs +++ b/Ink Canvas/Helpers/Plugins/PluginBase.cs @@ -75,6 +75,23 @@ namespace Ink_Canvas.Helpers.Plugins public virtual void Initialize() { Id = GetType().FullName; + + // 添加日志,记录插件名称 + try + { + string name = Name; + LogHelper.WriteLogToFile($"初始化插件: ID={Id}, 名称={name ?? "未命名"}", LogHelper.LogType.Info); + + if (string.IsNullOrEmpty(name)) + { + LogHelper.WriteLogToFile($"警告: 插件 {Id} 的名称为空", LogHelper.LogType.Warning); + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"获取插件名称时出错: {ex.Message}", LogHelper.LogType.Error); + } + LogHelper.WriteLogToFile($"插件 {Name} 已初始化", LogHelper.LogType.Info); } diff --git a/Ink Canvas/Windows/PluginSettingsWindow.xaml b/Ink Canvas/Windows/PluginSettingsWindow.xaml index 05b4ed4c..d9ed9067 100644 --- a/Ink Canvas/Windows/PluginSettingsWindow.xaml +++ b/Ink Canvas/Windows/PluginSettingsWindow.xaml @@ -65,7 +65,8 @@ - + @@ -141,11 +142,11 @@