40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace MAF1.Plugins;
|
|
|
|
/// <summary>Plugins:Directory 相对网页 exe,不是源码树里的 plugins/ 文件夹。</summary>
|
|
public sealed class PluginOptions
|
|
{
|
|
public string Directory { get; set; } = "plugins";
|
|
public int DefaultTimeoutSeconds { get; set; } = 180;
|
|
|
|
public string ResolveRoot()
|
|
{
|
|
if (Path.IsPathRooted(Directory))
|
|
{
|
|
return Directory;
|
|
}
|
|
|
|
return Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, Directory));
|
|
}
|
|
|
|
public static PluginOptions Load(IConfiguration config)
|
|
=> config.GetSection("Plugins").Get<PluginOptions>() ?? new PluginOptions();
|
|
}
|
|
|
|
/// <summary>扫描成功后的一个插件:目录 + 已解析的 plugin.json。</summary>
|
|
public sealed class LoadedPlugin
|
|
{
|
|
public required string FolderName { get; init; }
|
|
public required string FolderPath { get; init; }
|
|
public required PluginContract.PluginManifest Manifest { get; init; }
|
|
}
|
|
|
|
/// <summary>扫描问题,前端左侧「扫描说明」会显示。error 的插件不会进画布。</summary>
|
|
public sealed class CatalogIssue
|
|
{
|
|
public string Level { get; init; } = "error";
|
|
public string Source { get; init; } = "";
|
|
public string Message { get; init; } = "";
|
|
}
|