diff --git a/build.gradle b/build.gradle index 8316c39..52a6d61 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { id "run.halo.plugin.devtools" version "0.0.7" } -group 'run.halo.starter' +group 'run.jiewen.tool' sourceCompatibility = JavaVersion.VERSION_17 repositories { @@ -52,5 +52,5 @@ build { } halo { - version = '2.11' + version = '2.14' } diff --git a/settings.gradle b/settings.gradle index 67ea47b..49ab975 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,5 +3,5 @@ pluginManagement { gradlePluginPortal() } } -rootProject.name = 'plugin-starter' +rootProject.name = 'wx-config' diff --git a/src/main/java/run/halo/starter/StarterPlugin.java b/src/main/java/run/halo/starter/StarterPlugin.java deleted file mode 100644 index f8c3eb5..0000000 --- a/src/main/java/run/halo/starter/StarterPlugin.java +++ /dev/null @@ -1,31 +0,0 @@ -package run.halo.starter; - -import org.springframework.stereotype.Component; -import run.halo.app.plugin.BasePlugin; -import run.halo.app.plugin.PluginContext; - -/** - *

Plugin main class to manage the lifecycle of the plugin.

- *

This class must be public and have a public constructor.

- *

Only one main class extending {@link BasePlugin} is allowed per plugin.

- * - * @author guqing - * @since 1.0.0 - */ -@Component -public class StarterPlugin extends BasePlugin { - - public StarterPlugin(PluginContext pluginContext) { - super(pluginContext); - } - - @Override - public void start() { - System.out.println("插件启动成功!"); - } - - @Override - public void stop() { - System.out.println("插件停止!"); - } -} diff --git a/src/main/java/run/jiewen/tool/ToolConfiguration.java b/src/main/java/run/jiewen/tool/ToolConfiguration.java new file mode 100644 index 0000000..47450b7 --- /dev/null +++ b/src/main/java/run/jiewen/tool/ToolConfiguration.java @@ -0,0 +1,27 @@ +package run.jiewen.tool; +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Bean; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; +import run.halo.app.plugin.ReactiveSettingFetcher; +@Component +@RequiredArgsConstructor +public class ToolConfiguration { + private final ReactiveSettingFetcher settingFetcher; + + @Bean + RouterFunction editorOptionsRouter() { + return RouterFunctions.route() + .GET("/apis/api.wx.jiewen.run/tool-options", + request -> settingFetcher.getValues() + .flatMap(result -> ServerResponse.ok() + .contentType(MediaType.APPLICATION_JSON) + .bodyValue(result) + ) + ) + .build(); + } +} diff --git a/src/main/java/run/jiewen/tool/WxTool.java b/src/main/java/run/jiewen/tool/WxTool.java new file mode 100644 index 0000000..bd9c0e3 --- /dev/null +++ b/src/main/java/run/jiewen/tool/WxTool.java @@ -0,0 +1,20 @@ +package run.jiewen.tool; + +import org.pf4j.PluginWrapper; +import org.springframework.stereotype.Component; +import run.halo.app.plugin.BasePlugin; +@Component +public class WxTool extends BasePlugin{ + public WxTool(PluginWrapper wrapper) { + super(wrapper); + } + @Override + public void start() { + System.out.println("插件启动成功!"); + } + + @Override + public void stop() { + System.out.println("插件停止!"); + } +} diff --git a/src/main/resources/extensions/roleTemplates.yaml b/src/main/resources/extensions/roleTemplates.yaml new file mode 100644 index 0000000..f7414a6 --- /dev/null +++ b/src/main/resources/extensions/roleTemplates.yaml @@ -0,0 +1,11 @@ +apiVersion: v1alpha1 +kind: "Role" +metadata: + name: role-template-vditor-mde + labels: + halo.run/role-template: "true" + halo.run/hidden: "true" + rbac.authorization.halo.run/aggregate-to-authenticated: "true" +rules: + - nonResourceURLs: [ "/apis/api.wx.jiewen.run/tool-options" ] + verbs: [ "get" ] \ No newline at end of file diff --git a/src/main/resources/extensions/settings.yaml b/src/main/resources/extensions/settings.yaml new file mode 100644 index 0000000..bfc494f --- /dev/null +++ b/src/main/resources/extensions/settings.yaml @@ -0,0 +1,71 @@ +apiVersion: v1alpha1 +kind: Setting +metadata: + name: wx-config-settings +spec: + forms: + - group: basic + label: 基础设置 + formSchema: + - $formkit: attachment + name: searchIcon + label: 搜索栏旁图标 + required: true + - $formkit: text + name: appid + label: APPID + help: 请填写微信小程序的APPID + - $formkit: text + name: appSecret + label: APPSECRET + help: 请填写微信小程序的APPSECRET + - $formkit: text + name: openid + label: 微信号openid + help: 请填写微信小程序的openid,用于识别管理员 + - group: home + label: 首页设置 + formSchema: + - $formkit: repeater + name: carousel + label: 轮播图 + value: [ ] + max: 5 + min: 1 + children: + - $formkit: attachment + name: image + id: image + label: 图片 + value: "" + - $formkit: repeater + name: hot_category + label: 热门分类 + value: [ ] + max: 5 + min: 1 + children: + - $formkit: categorySelect + name: category + id: category + label: 选择分类 + value: "" + - group: about + label: 关于我的设置 + formSchema: + - $formkit: attachment + name: homeUserAvatar + label: 头像 + required: true + - $formkit: text + name: homeUserName + label: 昵称 + required: true + - $formkit: text + name: homeUserDesc + label: 个人简介 + required: true + - $formkit: attachment + name: homeUserQrCode + label: 二维码 + help: 点击后将跳出二维码 diff --git a/src/main/resources/plugin.yaml b/src/main/resources/plugin.yaml index 3326a11..66e6a62 100644 --- a/src/main/resources/plugin.yaml +++ b/src/main/resources/plugin.yaml @@ -2,19 +2,21 @@ apiVersion: plugin.halo.run/v1alpha1 kind: Plugin metadata: # The name defines how the plugin is invoked,A unique name - name: starter + name: wxConfig spec: enabled: true requires: ">=2.11.0" author: - name: Halo - website: https://github.com/halo-dev + name: Jiewenhuang + website: https://www.jiewen.run logo: logo.png # 'homepage' usually links to the GitHub repository of the plugin - homepage: https://github.com/halo-dev/plugin-starter + homepage: https://github.com/jiewenhuang/halo-plugin-wxConfig # 'displayName' explains what the plugin does in only a few words - displayName: "插件快速开始模板" - description: "这是一个插件快速开始模板" + settingName: wx-config-settings + configMapName: wx-config-configMap + displayName: "微信小程序设置" + description: "此插件没有任何实质作用,仅为配套微信小程序提供相应配置信息" license: - name: "GPL-3.0" - url: "https://github.com/halo-dev/plugin-starter/blob/main/LICENSE" + url: "https://github.com/jiewenhuang/halo-plugin-wxConfig/blob/main/LICENSE"