Files
personal-toolbox/PersonalToolBox/Models/ToolItem.cs
home-PC e126184973 工具路径为exe时默认显示exe自身图标
ToolItem新增IsExePath计算属性,ExePathToIconConverter通过Icon.ExtractAssociatedIcon提取exe图标并缓存,卡片模板图标区改为三层优先级:FontAwesome > exe图标 > 首字母
2026-05-10 14:26:55 +08:00

74 lines
2.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Text.Json.Serialization;
namespace PersonalToolBox.Models;
/// <summary>
/// 工具项模型,表示用户添加的一个可执行工具
/// </summary>
public class ToolItem
{
/// <summary>
/// 工具唯一标识 (UUID)
/// </summary>
public string Id { get; set; } = Guid.NewGuid().ToString();
/// <summary>
/// 工具显示名称
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// 内置图标库的图标枚举名称(如 "Github", "Wrench"),用于 FontAwesome 图标渲染
/// </summary>
public string IconCode { get; set; } = string.Empty;
/// <summary>
/// 可执行文件路径或 URL
/// </summary>
public string ExecutablePath { get; set; } = string.Empty;
/// <summary>
/// 运行参数(选填)
/// </summary>
public string Arguments { get; set; } = string.Empty;
/// <summary>
/// 所属分类 ID
/// </summary>
public string CategoryId { get; set; } = string.Empty;
/// <summary>
/// 全局快捷键(如 Ctrl+Alt+T选填
/// </summary>
public string HotKey { get; set; } = string.Empty;
/// <summary>
/// 路径是否有效(仅运行时计算,不存入 JSON
/// </summary>
[JsonIgnore]
public bool IsValid { get; set; } = true;
/// <summary>
/// 是否为组合卡片(一键多开)
/// </summary>
public bool IsGroup { get; set; }
/// <summary>
/// 当 IsGroup 为 true 时,存储需批量启动的子工具 ID 列表
/// </summary>
public List<string> SubToolIds { get; set; } = new();
/// <summary>
/// 是否在软件启动时自动运行
/// </summary>
public bool AutoRunOnStart { get; set; }
/// <summary>
/// 路径是否指向 .exe 文件(仅运行时判断,不存入 JSON
/// </summary>
[JsonIgnore]
public bool IsExePath =>
!IsGroup && !string.IsNullOrWhiteSpace(ExecutablePath) &&
ExecutablePath.EndsWith(".exe", StringComparison.OrdinalIgnoreCase);
}