From 519b2742598ca6f2f32fe8d3525519ac37e133e3 Mon Sep 17 00:00:00 2001 From: wenjing-xin Date: Sun, 16 Jun 2024 16:03:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E5=AE=B9=E9=A6=96=E8=A1=8C=E7=BC=A9?= =?UTF-8?q?=E8=BF=9B=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xin/wenjing/blogHao/entity/Settings.java | 11 ++ .../processor/GlobalInjectProcessor.java | 7 + src/main/resources/extensions/settings.yaml | 27 ++- ui/src/index.ts | 24 +-- ui/src/views/HomeView.vue | 169 ------------------ 5 files changed, 45 insertions(+), 193 deletions(-) delete mode 100644 ui/src/views/HomeView.vue diff --git a/src/main/java/xin/wenjing/blogHao/entity/Settings.java b/src/main/java/xin/wenjing/blogHao/entity/Settings.java index 8c14761..e0a7f70 100644 --- a/src/main/java/xin/wenjing/blogHao/entity/Settings.java +++ b/src/main/java/xin/wenjing/blogHao/entity/Settings.java @@ -31,6 +31,7 @@ public static class CopyAdd{ public static class MiniTool{ public final static String GROUP_NAME = "miniTools"; private ContentSpace contentSpace; + private ContentIndent contentIndent; } /** @@ -43,4 +44,14 @@ public static class ContentSpace{ private String scanContent; } + /** + * 小工具配置的子内容 + * 文章内容首行缩进 + */ + @Data + public static class ContentIndent{ + private boolean enableContentIndent; + private String indentNodeName; + } + } diff --git a/src/main/java/xin/wenjing/blogHao/processor/GlobalInjectProcessor.java b/src/main/java/xin/wenjing/blogHao/processor/GlobalInjectProcessor.java index 05630c3..1262dd8 100644 --- a/src/main/java/xin/wenjing/blogHao/processor/GlobalInjectProcessor.java +++ b/src/main/java/xin/wenjing/blogHao/processor/GlobalInjectProcessor.java @@ -59,6 +59,13 @@ private String finalScript(ITemplateContext context) { injectCode.append(ScriptContentUtils.panguScript(miniTool)); } + // 段落内容首行缩进 + if(miniTool.getContentIndent().isEnableContentIndent()){ + injectCode.append(""" + + """.formatted(miniTool.getContentIndent().getIndentNodeName())); + } + return injectCode.toString(); } } diff --git a/src/main/resources/extensions/settings.yaml b/src/main/resources/extensions/settings.yaml index 621e6a4..0634a95 100644 --- a/src/main/resources/extensions/settings.yaml +++ b/src/main/resources/extensions/settings.yaml @@ -73,4 +73,29 @@ spec: name: scanContent value: "pangu.spacingElementByTagName('body');" rows: 3 - help: 写法参考 https://github.com/vinta/pangu.js \ No newline at end of file + help: 写法参考 https://github.com/vinta/pangu.js + - $formkit: group + name: contentIndent + label: 文本内容首行缩进 + help: 开启后则在段落的首行缩进两个空格 + value: + enableContentIndent: false + indentNodeName: + children: + - $formkit: radio + name: enableContentIndent + key: enableContentIndent + id: enableContentIndent + help: 是否启用 + value: false + options: + - label: 启用 + value: true + - label: 禁用 + value: false + - $formkit: text + if: $get(enableContentIndent).value + label: 内容缩进的节点类名或者ID名 + name: indentNodeName + value: "#post" + help: 根据自己使用的主题选择要适配的内容节点 \ No newline at end of file diff --git a/ui/src/index.ts b/ui/src/index.ts index c8dfd78..cdedc2d 100644 --- a/ui/src/index.ts +++ b/ui/src/index.ts @@ -1,29 +1,7 @@ import { definePlugin } from "@halo-dev/console-shared"; -import HomeView from "./views/HomeView.vue"; -import { IconPlug } from "@halo-dev/components"; -import { markRaw } from "vue"; export default definePlugin({ components: {}, - routes: [ - { - parentName: "Root", - route: { - path: "/example", - name: "Example", - component: HomeView, - meta: { - title: "示例页面", - searchable: true, - menu: { - name: "示例页面", - group: "示例分组", - icon: markRaw(IconPlug), - priority: 0, - }, - }, - }, - }, - ], + routes: [], extensionPoints: {}, }); diff --git a/ui/src/views/HomeView.vue b/ui/src/views/HomeView.vue deleted file mode 100644 index 9b9cb0a..0000000 --- a/ui/src/views/HomeView.vue +++ /dev/null @@ -1,169 +0,0 @@ - - - - -