diff --git a/src/components/editor/composer/CommandComposer.vue b/src/components/editor/composer/CommandComposer.vue
index 9ec4aa5..e585a55 100644
--- a/src/components/editor/composer/CommandComposer.vue
+++ b/src/components/editor/composer/CommandComposer.vue
@@ -95,8 +95,8 @@ export default defineComponent({
generateFlowCode() {
return generateCode(this.commandFlow);
},
- handleComposer(type) {
- const code = this.generateFlowCode();
+ handleComposer(type, flow) {
+ const code = flow ? generateCode(flow) : generateCode(this.commandFlow);
this.$emit("use-composer", { type, code });
if (type !== "run") this.$emit("update:modelValue", false);
},
diff --git a/src/components/editor/composer/ComposerCard.vue b/src/components/editor/composer/ComposerCard.vue
index b099f3f..8def119 100644
--- a/src/components/editor/composer/ComposerCard.vue
+++ b/src/components/editor/composer/ComposerCard.vue
@@ -61,6 +61,19 @@
+
+
+ 单独运行此命令并打印输出
+
+
@@ -145,7 +163,7 @@ export default defineComponent({
showKeyRecorder: false,
};
},
- emits: ["remove", "toggle-output", "update:argv", "update:command"],
+ emits: ["remove", "toggle-output", "update:argv", "update:command", "run"],
computed: {
saveOutputLocal: {
get() {
@@ -256,6 +274,30 @@ export default defineComponent({
// 发出更新事件
this.$emit("update:command", updatedCommand);
},
+ handleArgvChange(key, value) {
+ // 收集所有参数的当前值
+ const args = this.command.config.reduce((acc, item) => {
+ acc[item.key] = item.key === key ? value : item.value || "";
+ return acc;
+ }, {});
+
+ // 按照配置顺序拼接参数值
+ const argv = this.command.config
+ .map((item) => args[item.key])
+ .filter(Boolean)
+ .join(",");
+
+ this.$emit("update:argv", argv);
+ },
+ runCommand() {
+ // 创建一个带临时变量的命令副本
+ const tempCommand = {
+ ...this.command,
+ outputVariable: this.command.outputVariable || `temp_${Date.now()}`,
+ saveOutput: true,
+ };
+ this.$emit("run", tempCommand);
+ },
},
mounted() {
this.$el.classList.add("composer-card-enter-from");
@@ -386,19 +428,28 @@ export default defineComponent({
color: var(--q-primary);
}
-/* 移除按钮样式 */
+/* 按钮样式 */
+.run-btn,
.remove-btn {
opacity: 0.5;
transition: all 0.3s ease;
font-size: 18px;
}
+.run-btn:hover,
.remove-btn:hover {
opacity: 1;
- color: var(--q-negative);
transform: scale(1.05);
}
+.run-btn:hover {
+ color: var(--q-positive);
+}
+
+.remove-btn:hover {
+ color: var(--q-negative);
+}
+
/* 暗色模式适配 */
.body--dark .output-section :deep(.q-field) {
background: rgba(255, 255, 255, 0.03);
@@ -451,4 +502,16 @@ export default defineComponent({
.output-section :deep(.q-field--focused .q-icon) {
opacity: 1;
}
+
+/* 参数项样式 */
+.param-item {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+}
+
+/* 当参数项换行时的间距 */
+.param-item :deep(.q-field) {
+ margin-bottom: 0;
+}
diff --git a/src/components/editor/composer/ComposerFlow.vue b/src/components/editor/composer/ComposerFlow.vue
index d9bae8b..296f98c 100644
--- a/src/components/editor/composer/ComposerFlow.vue
+++ b/src/components/editor/composer/ComposerFlow.vue
@@ -46,6 +46,7 @@
@toggle-output="toggleSaveOutput(index)"
@update:argv="(val) => handleArgvChange(index, val)"
@update:command="(val) => updateCommand(index, val)"
+ @run="handleRunCommand"
/>
@@ -242,6 +243,18 @@ export default defineComponent({
};
this.$emit("update:modelValue", newCommands);
},
+ handleRunCommand(command) {
+ // 创建一个临时的命令流程
+ const tempFlow = [
+ command,
+ {
+ value: "console.log",
+ argv: command.outputVariable,
+ },
+ ];
+ // 触发运行事件
+ this.$emit("action", "run", tempFlow);
+ },
},
});