From 5b5aca9ba5f70179ce9cc4ee8c2f89ce7c22c71a Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Mon, 26 Feb 2024 01:07:02 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=F0=9F=94=A7=20Fix(Plugins):=20Fixed=20tw?= =?UTF-8?q?o=20not=20debugged=20plugins.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestPlugin.CSharp/Controller.cs | 22 ++---- TestPlugin.CSharp/IdentityInterface.cs | 70 ++++++++----------- TestPlugin.CSharp/TestPlugin.CSharp.csproj | 1 + TestPlugin.Winform.Core/Controller.cs | 28 ++------ TestPlugin.Winform.Core/IdentityInterface.cs | 69 ++++++++---------- .../TestPlugin.Winform.Core.csproj | 1 + 6 files changed, 75 insertions(+), 116 deletions(-) diff --git a/TestPlugin.CSharp/Controller.cs b/TestPlugin.CSharp/Controller.cs index 4fd54b0..b264a78 100644 --- a/TestPlugin.CSharp/Controller.cs +++ b/TestPlugin.CSharp/Controller.cs @@ -1,13 +1,14 @@ using KitX.Contract.CSharp; using KitX.Shared.Plugin; using KitX.Shared.WebCommand; +using KitX.Shared.WebCommand.Details; using System.Text.Json; namespace TestPlugin.CSharp; public class Controller : IController { - private Action? sendCommandAction; + private Action? sendCommandAction; public void Start() { @@ -34,20 +35,9 @@ public List GetFunctions() return []; } - public void SetSendCommandAction(Action action) => sendCommandAction = action; + public void SetSendCommandAction(Action action) => sendCommandAction = action; - public void SetRootPath(string path) - { - Console.WriteLine($"Root path: {path}"); - } - - public void SetWorkPath(string path) - { - Console.WriteLine($"Work path: {path}"); - } - - public void SetCommandsSendBuffer(ref Queue commands) - { - throw new NotImplementedException(); - } + public void SetWorkingDetail(PluginWorkingDetail workingDetail) => Console.WriteLine( + $"WorkingDetail: {JsonSerializer.Serialize(workingDetail)}" + ); } diff --git a/TestPlugin.CSharp/IdentityInterface.cs b/TestPlugin.CSharp/IdentityInterface.cs index 48c14cc..e436eec 100644 --- a/TestPlugin.CSharp/IdentityInterface.cs +++ b/TestPlugin.CSharp/IdentityInterface.cs @@ -1,43 +1,41 @@ using KitX.Contract.CSharp; +using KitX.Shared.Plugin; namespace TestPlugin.CSharp; public class IdentityInterface : IIdentityInterface { - public string GetName() => "TestPlugin.CSharp"; + public IController GetController() => new Controller(); - public string GetVersion() => "v0.1.0"; + public IMarketPluginContract GetMarketPluginContract() => null!; - public Dictionary GetDisplayName() => new() + public PluginInfo GetPluginInfo() => new() + { + Name = "TestPlugin.CSharp", + Version = "v0.1.0", + DisplayName = new() { { "zh-cn", "适用于 C# 的 KitX 测试用插件" }, - { "zh-cnt", "適用於 C# 的 KitX 測試用插件" }, + { "zh-tw", "適用於 C# 的 KitX 測試用插件" }, { "en-us", "KitX Testing Plugin for C#" }, - }; - - public string GetAuthorName() => "Dynesshely"; - - public string GetPublisherName() => "Crequency"; - - public string GetAuthorLink() => "https://blog.catrol.cn"; - - public string GetPublisherLink() => "https://catrol.cn"; - - public Dictionary GetSimpleDescription() => new() + }, + AuthorName = "Dynesshely", + AuthorLink = "https://blog.catrol.cn", + PublisherName = "Crequency", + PublisherLink = "https://catrol.cn", + SimpleDescription = new() { { "zh-cn", "KitX 测试用插件" }, - { "zh-cnt", "KitX 測試用插件" }, + { "zh-tw", "KitX 測試用插件" }, { "en-us", "KitX Test Plugin" }, - }; - - public Dictionary GetComplexDescription() => new() + }, + ComplexDescription = new() { { "zh-cn", "KitX 测试用插件, 使用 KitX.Loader.CSharp 作为加载器." }, - { "zh-cnt", "KitX 測試用插件, 使用 KitX.Loader.CSharp 作爲加載器." }, + { "zh-tw", "KitX 測試用插件, 使用 KitX.Loader.CSharp 作爲加載器." }, { "en-us", "KitX Test Plugin, use KitX.Loader.CSharp as loader." }, - }; - - public Dictionary GetTotalDescriptionInMarkdown() => new() + }, + TotalDescriptionInMarkdown = new() { { "zh-cn", @@ -48,7 +46,7 @@ 使用 KitX.Loader.CSharp 作为加载器 """ }, { - "zh-cnt", + "zh-tw", """ # 關於 這是一個適用於 C# 的 KitX 測試用插件 @@ -63,19 +61,13 @@ 使用 KitX.Loader.CSharp 作爲加載器 Use KitX.Loader.CSharp as loader """ }, - }; - - public string GetIconInBase64() => "图标"; - - public DateTime GetPublishDate() => DateTime.Now; - - public DateTime GetLastUpdateDate() => DateTime.Now; - - public IController GetController() => new Controller(); - - public bool IsMarketVersion() => false; - - public IMarketPluginContract GetMarketPluginContract() => null; - - public string GetRootStartupFileName() => "TestPlugin.CSharp.dll"; + }, + IconInBase64 = "Icon", + PublishDate = DateTime.Now, + LastUpdateDate = DateTime.Now, + IsMarketVersion = false, + RootStartupFileName = "TestPlugin.CSharp.dll", + Tags = [], + Functions = [] + }; } diff --git a/TestPlugin.CSharp/TestPlugin.CSharp.csproj b/TestPlugin.CSharp/TestPlugin.CSharp.csproj index a533f98..3f24b18 100644 --- a/TestPlugin.CSharp/TestPlugin.CSharp.csproj +++ b/TestPlugin.CSharp/TestPlugin.CSharp.csproj @@ -20,6 +20,7 @@ + diff --git a/TestPlugin.Winform.Core/Controller.cs b/TestPlugin.Winform.Core/Controller.cs index c4348b7..222b5b1 100644 --- a/TestPlugin.Winform.Core/Controller.cs +++ b/TestPlugin.Winform.Core/Controller.cs @@ -1,13 +1,13 @@ using KitX.Contract.CSharp; -using KitX.Shared.Plugin; using KitX.Shared.WebCommand; +using KitX.Shared.WebCommand.Details; using System.Text.Json; namespace TestPlugin.Winform.Core; public class Controller : IController { - private Action? sendCommandAction; + private Action? sendCommandAction; public void Start() { @@ -31,25 +31,9 @@ public void Execute(Command cmd) Console.WriteLine($"Execute: {JsonSerializer.Serialize(cmd)}"); } - public List GetFunctions() - { - return new(); - } - - public void SetSendCommandAction(Action action) => sendCommandAction = action; - - public void SetRootPath(string path) - { - Console.WriteLine($"Root path: {path}"); - } + public void SetSendCommandAction(Action action) => sendCommandAction = action; - public void SetWorkPath(string path) - { - Console.WriteLine($"Work path: {path}"); - } - - public void SetCommandsSendBuffer(ref Queue commands) - { - throw new NotImplementedException(); - } + public void SetWorkingDetail(PluginWorkingDetail workingDetail) => MessageBox.Show( + JsonSerializer.Serialize(workingDetail) + ); } diff --git a/TestPlugin.Winform.Core/IdentityInterface.cs b/TestPlugin.Winform.Core/IdentityInterface.cs index 6993196..df74135 100644 --- a/TestPlugin.Winform.Core/IdentityInterface.cs +++ b/TestPlugin.Winform.Core/IdentityInterface.cs @@ -1,60 +1,51 @@ using KitX.Contract.CSharp; +using KitX.Shared.Plugin; namespace TestPlugin.Winform.Core; public class IdentityInterface : IIdentityInterface { - public string GetName() => "TestPlugin.Winform.Core"; - - public string GetVersion() => "v0.1.0"; + public IController GetController() => new Controller(); - public Dictionary GetDisplayName() => new() + public IMarketPluginContract GetMarketPluginContract() => null!; + + public PluginInfo GetPluginInfo() => new() + { + Name = "TestPlugin.Winform.Core", + Version = "v0.1.0", + AuthorName = "Dynesshely", + AuthorLink = "https://blog.catrol.cn", + PublisherName = "Crequency", + PublisherLink = "https://catrol.cn", + DisplayName = new() { { "zh-cn", "适用于 C# Winform 框架的 KitX 测试用插件" }, - { "zh-cnt", "適用於 C# Winform 框架的 KitX 測試用插件" }, + { "zh-tw", "適用於 C# Winform 框架的 KitX 測試用插件" }, { "en-us", "KitX Testing Plugin for C# with Winform framework" }, - }; - - public string GetAuthorName() => "Dynesshely"; - - public string GetPublisherName() => "Crequency"; - public string GetAuthorLink() => "https://blog.catrol.cn"; - - public string GetPublisherLink() => "https://catrol.cn"; - - public Dictionary GetSimpleDescription() => new() + }, + SimpleDescription = new() { { "zh-cn", "KitX 测试用插件" }, - { "zh-cnt", "KitX 測試用插件" }, + { "zh-tw", "KitX 測試用插件" }, { "en-us", "KitX Test Plugin" }, - }; - - public Dictionary GetComplexDescription() => new() + }, + ComplexDescription = new() { { "zh-cn", "KitX 测试用插件, 使用 KitX.Loader.Winform.Core 作为加载器." }, - { "zh-cnt", "KitX 測試用插件, 使用 KitX.Loader.Winform.Core 作爲加載器." }, + { "zh-tw", "KitX 測試用插件, 使用 KitX.Loader.Winform.Core 作爲加載器." }, { "en-us", "KitX Test Plugin, use KitX.Loader.Winform.Core as loader." }, - }; - - public Dictionary GetTotalDescriptionInMarkdown() => new() + }, + TotalDescriptionInMarkdown = new() { { "zh-cn", "Nope" }, - { "zh-cnt", "Nope" }, + { "zh-tw", "Nope" }, { "en-us", "Nope" }, - }; - - public string GetIconInBase64() => "图标"; - - public DateTime GetPublishDate() => DateTime.Now; - - public DateTime GetLastUpdateDate() => DateTime.Now; - - public IController GetController() => new Controller(); - - public bool IsMarketVersion() => false; - - public IMarketPluginContract GetMarketPluginContract() => null; - - public string GetRootStartupFileName() => "TestPlugin.Winform.Core.dll"; + }, + IconInBase64 = "Icon", + PublishDate = DateTime.Now, + LastUpdateDate = DateTime.Now, + IsMarketVersion = false, + RootStartupFileName = "TestPlugin.Winform.Core.dll", + }; } diff --git a/TestPlugin.Winform.Core/TestPlugin.Winform.Core.csproj b/TestPlugin.Winform.Core/TestPlugin.Winform.Core.csproj index 7128591..68c8278 100644 --- a/TestPlugin.Winform.Core/TestPlugin.Winform.Core.csproj +++ b/TestPlugin.Winform.Core/TestPlugin.Winform.Core.csproj @@ -14,6 +14,7 @@ + \ No newline at end of file From 58dc805ac00820fe2f763ac976457ad57615be0f Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Wed, 28 Feb 2024 18:20:29 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=F0=9F=93=9D=20Chore(Actions):=20Mirror?= =?UTF-8?q?=20to=20gitee.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/mirror.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/mirror.yml diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml new file mode 100644 index 0000000..e2cc0f1 --- /dev/null +++ b/.github/workflows/mirror.yml @@ -0,0 +1,24 @@ +name: Mirror Repo + +on: + push: + branches: + - "*" + workflow_dispatch: + +jobs: + mirror-repo: + runs-on: ubuntu-latest + + steps: + - name: Mirror + uses: Yikun/hub-mirror-action@master + with: + src: github/Crequency + dst: gitee/Crequency + dst_key: ${{ secrets.GITEE_SYNC_KEY }} + dst_token: ${{ secrets.GITEE_SYNC_TOKEN }} + account_type: org + static_list: "KitX-Plugins" + force_update: true + debug: true From 69eaee47991fc69a767041a98403327ad9140411 Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Wed, 28 Feb 2024 19:47:57 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=F0=9F=93=A6=20Struct:=20Adjust=20name=20?= =?UTF-8?q?space.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestPlugin.CSharp/Controller.cs | 6 +++--- TestPlugin.CSharp/IdentityInterface.cs | 2 +- TestPlugin.CSharp/TestPlugin.CSharp.csproj | 1 - TestPlugin.WPF.Core/Controller.cs | 4 ++-- TestPlugin.WPF.Core/MainWindow.xaml.cs | 4 ++-- TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj | 1 - TestPlugin.Winform.Core/Controller.cs | 4 ++-- TestPlugin.Winform.Core/IdentityInterface.cs | 2 +- TestPlugin.Winform.Core/TestPlugin.Winform.Core.csproj | 1 - 9 files changed, 11 insertions(+), 14 deletions(-) diff --git a/TestPlugin.CSharp/Controller.cs b/TestPlugin.CSharp/Controller.cs index b264a78..2e006f9 100644 --- a/TestPlugin.CSharp/Controller.cs +++ b/TestPlugin.CSharp/Controller.cs @@ -1,7 +1,7 @@ using KitX.Contract.CSharp; -using KitX.Shared.Plugin; -using KitX.Shared.WebCommand; -using KitX.Shared.WebCommand.Details; +using KitX.Shared.CSharp.Plugin; +using KitX.Shared.CSharp.WebCommand; +using KitX.Shared.CSharp.WebCommand.Details; using System.Text.Json; namespace TestPlugin.CSharp; diff --git a/TestPlugin.CSharp/IdentityInterface.cs b/TestPlugin.CSharp/IdentityInterface.cs index e436eec..defaac5 100644 --- a/TestPlugin.CSharp/IdentityInterface.cs +++ b/TestPlugin.CSharp/IdentityInterface.cs @@ -1,5 +1,5 @@ using KitX.Contract.CSharp; -using KitX.Shared.Plugin; +using KitX.Shared.CSharp.Plugin; namespace TestPlugin.CSharp; diff --git a/TestPlugin.CSharp/TestPlugin.CSharp.csproj b/TestPlugin.CSharp/TestPlugin.CSharp.csproj index 3f24b18..a533f98 100644 --- a/TestPlugin.CSharp/TestPlugin.CSharp.csproj +++ b/TestPlugin.CSharp/TestPlugin.CSharp.csproj @@ -20,7 +20,6 @@ - diff --git a/TestPlugin.WPF.Core/Controller.cs b/TestPlugin.WPF.Core/Controller.cs index d4cab33..323b447 100644 --- a/TestPlugin.WPF.Core/Controller.cs +++ b/TestPlugin.WPF.Core/Controller.cs @@ -1,6 +1,6 @@ using KitX.Contract.CSharp; -using KitX.Shared.WebCommand; -using KitX.Shared.WebCommand.Details; +using KitX.Shared.CSharp.WebCommand; +using KitX.Shared.CSharp.WebCommand.Details; using System; using System.Windows; diff --git a/TestPlugin.WPF.Core/MainWindow.xaml.cs b/TestPlugin.WPF.Core/MainWindow.xaml.cs index 322eab4..d53149a 100644 --- a/TestPlugin.WPF.Core/MainWindow.xaml.cs +++ b/TestPlugin.WPF.Core/MainWindow.xaml.cs @@ -1,6 +1,6 @@ using KitX.Contract.CSharp; -using KitX.Shared.Plugin; -using KitX.Shared.WebCommand; +using KitX.Shared.CSharp.Plugin; +using KitX.Shared.CSharp.WebCommand; using System; using System.Reflection; using System.Windows; diff --git a/TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj b/TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj index 3082fad..1f4aaf1 100644 --- a/TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj +++ b/TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj @@ -13,7 +13,6 @@ - diff --git a/TestPlugin.Winform.Core/Controller.cs b/TestPlugin.Winform.Core/Controller.cs index 222b5b1..f1b3885 100644 --- a/TestPlugin.Winform.Core/Controller.cs +++ b/TestPlugin.Winform.Core/Controller.cs @@ -1,6 +1,6 @@ using KitX.Contract.CSharp; -using KitX.Shared.WebCommand; -using KitX.Shared.WebCommand.Details; +using KitX.Shared.CSharp.WebCommand; +using KitX.Shared.CSharp.WebCommand.Details; using System.Text.Json; namespace TestPlugin.Winform.Core; diff --git a/TestPlugin.Winform.Core/IdentityInterface.cs b/TestPlugin.Winform.Core/IdentityInterface.cs index df74135..3ba48f7 100644 --- a/TestPlugin.Winform.Core/IdentityInterface.cs +++ b/TestPlugin.Winform.Core/IdentityInterface.cs @@ -1,5 +1,5 @@ using KitX.Contract.CSharp; -using KitX.Shared.Plugin; +using KitX.Shared.CSharp.Plugin; namespace TestPlugin.Winform.Core; diff --git a/TestPlugin.Winform.Core/TestPlugin.Winform.Core.csproj b/TestPlugin.Winform.Core/TestPlugin.Winform.Core.csproj index 68c8278..7128591 100644 --- a/TestPlugin.Winform.Core/TestPlugin.Winform.Core.csproj +++ b/TestPlugin.Winform.Core/TestPlugin.Winform.Core.csproj @@ -14,7 +14,6 @@ - \ No newline at end of file From 2c2a2102d4826765f6f9806ff1e1ddf3bc3f1b3e Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Fri, 1 Mar 2024 08:09:42 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=F0=9F=8E=87=20Style:=20Enable=20`using?= =?UTF-8?q?=20System.*`=20first.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestPlugin.CSharp/Controller.cs | 4 ++-- TestPlugin.WPF.Core/Controller.cs | 6 +++--- TestPlugin.WPF.Core/MainWindow.xaml.cs | 8 ++++---- TestPlugin.Winform.Core/Controller.cs | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/TestPlugin.CSharp/Controller.cs b/TestPlugin.CSharp/Controller.cs index 2e006f9..a935848 100644 --- a/TestPlugin.CSharp/Controller.cs +++ b/TestPlugin.CSharp/Controller.cs @@ -1,8 +1,8 @@ -using KitX.Contract.CSharp; +using System.Text.Json; +using KitX.Contract.CSharp; using KitX.Shared.CSharp.Plugin; using KitX.Shared.CSharp.WebCommand; using KitX.Shared.CSharp.WebCommand.Details; -using System.Text.Json; namespace TestPlugin.CSharp; diff --git a/TestPlugin.WPF.Core/Controller.cs b/TestPlugin.WPF.Core/Controller.cs index 323b447..de52df6 100644 --- a/TestPlugin.WPF.Core/Controller.cs +++ b/TestPlugin.WPF.Core/Controller.cs @@ -1,8 +1,8 @@ -using KitX.Contract.CSharp; +using System; +using System.Windows; +using KitX.Contract.CSharp; using KitX.Shared.CSharp.WebCommand; using KitX.Shared.CSharp.WebCommand.Details; -using System; -using System.Windows; namespace TestPlugin.WPF.Core; diff --git a/TestPlugin.WPF.Core/MainWindow.xaml.cs b/TestPlugin.WPF.Core/MainWindow.xaml.cs index d53149a..5587a38 100644 --- a/TestPlugin.WPF.Core/MainWindow.xaml.cs +++ b/TestPlugin.WPF.Core/MainWindow.xaml.cs @@ -1,9 +1,9 @@ -using KitX.Contract.CSharp; -using KitX.Shared.CSharp.Plugin; -using KitX.Shared.CSharp.WebCommand; -using System; +using System; using System.Reflection; using System.Windows; +using KitX.Contract.CSharp; +using KitX.Shared.CSharp.Plugin; +using KitX.Shared.CSharp.WebCommand; namespace TestPlugin.WPF.Core; diff --git a/TestPlugin.Winform.Core/Controller.cs b/TestPlugin.Winform.Core/Controller.cs index f1b3885..8a6710a 100644 --- a/TestPlugin.Winform.Core/Controller.cs +++ b/TestPlugin.Winform.Core/Controller.cs @@ -1,7 +1,7 @@ -using KitX.Contract.CSharp; +using System.Text.Json; +using KitX.Contract.CSharp; using KitX.Shared.CSharp.WebCommand; using KitX.Shared.CSharp.WebCommand.Details; -using System.Text.Json; namespace TestPlugin.Winform.Core; From 2fd3d442b9b2d18f8571aec4d3de64000091c341 Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Sun, 21 Apr 2024 21:03:51 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=F0=9F=92=BE=20Feat:=20Attributes=20for?= =?UTF-8?q?=20auto=20info=20file=20generation=20in=20future?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestPlugin.WPF.Core/Controller.cs | 2 +- TestPlugin.WPF.Core/Functions.cs | 27 ++++++++++ TestPlugin.WPF.Core/PluginStruct.json | 53 ------------------- .../TestPlugin.WPF.Core.csproj | 4 +- 4 files changed, 29 insertions(+), 57 deletions(-) create mode 100644 TestPlugin.WPF.Core/Functions.cs delete mode 100644 TestPlugin.WPF.Core/PluginStruct.json diff --git a/TestPlugin.WPF.Core/Controller.cs b/TestPlugin.WPF.Core/Controller.cs index de52df6..81ccf84 100644 --- a/TestPlugin.WPF.Core/Controller.cs +++ b/TestPlugin.WPF.Core/Controller.cs @@ -31,7 +31,7 @@ public void Execute(Command command) { if (command.FunctionName.Equals("HelloKitX")) { - MessageBox.Show("Hello KitX !"); + Functions.HelloKitX(); } } diff --git a/TestPlugin.WPF.Core/Functions.cs b/TestPlugin.WPF.Core/Functions.cs new file mode 100644 index 0000000..f83a6c2 --- /dev/null +++ b/TestPlugin.WPF.Core/Functions.cs @@ -0,0 +1,27 @@ +using System.Windows; +using KitX.Contract.CSharp.Attributes; + +namespace TestPlugin.WPF.Core; + +[EntryClass] +public class Functions +{ + [Function(nameof(HelloKitX))] + public static void HelloKitX() + { + MessageBox.Show("Hello KitX !"); + } + + [Function(nameof(HelloAnything))] + [Translation("DisplayName", "zh-CN", "打个招呼")] + [Translation("DisplayName", "en-US", "Hello Anything")] + public static void HelloAnything( + [Parameter(nameof(name))] + [Translation("DisplayName", "zh-CN", "名称")] + [Translation("DisplayName", "en-US", "Name")] + string name + ) + { + MessageBox.Show($"Hello {name} !"); + } +} diff --git a/TestPlugin.WPF.Core/PluginStruct.json b/TestPlugin.WPF.Core/PluginStruct.json deleted file mode 100644 index 9e92de2..0000000 --- a/TestPlugin.WPF.Core/PluginStruct.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "Name": "TestPlugin.WPF.Core", - "DisplayName": { - "zh-cn": "TestPlugin.WPF.Core", - "en-us": "TestPlugin.WPF.Core" - }, - "Version": "1.0.0.307", - "AuthorLink": "https://github.com/Crequency/KitX/", - "AuthorName": "Crequency", - "PublisherLink": "https://github.com/Crequency/", - "PublisherName": "Crequency", - "PublishDate": "2024-02-20T23:40:00.5475765+08:00", - "LastUpdateDate": "2024-02-20T23:40:00.5475782+08:00", - "SimpleDescription": { - "zh-cn": "TestPlugin.WPF.Core", - "en-us": "TestPlugin.WPF.Core" - }, - "ComplexDescription": { - "zh-cn": "\u7528\u4E8E\u6D4B\u8BD5\u4E8E\u9A8C\u8BC1 WPF.Core \u6846\u67B6\u4E0B\u7684\u63D2\u4EF6\u53EF\u884C\u6027", - "en-us": "Used to test and verify the feasibility of plug-ins under the WPF.Core framework" - }, - "TotalDescriptionInMarkdown": { - "zh-cn": "# \u4F60\u597D!\r\n\u0060\u0060\u0060cpp\r\nvoid helloWorld(string greet) {\r\n std::cout \u003C\u003C \u0022Hello, World!\u0022;\r\n}\r\n\u0060\u0060\u0060", - "en-us": "# Hi, there!\r\n\u0060\u0060\u0060cpp\r\nvoid helloWorld(string greet) {\r\n std::cout \u003C\u003C \u0022Hello, World!\u0022;\r\n}\r\n\u0060\u0060\u0060" - }, - "IconInBase64": "", - "IsMarketVersion": false, - "RootStartupFileName": "TestPlugin.WPF.Core.dll", - "Functions": [ - { - "Name": "HelloKitX", - "DisplayNames": { - "zh-cn": "\u4F60\u597D KitX !", - "en-us": "Hello KitX !" - }, - "ReturnValueType": "void", - "Parameters": [ - { - "Name": "greet", - "DisplayNames": { - "zh-cn": "\u95EE\u5019\u8BED", - "en-us": "GreetingText" - }, - "Type": "string", - "IsAppendable": false - } - ] - } - ], - "Tags": { - "IsTestPlugin": "true" - } -} diff --git a/TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj b/TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj index 1f4aaf1..1cca026 100644 --- a/TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj +++ b/TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj @@ -13,15 +13,13 @@ + Always - - Always - From db86a46f653294b6774fc7082005fddf411a3f53 Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Sun, 29 Sep 2024 09:23:34 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=F0=9F=93=9D=20Chore:=20Ignore=20.DS=5FSt?= =?UTF-8?q?ore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f16e632..57bc04b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ -## Ignore Visual Studio temporary files, build results, and +## Platform ignores +.DS_Store + +## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore From c042a456c5111a06d6b6ba9b9dfe9e980c5acaf5 Mon Sep 17 00:00:00 2001 From: StarInk Date: Sun, 15 Mar 2026 05:06:31 +0100 Subject: [PATCH 07/12] =?UTF-8?q?=F0=9F=92=BE=20=F0=9F=94=A7=20Feat,=20Fix?= =?UTF-8?q?(TestPlugin.CSharp,=20TestPlugin.WPF.Core):=20Add=20a=20"SayHel?= =?UTF-8?q?lo"=20Function;=20Change=20Exe=20OutputType=20to=20dll(Library)?= =?UTF-8?q?;=20Add=20PluginStruct.json=20to=20WPF=20plugin.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestPlugin.CSharp/Controller.cs | 43 ++++++++++++++++++- TestPlugin.CSharp/IdentityInterface.cs | 28 +++++++++++- TestPlugin.CSharp/Program.cs | 3 +- TestPlugin.CSharp/TestPlugin.CSharp.csproj | 2 +- TestPlugin.WPF.Core/PluginStruct.json | 26 +++++++++++ .../TestPlugin.WPF.Core.csproj | 3 ++ 6 files changed, 100 insertions(+), 5 deletions(-) create mode 100644 TestPlugin.WPF.Core/PluginStruct.json diff --git a/TestPlugin.CSharp/Controller.cs b/TestPlugin.CSharp/Controller.cs index a935848..3c21da6 100644 --- a/TestPlugin.CSharp/Controller.cs +++ b/TestPlugin.CSharp/Controller.cs @@ -28,11 +28,52 @@ public void End() public void Execute(Command cmd) { Console.WriteLine($"Execute: {JsonSerializer.Serialize(cmd)}"); + + if (cmd.FunctionName == "SayHello") + { + // 从参数中获取 name + var name = "World"; // 默认值 + + if (cmd.FunctionArgs is not null && cmd.FunctionArgs.Count > 0) + { + var firstArg = cmd.FunctionArgs[0]; + name = firstArg.Value ?? "World"; + } + + var result = $"Hello, {name}!"; + Console.WriteLine($"SayHello result: {result}"); + } } public List GetFunctions() { - return []; + return [ + new Function() + { + Name = "SayHello", + DisplayNames = new() + { + { "zh-cn", "打招呼" }, + { "zh-tw", "打招呼" }, + { "en-us", "Say Hello" }, + }, + ReturnValueType = "string", + Parameters = [ + new Parameter() + { + Name = "name", + Type = "string", + DisplayNames = new() + { + { "zh-cn", "姓名" }, + { "zh-tw", "姓名" }, + { "en-us", "Name" }, + }, + IsOptional = false, + } + ], + } + ]; } public void SetSendCommandAction(Action action) => sendCommandAction = action; diff --git a/TestPlugin.CSharp/IdentityInterface.cs b/TestPlugin.CSharp/IdentityInterface.cs index defaac5..1dd35d3 100644 --- a/TestPlugin.CSharp/IdentityInterface.cs +++ b/TestPlugin.CSharp/IdentityInterface.cs @@ -68,6 +68,32 @@ Use KitX.Loader.CSharp as loader IsMarketVersion = false, RootStartupFileName = "TestPlugin.CSharp.dll", Tags = [], - Functions = [] + Functions = [ + new Function() + { + Name = "SayHello", + DisplayNames = new() + { + { "zh-cn", "打招呼" }, + { "zh-tw", "打招呼" }, + { "en-us", "Say Hello" }, + }, + ReturnValueType = "string", + Parameters = [ + new Parameter() + { + Name = "name", + Type = "string", + DisplayNames = new() + { + { "zh-cn", "姓名" }, + { "zh-tw", "姓名" }, + { "en-us", "Name" }, + }, + IsOptional = false, + } + ], + } + ] }; } diff --git a/TestPlugin.CSharp/Program.cs b/TestPlugin.CSharp/Program.cs index 15ca0c9..ed9eb4e 100644 --- a/TestPlugin.CSharp/Program.cs +++ b/TestPlugin.CSharp/Program.cs @@ -1,2 +1 @@ - -Console.WriteLine("Hello, World!"); +// 插件入口点 - 不需要顶级语句,Loader 会通过 MEF 加载 IIdentityInterface diff --git a/TestPlugin.CSharp/TestPlugin.CSharp.csproj b/TestPlugin.CSharp/TestPlugin.CSharp.csproj index a533f98..d674cc1 100644 --- a/TestPlugin.CSharp/TestPlugin.CSharp.csproj +++ b/TestPlugin.CSharp/TestPlugin.CSharp.csproj @@ -1,7 +1,7 @@  - Exe + Library net8.0 enable enable diff --git a/TestPlugin.WPF.Core/PluginStruct.json b/TestPlugin.WPF.Core/PluginStruct.json new file mode 100644 index 0000000..3309dc0 --- /dev/null +++ b/TestPlugin.WPF.Core/PluginStruct.json @@ -0,0 +1,26 @@ +{ + "Name": "TestPlugin.WPF.Core", + "Version": "1.0.0", + "DisplayName": { + "zh-cn": "TestPlugin.WPF.Core", + "en-us": "TestPlugin.WPF.Core" + }, + "AuthorName": "Crequency", + "AuthorLink": "https://github.com/Crequency/KitX/", + "PublisherName": "Crequency", + "PublisherLink": "https://github.com/Crequency/", + "SimpleDescription": { + "zh-cn": "TestPlugin.WPF.Core", + "en-us": "TestPlugin.WPF.Core" + }, + "ComplexDescription": { + "zh-cn": "用于测试于验证 WPF.Core 框架下的插件可行性", + "en-us": "Used to test and verify the feasibility of plug-ins under the WPF.Core framework" + }, + "IconInBase64": "", + "IsMarketVersion": false, + "RootStartupFileName": "TestPlugin.WPF.Core.dll", + "Tags": { + "IsTestPlugin": "true" + } +} diff --git a/TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj b/TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj index 1cca026..e11d1c7 100644 --- a/TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj +++ b/TestPlugin.WPF.Core/TestPlugin.WPF.Core.csproj @@ -20,6 +20,9 @@ Always + + Always + From a6a77acf1a49b77afb8c66e1d2b66998b9abb4be Mon Sep 17 00:00:00 2001 From: StarInk Date: Sun, 15 Mar 2026 14:28:33 +0100 Subject: [PATCH 08/12] =?UTF-8?q?=F0=9F=92=BE=20Feat(TestPlugin.CSharp):?= =?UTF-8?q?=20=E9=80=82=E9=85=8D=E5=9F=BA=E4=BA=8ERequestId=E7=9A=84?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E8=BF=94=E5=9B=9E=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestPlugin.CSharp/Controller.cs | 44 ++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/TestPlugin.CSharp/Controller.cs b/TestPlugin.CSharp/Controller.cs index 3c21da6..a02349a 100644 --- a/TestPlugin.CSharp/Controller.cs +++ b/TestPlugin.CSharp/Controller.cs @@ -1,8 +1,10 @@ -using System.Text.Json; +using System.Text; +using System.Text.Json; using KitX.Contract.CSharp; using KitX.Shared.CSharp.Plugin; using KitX.Shared.CSharp.WebCommand; using KitX.Shared.CSharp.WebCommand.Details; +using KitX.Shared.CSharp.WebCommand.Infos; namespace TestPlugin.CSharp; @@ -10,6 +12,13 @@ public class Controller : IController { private Action? sendCommandAction; + private static readonly JsonSerializerOptions serializerOptions = new() + { + WriteIndented = true, + IncludeFields = true, + PropertyNameCaseInsensitive = true, + }; + public void Start() { Console.WriteLine("Started"); @@ -29,6 +38,13 @@ public void Execute(Command cmd) { Console.WriteLine($"Execute: {JsonSerializer.Serialize(cmd)}"); + // 从 Tags 中获取 RequestId,用于发送响应 + string? requestId = null; + if (cmd.Tags is not null && cmd.Tags.TryGetValue("RequestId", out var reqId)) + { + requestId = reqId; + } + if (cmd.FunctionName == "SayHello") { // 从参数中获取 name @@ -42,6 +58,32 @@ public void Execute(Command cmd) var result = $"Hello, {name}!"; Console.WriteLine($"SayHello result: {result}"); + + // 如果有 RequestId,发送响应 + if (requestId is not null && sendCommandAction is not null) + { + var responseBytes = Encoding.UTF8.GetBytes(result); + + var responseCommand = new Command + { + Request = CommandRequestInfo.ReceiveCommand, + PluginConnectionId = cmd.PluginConnectionId ?? string.Empty, + Body = responseBytes, + BodyLength = responseBytes.Length, + Tags = new Dictionary + { + { "RequestId", requestId } + } + }; + + var responseRequest = new Request + { + Content = JsonSerializer.Serialize(responseCommand, serializerOptions) + }; + + sendCommandAction.Invoke(responseRequest); + Console.WriteLine($"[DEBUG] Response sent via sendCommandAction: {result}"); + } } } From a05d6d120d6102edffe7666bd836ed03e825238f Mon Sep 17 00:00:00 2001 From: StarInk Date: Mon, 13 Apr 2026 02:45:07 +0200 Subject: [PATCH 09/12] =?UTF-8?q?=F0=9F=92=BE=20Feat(TestPlugin.WPF.Core):?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?UI=E4=BB=A5=E6=94=AF=E6=8C=81=E7=94=A8=E6=88=B7=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E8=A7=A6=E5=8F=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestPlugin.WPF.Core/Controller.cs | 30 +++++++++++++++++++++++ TestPlugin.WPF.Core/Functions.cs | 5 ++++ TestPlugin.WPF.Core/MainWindow.xaml | 33 +++++++++++++++++++++----- TestPlugin.WPF.Core/MainWindow.xaml.cs | 25 +++++++++++++++++++ 4 files changed, 87 insertions(+), 6 deletions(-) diff --git a/TestPlugin.WPF.Core/Controller.cs b/TestPlugin.WPF.Core/Controller.cs index 81ccf84..5c81d91 100644 --- a/TestPlugin.WPF.Core/Controller.cs +++ b/TestPlugin.WPF.Core/Controller.cs @@ -1,4 +1,6 @@ using System; +using System.Text; +using System.Text.Json; using System.Windows; using KitX.Contract.CSharp; using KitX.Shared.CSharp.WebCommand; @@ -10,6 +12,13 @@ public class Controller(MainWindow mainwin) : IController { private readonly MainWindow mainwin = mainwin; + private static readonly JsonSerializerOptions _serializerOptions = new() + { + WriteIndented = false, + IncludeFields = true, + PropertyNameCaseInsensitive = true, + }; + public PluginWorkingDetail? WorkingDetail { get; set; } public void End() @@ -33,6 +42,27 @@ public void Execute(Command command) { Functions.HelloKitX(); } + else if (command.FunctionName.Equals("HelloAnything")) + { + var name = command.FunctionArgs != null && command.FunctionArgs.Count > 0 ? command.FunctionArgs[0].Value : "Anything"; + Functions.HelloAnything(name); + } + else if (command.FunctionName.Equals("GetInput")) + { + var inputText = mainwin.GetInputText(); + var bodyBytes = Encoding.UTF8.GetBytes(inputText); + mainwin.sendCommandAction?.Invoke(new Request + { + Type = RequestTypes.Command, + Version = RequestVersions.V1, + Content = JsonSerializer.Serialize(new Command + { + Tags = command.Tags, // 保留 RequestId 用于响应匹配 + Body = bodyBytes, + BodyLength = bodyBytes.Length + }, _serializerOptions) + }); + } } public void SetWorkingDetail(PluginWorkingDetail workingDetail) => WorkingDetail = workingDetail; diff --git a/TestPlugin.WPF.Core/Functions.cs b/TestPlugin.WPF.Core/Functions.cs index f83a6c2..6b41aca 100644 --- a/TestPlugin.WPF.Core/Functions.cs +++ b/TestPlugin.WPF.Core/Functions.cs @@ -24,4 +24,9 @@ string name { MessageBox.Show($"Hello {name} !"); } + + [Function(nameof(GetInput))] + [Translation("DisplayName", "zh-CN", "获取输入内容")] + [Translation("DisplayName", "en-US", "Get Input Text")] + public static string GetInput() => string.Empty; // 实际由 Controller.Execute 处理返回值 } diff --git a/TestPlugin.WPF.Core/MainWindow.xaml b/TestPlugin.WPF.Core/MainWindow.xaml index ba2d5d7..de09bf7 100644 --- a/TestPlugin.WPF.Core/MainWindow.xaml +++ b/TestPlugin.WPF.Core/MainWindow.xaml @@ -9,11 +9,32 @@ SizeToContent="WidthAndHeight" mc:Ignorable="d"> - + + + + + + + +