Phase 0: 项目初始化与基础架构
- 创建 .NET 8 WPF 项目 PersonalToolBox - 引入 NuGet 包: CommunityToolkit.Mvvm, System.Text.Json, Microsoft.Extensions.DependencyInjection - 建立 MVVM 目录结构: Models/ ViewModels/ Views/ Services/ Helpers/ - 实现 LogEntry 模型 (时间/日志级别/内容) - 实现 ILogService 接口与 LogService (线程安全, 通过 Dispatcher 推送到 UI) - 配置 DI 容器 (App.xaml.cs) 注册日志服务和主窗口 - 添加 .gitignore 文件
This commit is contained in:
35
PersonalToolBox/Services/ILogService.cs
Normal file
35
PersonalToolBox/Services/ILogService.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using PersonalToolBox.Models;
|
||||
|
||||
namespace PersonalToolBox.Services;
|
||||
|
||||
/// <summary>
|
||||
/// 日志服务接口,管理底部日志打印栏的数据
|
||||
/// </summary>
|
||||
public interface ILogService
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志条目集合,绑定到 UI 的 ObservableCollection
|
||||
/// </summary>
|
||||
ObservableCollection<LogEntry> Logs { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 记录普通信息日志
|
||||
/// </summary>
|
||||
void Info(string message);
|
||||
|
||||
/// <summary>
|
||||
/// 记录警告日志
|
||||
/// </summary>
|
||||
void Warning(string message);
|
||||
|
||||
/// <summary>
|
||||
/// 记录错误日志
|
||||
/// </summary>
|
||||
void Error(string message);
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有日志
|
||||
/// </summary>
|
||||
void Clear();
|
||||
}
|
||||
Reference in New Issue
Block a user