891128fec3
- P1b: 点击通知切回 Windows Terminal 原标签(源生成 COM UIAutomation,AOT 友好) - Toast 设为工具窗口(WS_EX_TOOLWINDOW),从任务栏与 Alt+Tab 隐藏 - 投递改为落盘队列 spool + FileSystemWatcher,CLI 毫秒级返回不阻塞 Claude Code - 移除命名管道(PipeServer/PipeClient/PipeMessage),新增 NotificationSpool/SpoolWatcher - NativeAOT 发布配置 + scripts/build.bat(vcvars 自动配置 MSVC 工具链) - .gitattributes 保证 .bat 用 CRLF
44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using System;
|
|
using System.IO;
|
|
|
|
namespace Notify.Ipc;
|
|
|
|
/// <summary>
|
|
/// Host 侧:监视 spool 目录,新文件出现即消费并回调
|
|
/// </summary>
|
|
public sealed class SpoolWatcher
|
|
{
|
|
private readonly Action<NotifyMessage> _onMessage;
|
|
private FileSystemWatcher? _watcher;
|
|
|
|
public SpoolWatcher(Action<NotifyMessage> onMessage) => _onMessage = onMessage;
|
|
|
|
public void Start()
|
|
{
|
|
Directory.CreateDirectory(NotificationSpool.Dir);
|
|
|
|
// 先补弹启动前堆积的请求
|
|
NotificationSpool.DrainExisting(_onMessage);
|
|
|
|
_watcher = new FileSystemWatcher(NotificationSpool.Dir, "*.json")
|
|
{
|
|
NotifyFilter = NotifyFilters.FileName,
|
|
EnableRaisingEvents = true,
|
|
};
|
|
_watcher.Created += OnCreated;
|
|
_watcher.Renamed += OnRenamed;
|
|
}
|
|
|
|
private void OnCreated(object sender, FileSystemEventArgs e) => Handle(e.FullPath);
|
|
|
|
private void OnRenamed(object sender, RenamedEventArgs e) => Handle(e.FullPath);
|
|
|
|
private void Handle(string path)
|
|
{
|
|
if (NotificationSpool.ReadAndRemove(path) is { } msg)
|
|
{
|
|
_onMessage(msg);
|
|
}
|
|
}
|
|
}
|