mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 23:54:26 +08:00
Introduce a new LanMountainDesktop.Shared.IPC project implementing a public IPC host and client (LanMountainDesktopIpcClient, PublicIpcHostService), IPC constants and routed notify IDs, DTOs and DI helpers for registering public services. Update Plugin SDK to allow plugins to contribute public IPC services and registrations, add related descriptors/records and extension helpers. Migrate Launcher/App to use the new public IPC for startup/loading notifications and wiring (including TryConnect helper), switch LoadingStateReporter to use the external notification publisher, and add host-side public services (app info, shell control, plugin catalog). Include integration tests and spec/checklist/docs for the external IPC public API.
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using Avalonia;
|
|
using Avalonia.Threading;
|
|
using LanMountainDesktop.PluginSdk;
|
|
using LanMountainDesktop.Shared.IPC.Abstractions.Services;
|
|
|
|
namespace LanMountainDesktop.Services.ExternalIpc;
|
|
|
|
internal sealed class PublicShellControlService : IPublicShellControlService
|
|
{
|
|
public Task<bool> ActivateMainWindowAsync()
|
|
{
|
|
return Dispatcher.UIThread.InvokeAsync(() =>
|
|
{
|
|
return (Application.Current as App)?.TryActivateMainWindowFromExternalIpc("PublicIpc") == true;
|
|
}).GetTask();
|
|
}
|
|
|
|
public Task<bool> OpenSettingsAsync(string? pageTag = null)
|
|
{
|
|
return Dispatcher.UIThread.InvokeAsync(() =>
|
|
{
|
|
if (Application.Current is not App app)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
app.OpenIndependentSettingsModule("PublicIpc", pageTag);
|
|
return true;
|
|
}).GetTask();
|
|
}
|
|
|
|
public Task<bool> RestartAsync()
|
|
{
|
|
var lifecycle = App.CurrentHostApplicationLifecycle;
|
|
return Task.FromResult(lifecycle?.TryRestart(new HostApplicationLifecycleRequest(
|
|
Source: "PublicIpc",
|
|
Reason: "External IPC requested restart.")) == true);
|
|
}
|
|
|
|
public Task<bool> ExitAsync()
|
|
{
|
|
var lifecycle = App.CurrentHostApplicationLifecycle;
|
|
return Task.FromResult(lifecycle?.TryExit(new HostApplicationLifecycleRequest(
|
|
Source: "PublicIpc",
|
|
Reason: "External IPC requested exit.")) == true);
|
|
}
|
|
}
|