Skip to content

Commit

Permalink
feat: 使用新的 PluginCore, 一些地方写错修复
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyungent committed Apr 16, 2022
1 parent 16aba0f commit 0e6f791
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 16 deletions.
14 changes: 14 additions & 0 deletions QQBotHub.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginCore", "src\PluginCor
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginCore.IPlugins", "src\PluginCore\src\PluginCore.IPlugins\PluginCore.IPlugins.csproj", "{3F1C9ACE-0EC3-45FE-B382-97216429086E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginCore.AspNetCore", "src\PluginCore\src\PluginCore.AspNetCore\PluginCore.AspNetCore.csproj", "{F0B0E0DF-4490-478A-9C60-C80F0E290FC2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginCore.IPlugins.AspNetCore", "src\PluginCore\src\PluginCore.IPlugins.AspNetCore\PluginCore.IPlugins.AspNetCore.csproj", "{61F02E99-EB5C-4E9E-95D7-A2F7CEAFE077}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -69,6 +73,14 @@ Global
{3F1C9ACE-0EC3-45FE-B382-97216429086E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F1C9ACE-0EC3-45FE-B382-97216429086E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F1C9ACE-0EC3-45FE-B382-97216429086E}.Release|Any CPU.Build.0 = Release|Any CPU
{F0B0E0DF-4490-478A-9C60-C80F0E290FC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0B0E0DF-4490-478A-9C60-C80F0E290FC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0B0E0DF-4490-478A-9C60-C80F0E290FC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0B0E0DF-4490-478A-9C60-C80F0E290FC2}.Release|Any CPU.Build.0 = Release|Any CPU
{61F02E99-EB5C-4E9E-95D7-A2F7CEAFE077}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{61F02E99-EB5C-4E9E-95D7-A2F7CEAFE077}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61F02E99-EB5C-4E9E-95D7-A2F7CEAFE077}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61F02E99-EB5C-4E9E-95D7-A2F7CEAFE077}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -82,6 +94,8 @@ Global
{F6087CC7-5239-42E3-92D6-51F25F6E3EE8} = {4B4BFBBE-8CE4-453C-B05A-EAFE933B79C9}
{AE51E530-8545-40F5-9070-8314E722FEF9} = {BDFD03E4-0A99-49A3-95A7-F7132EC4FF00}
{3F1C9ACE-0EC3-45FE-B382-97216429086E} = {BDFD03E4-0A99-49A3-95A7-F7132EC4FF00}
{F0B0E0DF-4490-478A-9C60-C80F0E290FC2} = {BDFD03E4-0A99-49A3-95A7-F7132EC4FF00}
{61F02E99-EB5C-4E9E-95D7-A2F7CEAFE077} = {BDFD03E4-0A99-49A3-95A7-F7132EC4FF00}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3F1D77E3-11F8-4B5B-BEED-EE2816D57A86}
Expand Down
4 changes: 2 additions & 2 deletions plugins/QQHelloWorldPlugin/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ namespace QQHelloWorldPlugin.Controllers
/// 若 wwwroot 下有其它需要访问的文件, 如何 css, js, 而你又不想每次新增 action 指定返回, 则 Route 必须 Plugins/{PluginId},
/// 这样访问 Plugins/HelloWorldPlugin/css/main.css 就会访问到你插件下的 wwwroot/css/main.css
/// </summary>
[Route("Plugins/HelloWorldPlugin")]
[Route($"Plugins/{nameof(QQHelloWorldPlugin)}")]
public class HomeController : Controller
{
public async Task<ActionResult> Get()
{
string indexFilePath = System.IO.Path.Combine(PluginPathProvider.PluginWwwRootDir("HelloWorldPlugin"), "index.html");
string indexFilePath = System.IO.Path.Combine(PluginPathProvider.PluginWwwRootDir(nameof(QQHelloWorldPlugin)), "index.html");

return PhysicalFile(indexFilePath, "text/html");
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/QQHelloWorldPlugin/QQHelloWorldPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

namespace QQHelloWorldPlugin
{
public class HelloWorldPlugin : BasePlugin, IStartupXPlugin, IWidgetPlugin, IQQBotPlugin
public class QQHelloWorldPlugin : BasePlugin, IStartupXPlugin, IWidgetPlugin, IQQBotPlugin
{
public override (bool IsSuccess, string Message) AfterEnable()
{
Console.WriteLine($"{nameof(HelloWorldPlugin)}: {nameof(AfterEnable)}");
Console.WriteLine($"{nameof(QQHelloWorldPlugin)}: {nameof(AfterEnable)}");
return base.AfterEnable();
}

public override (bool IsSuccess, string Message) BeforeDisable()
{
Console.WriteLine($"{nameof(HelloWorldPlugin)}: {nameof(BeforeDisable)}");
Console.WriteLine($"{nameof(QQHelloWorldPlugin)}: {nameof(BeforeDisable)}");
return base.BeforeDisable();
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/QQHelloWorldPlugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

## 前端视图

- [/Plugins/HelloWorldPlugin](/Plugins/QQHelloWorldPlugin)
- [/Plugins/QQHelloWorldPlugin](/Plugins/QQHelloWorldPlugin)

## 挂件

Expand Down
6 changes: 3 additions & 3 deletions plugins/QQHelloWorldPlugin/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<head>
<meta charset="utf-8" />
<title>HelloWorldPlugin</title>
<!-- 注意:路径, 前置 /plugins/HelloWorldPlugin/ -->
<link href="/plugins/HelloWorldPlugin/css/main.css" rel="stylesheet" />
<!-- 注意:路径, 前置 /plugins/QQHelloWorldPlugin/ -->
<link href="/plugins/QQHelloWorldPlugin/css/main.css" rel="stylesheet" />
</head>
<body>
<div id="app">
<h3>HelloWorldPlugin! </h3>
<h3>QQHelloWorldPlugin! </h3>
<p>插件的前端文件应当放在 wwwroot 文件夹下</p>
</div>

Expand Down
2 changes: 1 addition & 1 deletion plugins/QQStatPlugin/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task<ActionResult> Get()
}

[Route(nameof(Download))]
[Authorize("PluginCoreAdmin")]
[Authorize("PluginCore.Admin")]
public async Task<ActionResult> Download()
{
string dbFilePath = DbContext.DbFilePath;
Expand Down
4 changes: 2 additions & 2 deletions src/QQBotHub.Sdk/QQBotHub.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

<!-- 方便开发debug,与发布到nuget -->
<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="PluginCore.IPlugins" Version="0.7.0" />
<PackageReference Include="PluginCore.IPlugins.AspNetCore" Version="0.0.1" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<ProjectReference Include="..\PluginCore\src\PluginCore.IPlugins\PluginCore.IPlugins.csproj" />
<ProjectReference Include="..\PluginCore\src\PluginCore.IPlugins.AspNetCore\PluginCore.IPlugins.AspNetCore.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/QQBotHub.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace QQBotHub.Web.Controllers
{
[Route("api/[action]")]
[Authorize("PluginCoreAdmin")]
[Authorize("PluginCore.Admin")]
[ApiController]
public class HomeController : ControllerBase
{
Expand Down
2 changes: 1 addition & 1 deletion src/QQBotHub.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using PluginCore.Extensions;
using PluginCore.AspNetCore.Extensions;

var builder = WebApplication.CreateBuilder(args);

Expand Down
4 changes: 2 additions & 2 deletions src/QQBotHub.Web/QQBotHub.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

<!-- 方便开发debug,与发布到nuget -->
<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="PluginCore" Version="0.9.3" />
<PackageReference Include="PluginCore.AspNetCore" Version="0.0.3" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<ProjectReference Include="..\PluginCore\src\PluginCore\PluginCore.csproj" />
<ProjectReference Include="..\PluginCore\src\PluginCore.AspNetCore\PluginCore.AspNetCore.csproj" />
</ItemGroup>

<!-- 方便开发debug,与发布到nuget -->
Expand Down

0 comments on commit 0e6f791

Please sign in to comment.