基于WebView2实现的Win11桌面框架,利用插件自定义
Moli
2026-07-29 cf40cded1708bb303be4a404b7aceddd196e1d46
src/Moli.Desktop/Runtime/RuntimeState.cs
@@ -1,6 +1,8 @@
using Moli.Desktop.Diagnostics;
using Moli.Desktop.Layout;
using Moli.Desktop.Plugins;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
namespace Moli.Desktop.Runtime;
@@ -42,6 +44,12 @@
{
    private readonly object _gate = new();
    private readonly List<Func<RuntimeEvent, Task>> _handlers = [];
    private readonly ILogger<RuntimeEventBus> _logger;
    public RuntimeEventBus(ILogger<RuntimeEventBus>? logger = null)
    {
        _logger = logger ?? NullLogger<RuntimeEventBus>.Instance;
    }
    public IDisposable Subscribe(Func<RuntimeEvent, Task> handler)
    {
@@ -61,6 +69,7 @@
    public async Task PublishAsync(RuntimeEvent runtimeEvent, CancellationToken cancellationToken = default)
    {
        _logger.LogDebug("Runtime event published: {EventName}", runtimeEvent.Name);
        Func<RuntimeEvent, Task>[] handlers;
        lock (_gate)
        {