From 6c08854b48c3229bfb890f5498d98618d7f71782 Mon Sep 17 00:00:00 2001 From: Wangjunqi123 Date: Fri, 14 Jun 2024 17:05:05 +0800 Subject: [PATCH] template: add pluginclient module --- template/server/pluginclient/meta.go | 15 ++++++ template/server/pluginclient/pluginClient.go | 48 ++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 template/server/pluginclient/meta.go create mode 100644 template/server/pluginclient/pluginClient.go diff --git a/template/server/pluginclient/meta.go b/template/server/pluginclient/meta.go new file mode 100644 index 00000000..afd17594 --- /dev/null +++ b/template/server/pluginclient/meta.go @@ -0,0 +1,15 @@ +package pluginclient + +import "gitee.com/openeuler/PilotGo/sdk/plugin/client" + +const Version = "1.0.1" + +var PluginInfo = &client.PluginInfo{ + Name: "template", + Version: Version, + Description: "template plugin for PilotGo", + Author: "", + Email: "", + Url: "", + PluginType: "micro-app", +} diff --git a/template/server/pluginclient/pluginClient.go b/template/server/pluginclient/pluginClient.go new file mode 100644 index 00000000..3d4cf587 --- /dev/null +++ b/template/server/pluginclient/pluginClient.go @@ -0,0 +1,48 @@ +package pluginclient + +import ( + "context" + + "gitee.com/openeuler/PilotGo-plugin-template/conf" + "gitee.com/openeuler/PilotGo/sdk/common" + "gitee.com/openeuler/PilotGo/sdk/plugin/client" +) + +var Global_Client *client.Client + +var Global_Context context.Context + +func InitPluginClient() { + if conf.Global_Config.Template.Https_enabled { + PluginInfo.Url = "https://" + conf.Global_Config.Template.Addr + } else { + PluginInfo.Url = "http://" + conf.Global_Config.Template.Addr + } + + Global_Client = client.DefaultClient(PluginInfo) + + // 注册插件扩展点 + var ex []common.Extention + pe1 := &common.PageExtention{ + Type: common.ExtentionPage, + Name: "主页面扩展", + URL: "/page", + Permission: "plugin.template.page/menu", + } + me2 := &common.MachineExtention{ + Type: common.ExtentionMachine, + Name: "机器扩展", + URL: "/host", + Permission: "plugin.template/function", + } + be3 := &common.BatchExtention{ + Type: common.ExtentionBatch, + Name: "批次扩展", + URL: "/batch", + Permission: "plugin.template/function", + } + ex = append(ex, pe1, me2, be3) + Global_Client.RegisterExtention(ex) + + Global_Context = context.Background() +} -- Gitee