English | 中文
🔌
ASP.NET Core
lightweight plugin framework | ASP.NET Core 轻量级 插件框架 - 一分钟集成 | Vue.js frontend | JavaScript SDK
🔌 ASP.NET Core
lightweight plugin framework | ASP.NET Core 轻量级 插件框架 - 一分钟集成 | Vue.js frontend | JavaScript SDK
wwwroot
folder, and then visit /plugins/pluginId/index.html
HTTP request pipeline middleware
at runtime through the plug-in, and there is no need to restart the siteSharpZipLib
for decompression)i18n
, it provides multi-language switching support关联线上产品:
- https://120365.xyz
- 在线工具集
- 数据分析可视化
- 时间管理
- 效率工具箱
Recommended Use NuGet, Execute the following commands in the root directory of your project. If you use Visual Studio, then click Tools -> NuGet Package Manager -> Package Manager Console, make sure "Default project" It is the item you want to install, enter the command below to install it.
PM> Install-Package PluginCore.AspNetCore
Modify the code in your ASP.NET Core application
Startup.cs
using PluginCore.AspNetCore.Extensions;
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
// 1. Add PluginCore
services.AddPluginCore();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
// 2. Use PluginCore
app.UsePluginCore();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
Now visit https://localhost:5001/PluginCore/Admin to enter PluginCore Admin https://localhost:5001 Need to be changed to your address
Please log in to PluginCore Admin
, and for safety, modify the default user name and password in time:
App_Data/PluginCore.Config.json
{
"Admin": {
"UserName": "admin",
"Password": "ABC12345"
},
"FrontendMode": "LocalEmbedded",
"RemoteFrontend": "https://cdn.jsdelivr.net/gh/yiyungent/plugincore-admin-frontend@0.1.2/dist-cdn"
}
After the modification, it will take effect immediately, no need to restart the site, you need to log in to PluginCore Admin
again
If you need to experience PluginCore locally, then here is an example(/examples)
docker run -d -p 5004:80 -e ASPNETCORE_URLS="http://*:80" --name plugincore-aspnetcore3-1 yiyungent/plugincore-aspnetcore3-1
Now you can visit http://localhost:5004/PluginCore/Admin
add:
If you useDocker Compose
, you can refer todocker-compose.yml
in the root directory of the warehouseadd:
Useghcr.io
docker run -d -p 5004:80 -e ASPNETCORE_URLS="http://*:80" --name plugincore-aspnetcore3-1 ghcr.io/yiyungent/plugincore-aspnetcore3-1
- For example, custom plug-in hook:
ITestPlugin
using PluginCore.IPlugins;
namespace PluginCore.IPlugins
{
public interface ITestPlugin : IPlugin
{
string Say();
}
}
- Apply the hook where it needs to be activated, so that all enabled plug-ins that implement
ITestPlugin
will callSay()
using PluginCore;
using PluginCore.IPlugins;
namespace WebApi.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class TestController : ControllerBase
{
private readonly PluginFinder _pluginFinder;
public TestController(PluginFinder pluginFinder)
{
_pluginFinder = pluginFinder;
}
public ActionResult Get()
{
//var plugins = PluginFinder.EnablePlugins<BasePlugin>().ToList();
// All enabled plugins that implement ITestPlugin
var plugins2 = _pluginFinder.EnablePlugins<ITestPlugin>().ToList();
foreach (var item in plugins2)
{
// transfer
string words = item.Say();
Console.WriteLine(words);
}
return Ok("");
}
}
}
PluginCore supports 3 front-end file loading methods
FrontendMode
in the configuration fileApp_Data/PluginCore.Config.json
LocalEmbedded
PluginCore
and recompile. It is not recommendedLocalFolder
PluginCore
, create a new PluginCoreAdmin
, and put the front-end files into this folderRemoteCDN
RemoteFrontend
in the configuration file注意:
更新FrontendMode
, 需重启站点后, 才能生效
补充
开发插件只需要, 添加对
PluginCore.IPlugins
包 (插件sdk) 的引用即可,当然如果你需要
PluginCore
, 也可以添加引用规范
- 插件sdk
插件接口应当位于
PluginCore.IPlugins
命名空间,这是规范,不强求,但建议这么做,程序集名不一定要与命名空间名相同,你完全在你的插件sdk程序集中,使用
PluginCore.IPlugins
命名空间。
- 插件
插件程序集名(一般=项目(Project)名) 与 插件
info.json
中PluginId
一致, 例如: Project:HelloWorldPlugin
, PluginId:HelloWorldPlugin
, 此项必须,否则插件无法加载PluginId
为插件唯一标识
自
PluginCore.IPlugins-v0.8.0
起,PluginCore
项目重构,PluginCore
只包含核心插件逻辑,ASP.NET Core
需要使用PluginCore.AspNetCore
PluginCore.IPlugins | 0.8.0 | 0.8.0 | 0.8.0 | 0.8.0 | 0.8.0 | 0.8.0 | 0.8.0 | 0.8.0 | 0.8.0 | 0.8.0 | 0.8.0 | 0.8.0 | 0.9.0 | 0.9.0 | 0.9.0 | 0.9.0 | 0.9.1 | 0.9.1 | 0.9.1 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PluginCore | 1.0.0 | 1.0.0 | 1.0.0 | 1.0.0 | 2.0.0 | 2.0.0 | 2.0.1 | 2.0.1 | 2.0.1 | 2.0.2 | 2.0.2 | 2.1.0 | 2.2.0 | 2.2.1 | 2.2.2 | 2.2.2 | 2.2.3 | 2.2.3 | 2.2.4 |
PluginCore.IPlugins.AspNetCore | 0.0.1 | 0.0.1 | 0.0.1 | 0.0.1 | 0.0.1 | 0.0.1 | 0.0.1 | 0.0.1 | 0.0.1 | 0.0.1 | 0.0.1 | 0.0.1 | 0.1.0 | 0.1.0 | 0.1.0 | 0.1.0 | 0.1.1 | 0.1.1 | 0.1.1 |
PluginCore.AspNetCore | 0.0.2 | 0.0.3 | 0.0.4 | 0.0.5 | 0.0.5 | 1.0.0 | 1.0.1 | 1.0.2 | 1.0.3 | 1.0.4 | 1.1.0 | 1.2.0 | 1.3.1 | 1.3.2 | 1.3.2 | 1.3.3 | 1.3.4 | 1.4.0 | 1.4.1 |
plugincore-admin-frontend | 0.1.0 - 0.3.1 | 0.1.0 - 0.3.1 | 0.1.0 - 0.3.1 | 0.1.0 - 0.3.1 | 0.1.0 - 0.3.1 | 0.1.0 - 0.3.1 | 0.1.0 - 0.3.1 | 0.3.2 | 0.3.2 | 0.3.2 | 0.3.2 | 0.3.2 | 0.3.2 | 0.3.2 | 0.3.2 | 0.3.2 | 0.3.2 | 0.3.2 | 0.3.2 |
plugincore-js-sdk | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 | 0.1.0 - 0.5.0 |
下方为旧版依赖, 仅作存档
PluginCore.IPlugins | 0.1.0 | 0.1.0 | 0.2.0 | 0.2.0 | 0.2.0 | 0.3.0 | 0.3.0 | 0.4.0 | 0.5.0 | 0.6.0 | 0.6.0 | 0.6.0 | 0.6.0 | 0.6.1 | 0.6.1 | 0.6.1 | 0.7.0 | 0.7.0 | 0.7.0 | 0.7.0 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PluginCore | 0.1.0 | 0.2.0 | 0.3.0 | 0.3.1 | 0.4.0 | 0.5.0 | 0.5.1 | 0.6.0 | 0.7.0 | 0.8.0 | 0.8.1 | 0.8.2 | 0.8.3 | 0.8.4 | 0.8.5 | 0.8.6 | 0.9.0 | 0.9.1 | 0.9.2 | 0.9.3 |
plugincore-admin-frontend | 0.1.0 | 0.1.2 | 0.1.2 | 0.1.3 | 0.1.3 | 0.2.0 | 0.2.0 | 0.2.0 | 0.2.0 | 0.2.0 | 0.2.3 | 0.2.3 | 0.2.3 | 0.2.3 | 0.3.0 | 0.3.0 | 0.3.0 | 0.3.0 | 0.3.0 | 0.3.1 |
plugincore-js-sdk | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | 0.1.0 | 0.1.0 | 0.1.0 | 0.1.0 |
PluginCore.IPlugins | ||
---|---|---|
PluginCore | ||
PluginCore.IPlugins.AspNetCore | ||
PluginCore.AspNetCore | ||
PluginCore.Template | ||
plugincore-admin-frontend | ||
plugincore-js-sdk |
graph BT
iplugins_aspnetcore(PluginCore.IPlugins.AspNetCore) --> iplugins(PluginCore.IPlugins)
aspnetcore(PluginCore.AspNetCore) --> iplugins_aspnetcore
plugincore(PluginCore) --> iplugins
aspnetcore(PluginCore.AspNetCore) --> plugincore
admin_frontend(plugincore-admin-frontend) --> aspnetcore
jssdk(plugincore-js-sdk) --> aspnetcore
ReSharper 是一个强大的 Visual Studio 扩展,适用于 .NET 平台语言。
特别感谢 JetBrains 为开源项目提供免费的 ReSharper 等的授权
本列表由 afdian-action 自动更新
感谢这些来自爱发电的赞助者:
PluginCore is an GNU LGPLv3 licensed open source project and completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.
We accept donations through these channels:
PluginCore © yiyun, Released under the GNU LGPLv3 License.
Authored and maintained by yiyun with help from contributors (list).
GitHub @yiyungent Gitee @yiyungent