@@ -228,6 +233,10 @@ export default defineComponent({
type: String,
default: "arrow_drop_down",
},
+ label: {
+ type: String,
+ default: "",
+ },
},
});
diff --git a/src/components/composer/script/ScriptEditor.vue b/src/components/composer/script/ScriptEditor.vue
index 60b6a72..bef3d96 100644
--- a/src/components/composer/script/ScriptEditor.vue
+++ b/src/components/composer/script/ScriptEditor.vue
@@ -35,18 +35,21 @@
-
-
- 插入变量
-
-
-
-
+
+
+
+ 引入当前流程的变量到代码中
+
+ 注意,所有变量的值都是以字符串的形式传入,不要删除两边的引号
+
+
@@ -54,6 +57,7 @@
class="col-3"
filled
dense
+ options-dense
v-if="!isCodeSnippet"
:model-value="argvs.scriptCode"
@update:modelValue="updateArgvs('scriptCode', $event)"
@@ -66,6 +70,7 @@
class="col-3"
filled
dense
+ options-dense
v-if="!isCodeSnippet"
:model-value="argvs.outputCode"
@update:modelValue="updateArgvs('outputCode', $event)"
@@ -115,6 +120,7 @@
label="Windows终端"
filled
dense
+ options-dense
emit-value
map-options
class="col-6"
@@ -127,6 +133,7 @@
label="macOS终端"
filled
dense
+ options-dense
emit-value
map-options
class="col-6"
@@ -228,11 +235,18 @@ export default defineComponent({
}
},
generateCode(argvs = this.argvs) {
- const variables = argvs.code.match(/___([^_]+?)___/g);
+ const variables = argvs.code.match(/"?___([^_]+?)___"?/g);
const replaceStr =
variables
?.map((variable) => {
- return `.replace("${variable}", ${variable.slice(3, -3)})`;
+ if (variable.startsWith('"') && variable.endsWith('"')) {
+ return `.replace('${variable}', JSON.stringify(${variable.slice(
+ 4,
+ -4
+ )}))`;
+ } else {
+ return `.replace('${variable}', ${variable.slice(3, -3)})`;
+ }
})
.join("") || "";
if (this.isCodeSnippet) {
@@ -294,7 +308,10 @@ export default defineComponent({
});
},
insertVariable(_, variable) {
- this.$refs.codeEditor.replaceEditorSelection("___" + variable + "___");
+ const replaceVar = this.isCodeSnippet
+ ? "___" + variable + "___"
+ : '"___' + variable + '___"';
+ this.$refs.codeEditor.replaceEditorSelection(replaceVar);
},
},
mounted() {
@@ -312,4 +329,9 @@ export default defineComponent({
flex-direction: column;
gap: 8px;
}
+
+.variable-list-field :deep(.q-field__control) {
+ padding: 0;
+ color: var(--utools-font-color);
+}