1
This commit is contained in:
parent
34d72d4ed7
commit
0d8d887ac1
@ -1,5 +1,6 @@
|
|||||||
package com.qqchen.deploy.backend.deploy.dto.variables;
|
package com.qqchen.deploy.backend.deploy.dto.variables;
|
||||||
|
|
||||||
|
import com.qqchen.deploy.backend.workflow.annotation.CodeEditorConfig;
|
||||||
import com.qqchen.deploy.backend.workflow.annotation.SchemaProperty;
|
import com.qqchen.deploy.backend.workflow.annotation.SchemaProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -26,6 +27,17 @@ public class JenkinsJavaBuildVariables extends JenkinsBaseBuildVariables {
|
|||||||
required = true,
|
required = true,
|
||||||
format = "monaco-editor", // 使用 Monaco Editor
|
format = "monaco-editor", // 使用 Monaco Editor
|
||||||
defaultValue = "#!/bin/bash\n\necho \"Hello World\"",
|
defaultValue = "#!/bin/bash\n\necho \"Hello World\"",
|
||||||
|
codeEditor = @CodeEditorConfig(
|
||||||
|
language = "shell",
|
||||||
|
theme = "vs-dark",
|
||||||
|
minimap = false,
|
||||||
|
lineNumbers = true,
|
||||||
|
wordWrap = true,
|
||||||
|
fontSize = 14,
|
||||||
|
tabSize = 2,
|
||||||
|
autoComplete = true,
|
||||||
|
folding = true
|
||||||
|
),
|
||||||
order = 3
|
order = 3
|
||||||
)
|
)
|
||||||
private String script;
|
private String script;
|
||||||
|
|||||||
@ -8,4 +8,6 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class JenkinsNodeJsBuildVariables extends JenkinsBaseBuildVariables {
|
public class JenkinsNodeJsBuildVariables extends JenkinsBaseBuildVariables {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,78 @@
|
|||||||
|
package com.qqchen.deploy.backend.workflow.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码编辑器配置注解,用于配置Monaco Editor等代码编辑器的行为
|
||||||
|
*
|
||||||
|
* <p>使用示例:
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* @SchemaProperty(
|
||||||
|
* title = "脚本代码",
|
||||||
|
* description = "脚本代码",
|
||||||
|
* format = "monaco-editor",
|
||||||
|
* codeEditor = @CodeEditorConfig(
|
||||||
|
* language = "shell",
|
||||||
|
* theme = "vs-dark",
|
||||||
|
* minimap = false,
|
||||||
|
* lineNumbers = true,
|
||||||
|
* wordWrap = true
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
* private String script;
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Target({})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface CodeEditorConfig {
|
||||||
|
/**
|
||||||
|
* 编辑器语言
|
||||||
|
* 支持的语言:java, javascript, typescript, python, shell等
|
||||||
|
*/
|
||||||
|
String language() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑器主题
|
||||||
|
* 支持的主题:vs, vs-dark, hc-black
|
||||||
|
*/
|
||||||
|
String theme() default "vs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否显示代码小地图
|
||||||
|
*/
|
||||||
|
boolean minimap() default true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否显示行号
|
||||||
|
*/
|
||||||
|
boolean lineNumbers() default true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否自动换行
|
||||||
|
*/
|
||||||
|
boolean wordWrap() default false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑器字体大小
|
||||||
|
*/
|
||||||
|
int fontSize() default 14;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tab键缩进空格数
|
||||||
|
*/
|
||||||
|
int tabSize() default 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用自动完成
|
||||||
|
*/
|
||||||
|
boolean autoComplete() default true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否显示代码折叠
|
||||||
|
*/
|
||||||
|
boolean folding() default true;
|
||||||
|
}
|
||||||
@ -98,4 +98,9 @@ public @interface SchemaProperty {
|
|||||||
* 字段排序,值越小越靠前
|
* 字段排序,值越小越靠前
|
||||||
*/
|
*/
|
||||||
int order() default Integer.MAX_VALUE;
|
int order() default Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码编辑器配置,用于配置Monaco Editor等代码编辑器的行为
|
||||||
|
*/
|
||||||
|
CodeEditorConfig codeEditor() default @CodeEditorConfig;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.qqchen.deploy.backend.workflow.dto.definition.node.panelVariables;
|
package com.qqchen.deploy.backend.workflow.dto.definition.node.panelVariables;
|
||||||
|
|
||||||
|
import com.qqchen.deploy.backend.workflow.annotation.CodeEditorConfig;
|
||||||
import com.qqchen.deploy.backend.workflow.annotation.SchemaProperty;
|
import com.qqchen.deploy.backend.workflow.annotation.SchemaProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@ -33,6 +34,17 @@ public class ScriptNodePanelVariables extends BaseNodePanelVariables {
|
|||||||
description = "脚本代码",
|
description = "脚本代码",
|
||||||
required = true,
|
required = true,
|
||||||
format = "monaco-editor",
|
format = "monaco-editor",
|
||||||
|
codeEditor = @CodeEditorConfig(
|
||||||
|
language = "shell",
|
||||||
|
theme = "vs-dark",
|
||||||
|
minimap = false,
|
||||||
|
lineNumbers = true,
|
||||||
|
wordWrap = true,
|
||||||
|
fontSize = 14,
|
||||||
|
tabSize = 2,
|
||||||
|
autoComplete = true,
|
||||||
|
folding = true
|
||||||
|
),
|
||||||
order = 20
|
order = 20
|
||||||
)
|
)
|
||||||
private String script;
|
private String script;
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|||||||
import com.qqchen.deploy.backend.workflow.annotation.SchemaProperty;
|
import com.qqchen.deploy.backend.workflow.annotation.SchemaProperty;
|
||||||
import com.qqchen.deploy.backend.workflow.annotation.SchemaPropertyDataSource;
|
import com.qqchen.deploy.backend.workflow.annotation.SchemaPropertyDataSource;
|
||||||
import com.qqchen.deploy.backend.workflow.annotation.SchemaPropertyDataSourceParam;
|
import com.qqchen.deploy.backend.workflow.annotation.SchemaPropertyDataSourceParam;
|
||||||
|
import com.qqchen.deploy.backend.workflow.annotation.CodeEditorConfig;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -62,6 +63,23 @@ public class GenerateSchemaUtils {
|
|||||||
}
|
}
|
||||||
if (!annotation.format().isEmpty()) {
|
if (!annotation.format().isEmpty()) {
|
||||||
property.put("format", annotation.format());
|
property.put("format", annotation.format());
|
||||||
|
|
||||||
|
// 处理代码编辑器配置
|
||||||
|
if (annotation.format().endsWith("-editor")) {
|
||||||
|
CodeEditorConfig editorConfig = annotation.codeEditor();
|
||||||
|
if (editorConfig != null && !editorConfig.language().isEmpty()) {
|
||||||
|
ObjectNode configNode = property.putObject("editorConfig");
|
||||||
|
configNode.put("language", editorConfig.language());
|
||||||
|
configNode.put("theme", editorConfig.theme());
|
||||||
|
configNode.put("minimap", editorConfig.minimap());
|
||||||
|
configNode.put("lineNumbers", editorConfig.lineNumbers());
|
||||||
|
configNode.put("wordWrap", editorConfig.wordWrap());
|
||||||
|
configNode.put("fontSize", editorConfig.fontSize());
|
||||||
|
configNode.put("tabSize", editorConfig.tabSize());
|
||||||
|
configNode.put("autoComplete", editorConfig.autoComplete());
|
||||||
|
configNode.put("folding", editorConfig.folding());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (annotation.required()) {
|
if (annotation.required()) {
|
||||||
required.add(field.getName());
|
required.add(field.getName());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user