简化RunCode编码参数结构,新增ScriptEditor组件,优化CodeEditor代码提示

This commit is contained in:
fofolee
2025-01-25 13:57:14 +08:00
parent 680360ef2c
commit 1d9a675803
8 changed files with 472 additions and 97 deletions

View File

@@ -55,3 +55,7 @@ export const SelectListEditor = defineAsyncComponent(() =>
export const ReturnEditor = defineAsyncComponent(() =>
import("components/composer/script/ReturnEditor.vue")
);
export const ScriptEditor = defineAsyncComponent(() =>
import("components/composer/script/ScriptEditor.vue")
);

View File

@@ -311,6 +311,7 @@ export const browserCommands = {
{
label: "脚本内容",
component: "CodeEditor",
language: "webjavascript",
icon: "code",
width: 12,
placeholder: "输入JavaScript代码使用return返回结果",
@@ -382,6 +383,7 @@ export const browserCommands = {
config: [
{
component: "CodeEditor",
language: "css",
icon: "style",
width: 12,
placeholder: "输入CSS代码",

View File

@@ -1,26 +1,10 @@
import programs from "js/options/programs";
export const scriptCommands = {
label: "编程相关",
icon: "integration_instructions",
commands: [
{
value: "",
label: "赋值",
icon: "script",
outputVariable: "value",
saveOutput: true,
config: [
{
label: "值或表达式",
component: "VariableInput",
width: 12,
},
],
},
{
value: "injectJs",
label: "注入JS脚本",
label: "注入JS代码",
icon: "script",
neverHasOutput: true,
isExpression: true,
@@ -28,6 +12,7 @@ export const scriptCommands = {
{
label: "JS脚本",
component: "CodeEditor",
language: "quickcommand",
placeholder:
"共享当前上下文支持utoolsquickcommandquickcomposer等接口",
width: 12,
@@ -36,53 +21,10 @@ export const scriptCommands = {
},
{
value: "quickcommand.runCode",
label: "执行代码",
icon: "script",
label: "运行脚本",
component: "ScriptEditor",
desc: "运行各种编程语言的代码",
isAsync: true,
outputVariable: "result",
saveOutput: true,
config: [
{
label: "脚本",
component: "CodeEditor",
placeholder: "需要本机安装了对应的解释器/编译器",
width: 12,
},
{
component: "OptionEditor",
width: 12,
options: {
language: {
label: "语言",
component: "QSelect",
icon: "language",
options: Object.keys(programs).slice(2, -1),
width: 8,
},
runInTerminal: {
label: "终端运行",
icon: "terminal",
component: "CheckButton",
width: 4,
},
args: {
topLabel: "参数",
icon: "data_array",
component: "ArrayEditor",
width: 12,
},
charset: {
label: "编码",
icon: "abc",
component: "DictEditor",
options: {
optionKeys: ["scriptCode", "outputCode"],
},
width: 12,
},
},
},
],
},
{
value: "return",