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 @@
-
+
diff --git a/Ink Canvas/Windows/PluginSettingsWindow.xaml.cs b/Ink Canvas/Windows/PluginSettingsWindow.xaml.cs
index ec667215..55b2b927 100644
--- a/Ink Canvas/Windows/PluginSettingsWindow.xaml.cs
+++ b/Ink Canvas/Windows/PluginSettingsWindow.xaml.cs
@@ -120,6 +120,8 @@ namespace Ink_Canvas.Windows
{
Plugins.Clear();
+ LogHelper.WriteLogToFile($"开始加载插件列表到UI,插件总数: {PluginManager.Instance.Plugins.Count}", LogHelper.LogType.Info);
+
// 添加所有已加载的插件
foreach (var plugin in PluginManager.Instance.Plugins)
{
@@ -131,6 +133,10 @@ namespace Ink_Canvas.Windows
isEnabled = pluginBase.IsEnabled;
}
+ // 记录插件详细信息
+ LogHelper.WriteLogToFile($"正在加载插件到UI: 类型={plugin.GetType().FullName}, 名称={plugin.Name ?? "未命名"}, 状态={isEnabled}",
+ LogHelper.LogType.Info);
+
// 创建视图模型并添加到集合
var viewModel = new PluginViewModel(plugin)
{
@@ -142,13 +148,19 @@ namespace Ink_Canvas.Windows
}
// 绑定到ListView
+ LogHelper.WriteLogToFile($"绑定 {Plugins.Count} 个插件到ListView", LogHelper.LogType.Info);
PluginListView.ItemsSource = Plugins;
// 如果有插件,选择第一个
if (Plugins.Count > 0)
{
+ LogHelper.WriteLogToFile($"选择第一个插件: {Plugins[0].Name}", LogHelper.LogType.Info);
PluginListView.SelectedIndex = 0;
}
+ else
+ {
+ LogHelper.WriteLogToFile("没有找到任何插件", LogHelper.LogType.Warning);
+ }
}
///
@@ -624,7 +636,15 @@ namespace Ink_Canvas.Windows
///
/// 插件名称
///
- public string Name => Plugin.Name;
+ public string Name
+ {
+ get
+ {
+ string name = Plugin?.Name ?? "未命名插件";
+ LogHelper.WriteLogToFile($"获取插件名称: {name},类型: {Plugin?.GetType().FullName ?? "未知"}", LogHelper.LogType.Info);
+ return name;
+ }
+ }
///
/// 插件是否启用
@@ -650,6 +670,9 @@ namespace Ink_Canvas.Windows
// 获取实际状态
_isEnabled = plugin is PluginBase pluginBase && pluginBase.IsEnabled;
+ // 记录日志
+ LogHelper.WriteLogToFile($"创建插件视图模型: {plugin?.GetType().FullName ?? "未知"}, 名称: {plugin?.Name ?? "未命名"}", LogHelper.LogType.Info);
+
// 注册插件状态变更事件
if (plugin is PluginBase pb)
{