Skip to content

Commit

Permalink
initialization:First Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jiewenhuang committed Apr 10, 2024
1 parent 29c3d34 commit ba5431c
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 41 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -52,5 +52,5 @@ build {
}

halo {
version = '2.11'
version = '2.14'
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pluginManagement {
gradlePluginPortal()
}
}
rootProject.name = 'plugin-starter'
rootProject.name = 'wx-config'

31 changes: 0 additions & 31 deletions src/main/java/run/halo/starter/StarterPlugin.java

This file was deleted.

27 changes: 27 additions & 0 deletions src/main/java/run/jiewen/tool/ToolConfiguration.java
Original file line number Diff line number Diff line change
@@ -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<ServerResponse> 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();
}
}
20 changes: 20 additions & 0 deletions src/main/java/run/jiewen/tool/WxTool.java
Original file line number Diff line number Diff line change
@@ -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("插件停止!");
}
}
11 changes: 11 additions & 0 deletions src/main/resources/extensions/roleTemplates.yaml
Original file line number Diff line number Diff line change
@@ -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" ]
71 changes: 71 additions & 0 deletions src/main/resources/extensions/settings.yaml
Original file line number Diff line number Diff line change
@@ -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: 点击后将跳出二维码
16 changes: 9 additions & 7 deletions src/main/resources/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit ba5431c

Please sign in to comment.