新增EVAL代码

This commit is contained in:
fofolee 2025-02-22 11:03:26 +08:00
parent 1fe478f373
commit d9bc4b4f34
2 changed files with 27 additions and 6 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="code-editor" :style="{ height: height }"> <div class="code-editor" :style="{ height: height + 'px' }">
<div <div
class="editor-container" class="editor-container"
:style="{ :style="{
@ -90,8 +90,8 @@ export default defineComponent({
}, },
// //
height: { height: {
type: String, type: Number,
default: "300px", default: 300,
}, },
// //
theme: { theme: {

View File

@ -4,21 +4,42 @@ export const scriptCommands = {
commands: [ commands: [
{ {
value: "injectJs", value: "injectJs",
label: "注入JS代码", label: "注入代码",
icon: "script", icon: "script",
description: "注入的代码js将在流程对应的位置直接运行。",
neverHasOutput: true, neverHasOutput: true,
isExpression: true, isExpression: true,
config: [ config: [
{ {
label: "JS脚本",
component: "CodeEditor", component: "CodeEditor",
language: "quickcommand", language: "quickcommand",
placeholder: placeholder:
"共享当前上下文支持utoolsquickcommandquickcomposer等接口", "和当前流程共享上下文变量、函数等支持utools、quickcommand、quickcomposer、nodejs的接口",
width: 12, width: 12,
}, },
], ],
}, },
{
value: `((code) => {return new Function("return " + code)()})`,
label: "eval代码",
description: "eval代码js并返回结果",
config: [
{
component: "CodeEditor",
language: "quickcommand",
height: 40,
hasAIAssistant: false,
placeholder:
"和当前流程共享上下文变量、函数等支持utools、quickcommand、quickcomposer、nodejs的接口。",
width: 12,
},
],
outputs: {
label: "结果",
suggestName: "evalResult",
typeName: "字符串",
},
},
{ {
value: "quickcommand.runCode", value: "quickcommand.runCode",
label: "运行脚本", label: "运行脚本",