• Stars
    star
    406
  • Rank 106,421 (Top 3 %)
  • Language
    C#
  • License
    GNU Lesser Genera...
  • Created over 3 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🔌 ASP.NET Core lightweight plugin framework | ASP.NET Core 轻量级 插件框架 - 一分钟集成 | Vue.js frontend | JavaScript SDK

PluginCore

PluginCore

English | 中文

🔌 ASP.NET Core lightweight plugin framework

repo size LICENSE CodeFactor downloads QQ Group Telegram Group

CLA assistant FOSSA Status

Introduce

ASP.NET Core lightweight plugin framework

  • Simple - Agreement is better than configuration, with minimal configuration to help you focus on your business
  • Out of the box - Automatic front-end and back-end integration, two lines of code complete the integration
  • Dynamic WebAPI - Each plug-in can add a Controller and have its own routing
  • Plugin isolation and sharing - Perfect plugin isolation and type sharing
  • Front and back ends of the plug-in are separated - You can place the front-end files (index.html,...) under the plugin wwwroot folder, and then visit /plugins/pluginId/index.html
  • Hot swap - Upload, install, enable, disable, uninstall, and delete without restarting the site; you can even add the HTTP request pipeline middleware at runtime through the plug-in, and there is no need to restart the site
  • Dependency injection - You can apply for dependency injection in the construction method of the plug-in class that implements IPlugin. Of course, dependency injection can also be used in the controller construction method
  • Modular - Process modularization, full dependency injection, can be implemented by replacement to customize the plug-in mechanism
  • Easy to expand - You can write your own plug-in SDK, then reference the plug-in SDK, write extension plug-ins-custom plug-in hooks, and apply
  • Plugin dependency tree - Declarative dependencies, automatically establish the correct loading order according to the dependencies between plugins
  • Life cycle - Controllable plug-in life cycle, perfect event distribution
  • Widget - You can bury extension points in the front end, inject widgets through plug-ins, widgets have perfect HTML/CSS/JavaScript support, and elegant event dispatch
  • No database required - No database dependency
  • 0 intrusion - Nearly zero intrusion, does not affect your existing system
  • Little reliance - Only rely on a third-party package (SharpZipLib for decompression)
  • Globalization - Thanks to the internationalization implementation of i18n, it provides multi-language switching support

Online demo

Screenshot

One minute integration

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.

ASP.NET Core Project

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

Notice

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/[email protected]/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

Docker experience

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 use Docker Compose, you can refer to docker-compose.yml in the root directory of the warehouse

add:
Use ghcr.io

docker run -d -p 5004:80 -e ASPNETCORE_URLS="http://*:80" --name plugincore-aspnetcore3-1 ghcr.io/yiyungent/plugincore-aspnetcore3-1

Use

Add plugin hook and apply

  1. For example, custom plug-in hook: ITestPlugin
using PluginCore.IPlugins;

namespace PluginCore.IPlugins
{
    public interface ITestPlugin : IPlugin
    {
        string Say();
    }
}
  1. Apply the hook where it needs to be activated, so that all enabled plug-ins that implement ITestPlugin will call Say()
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("");
        }
    }
}

Custom frontend

PluginCore supports 3 front-end file loading methods

FrontendMode in the configuration file App_Data/PluginCore.Config.json

  1. LocalEmbedded
  • By default, embedded resources and front-end files are packaged into dll. In this mode, it is not easy to customize the front-end files. You need to modify the source code of PluginCore and recompile. It is not recommended
  1. LocalFolder
  • In the ASP.NET Core project that integrates PluginCore, create a new PluginCoreAdmin, and put the front-end files into this folder
  1. RemoteCDN
  • To use remote CDN resources, you can specify the url through the RemoteFrontend in the configuration file

注意:
更新 FrontendMode, 需重启站点后, 才能生效

补充

补充

开发插件只需要, 添加对 PluginCore.IPlugins 包 (插件sdk) 的引用即可,

当然如果你需要 PluginCore , 也可以添加引用

规范

  1. 插件sdk

插件接口应当位于 PluginCore.IPlugins 命名空间,这是规范,不强求,但建议这么做,

程序集名不一定要与命名空间名相同,你完全在你的插件sdk程序集中,使用 PluginCore.IPlugins 命名空间。

  1. 插件

插件程序集名(一般=项目(Project)名) 与 插件 info.jsonPluginId 一致, 例如: 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.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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 nuget downloads
PluginCore nuget downloads
PluginCore.IPlugins.AspNetCore nuget downloads
PluginCore.AspNetCore nuget downloads
PluginCore.Template nuget downloads
plugincore-admin-frontend NPM version NPM downloads
plugincore-js-sdk NPM version NPM downloads

Project structure

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

环境

  • 运行环境: .NET Core 3.1 (+)
  • 开发环境: Visual Studio Community 2019

相关项目

本项目组件

本项目前生/相关

使用本项目的项目

  • yiyungent/KnifeHub - 【PluginCore.AspNetCore 最佳实践】工具平台 | 日常生活/学习/工作/开发 工具集
  • yiyungent/Dragonfly - ASP.NET Core + Selenium 实现 Web 自动化

鸣谢

  • 插件系统设计参考自 CoolCat,感谢作者 lamondlu 的贡献
  • 设计参考自 nopCommerce,感谢作者 nopSolutions 的贡献

特别鸣谢

ReSharper 是一个强大的 Visual Studio 扩展,适用于 .NET 平台语言。

