Phase 1: data models and local storage service
- Add Models: Category, ToolItem (IsValid runtime-only, not stored), AppConfig - Add Services: IDataService + JsonDataService (JSON load/save) - Path validation on Load(): File.Exists check, logs warning for missing paths - Startup: auto-calls dataService.Load() to load config
This commit is contained in:
50
PersonalToolBox/Models/ToolItem.cs
Normal file
50
PersonalToolBox/Models/ToolItem.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
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>
|
||||
/// 内置图标库的字符编码
|
||||
/// </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;
|
||||
}
|
||||
Reference in New Issue
Block a user