mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-22 09:14:25 +08:00
宿主侧插件运行时
中文
本目录保存阑山桌面宿主程序中的插件运行时实现。
主要职责
- 发现已安装插件
- 安装和替换
.laapp插件包 - 加载插件程序集
- 接入插件贡献的设置页和桌面组件
- 在宿主设置界面中展示插件与市场信息
市场安装优先级
- 宿主先连接
LanAirApp/airappmarket/index.json。 - 当条目同时提供
releaseTag和releaseAssetName时,宿主优先按精确标签读取插件仓库的 GitHub Release 资产。 - 如果 Release 不存在、资产缺失、GitHub API 失败,或当前是本地工作区测试但找不到远程资产,宿主会退回
downloadUrl指向的仓库根目录.laapp。 - 插件介绍始终读取仓库根目录
README.md。 - 安装完成后只做暂存,重启后生效,不在运行时热重载市场安装插件。
核心文件
PluginLoader.csPluginLoadContext.csPluginRuntimeService.csPluginCatalogEntry.csPluginMarketIndexService.csPluginMarketInstallService.cs
与 LanAirApp 的分工
LanAirApp负责插件开发文档、示例、市场索引和校验工具。- 宿主目录负责运行时发现、安装、加载和界面接入。
English
This directory contains the host-side plugin runtime for LanMountainDesktop.
Responsibilities
- discover installed plugins
- install and replace
.laapppackages - load plugin assemblies
- integrate plugin settings pages and desktop components
- expose market and plugin management in the host UI
- build a plugin-scoped
IServiceCollection/ServiceProviderfor API2.0.0plugins - resolve shared contract assemblies into a version-isolated cache before plugin activation
- expose explicit cross-plugin exports through
IPluginExportRegistry
Market install order
- The host reads
LanAirApp/airappmarket/index.json. - If an entry declares both
releaseTagandreleaseAssetName, the host first resolves the exact GitHub Release asset. - If Release resolution fails, the host falls back to the repository root
.laappfromdownloadUrl. - Plugin details always come from the repository root
README.md. - Market installs are staged and take effect after restart.
Dependency model
- Plugin-private managed and native NuGet dependencies remain plugin-local and are resolved through
AssemblyDependencyResolver. - Shared contract assemblies are downloaded from the official market index, cached under
LocalAppData/LanMountainDesktop/SharedContracts/<id>/<version>/, and loaded into the default context so host and plugins share the same contract types. - Different contract versions are isolated on disk. If two active plugins request incompatible versions of the same shared assembly name in one process, the host fails the later activation with a clear error instead of loading an ambiguous contract.