特别感谢 JetBrains 为开源项目提供免费的 ReSharper 等的授权

赞助者

本列表由 afdian-action 自动更新

感谢这些来自爱发电的赞助者:

WiMi Dr MonoLogueChi
点我 打开/关闭 赞助者列表 WiMi ( 1 次赞助, 共 ¥30 ) 留言: 感谢分享
Dr ( 1 次赞助, 共 ¥10 ) 留言: 非常感谢
MonoLogueChi ( 1 次赞助, 共 ¥28.2 ) 留言: 感谢你的开源项目

Donate

PluginCore is an Apache-2.0 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:

License

FOSSA Status

Author

PluginCore © yiyun, Released under the Apache-2.0 License.
Authored and maintained by yiyun with help from contributors (list).

GitHub @yiyungent Gitee @yiyungent

More Repositories

1

KnifeHub

🧰 简单易用的效率工具平台
C#
439
star
2

SimCaptcha

✅ 简单易用的点触验证码 (前端+后端)
C#
79
star
3

hexo-asset-img

🍰 Hexo local image plugin. | Hexo 本地图片插件: 转换 图片相对路径 为 asset_img
JavaScript
58
star
4

Meting4Net

🍰 一个强大的音乐API框架。 Such a powerful music API framework for .Net
C#
39
star
5

Dragonfly

ASP.NET Core + Selenium 实现 Web 自动化平台。已移植到: https://github.com/yiyungent/KnifeHub
C#
35
star
6

Remember.Core

🐬 .NET Web 应用框架。remember for ASP.NET Core
C#
31
star
7

afdian-action

🔧 自动更新 爱发电 赞助列表 | GitHub Action
C#
26
star
8

WebScreenshot

🍰 ASP.NET Core + Selenium 实现 网页截图 以及 获取网页源代码 等
C#
25
star
9

clear-image-action

🔧 Image detection. | 图片检测 | 清理未引用图片 | 删除未引用图片 | 检查引用的图片是否有效 | GitHub Actions
Shell
10
star
10

hexo-anti-spider

🍰 自用 Hexo 反爬虫 方案 ( 加密 + token ) | 修改自 https://github.com/D0n9X1n/hexo-blog-encrypt
JavaScript
8
star
11

getBDUSS

在线获取百度BDUSS C#移植版
C#
7
star
12

QQBotHub

【新仓库】https://github.com/yiyungent/KnifeHub
7
star
13

Afdian.Sdk

🍰 爱发电 非官方 .NET SDK
C#
6
star
14

vue-sim-captcha

✅ Easy-to-use SimCaptcha for Vue.js
Vue
6
star
15

bilibiliLiveSignIn

哔哩哔哩直播自动签到
C#
5
star
16

sim-captcha-js

✅ JavaScript implementation of SimCaptcha frontend.
JavaScript
5
star
17

OneTree.App

自用 工具箱 OneTree - App 客户端
C#
4
star
18

WebScreenshot-python

利用 GitHub Actions 每天 定时 网页截图,并保存到 gh-pages 分支
Python
4
star
19

UHub

😊 OAuth2 + OpenId Connect + SSO + 用户同步 + 用户中心。
C#
4
star
20

zhidaoSignIn

百度知道自动签到
C#
2
star
21

PluginHub

ASP.NET MVC 插件化解决方案
C#
2
star
22

awesome-docker

🐳 个人常用 Dockerfile, docker-compose.yml 配置收集
Dockerfile
2
star
23

upyun-action

☁️ upyun | 又拍云 | GitHub Actions
C#
2
star
24

hexo-cloud

🍰 Hexo 云插件 | 云服务
JavaScript
2
star
25

coo

🧰 .NET 自用 CLI | 工具集
C#
2
star
26

com.moeci.music

基于 Native.Framework 的 酷Q QQ机器人 音乐插件
C#
2
star
27

plugincore-js-sdk

🔌 PluginCore JavaScript SDK | 页面注入/修改 | Plugin Widget
JavaScript
2
star
28

TorchView

🔧 Hybrid App for Xamarin, Xamarin combined with Vue.js and more.
C#
2
star
29

Templates

🎨 ASP.NET MVC5 多主题模板解决方案
C#
2
star
30

remember-app

🍉 Remember.Core for mobile.
Vue
2
star
31

remember

一个在线学习系统,更是一个强大的CMS。v3: 正在转型为多人博客系统
JavaScript
2
star
32

hadoop-docker

在 Docker 中快速搭建 Hadoop 伪分布式集群,用于开发测试。
Shell
1
star
33

OAuth2Demo

OAuth 2.0 ASP.NET MVC 实现(未完工),移植自https://github.com/zifangsky/OAuth2.0Demo
C#
1
star
34

yiyun-LeetCode

✏️ 算法与数据结构 刷题。
C#
1
star
35

tiebaSignIn

百度贴吧自动签到
C#
1
star
36

imaging

🔧 轻量级 Python 图像处理
Python
1
star
37

UCenterApi

🔗 轻松将你的 .NET 应用 与 UCenter(PHP)、DiscuzX 整合。
C#
1
star
38

OneTree.App.Web

自用 工具箱 OneTree - App 客户端 中的 Web页面
Vue
1
star
39

hexo-hidden

🍰 Hexo 插件: 隐藏文章中的部分内容
JavaScript
1
star
40

plugincore-admin-frontend

🔌 PluginCore 的 Admin 前端 ( Vue.js )
JavaScript
1
star