添加清空流程功能

This commit is contained in:
fofolee 2025-02-16 15:42:49 +08:00
parent fec8eb3f09
commit 9f7d8dde05
2 changed files with 26 additions and 0 deletions

View File

@ -146,6 +146,11 @@ export default defineComponent({
}, },
]; ];
const clearFlows = () => {
updateFlows(defaultFlow);
activeTab.value = "main";
};
if (!props.modelValue.flows || props.modelValue.flows.length === 0) { if (!props.modelValue.flows || props.modelValue.flows.length === 0) {
updateFlows(defaultFlow); updateFlows(defaultFlow);
} }
@ -258,6 +263,7 @@ export default defineComponent({
activeTab, activeTab,
getOutputVariables, getOutputVariables,
updateFlows, updateFlows,
clearFlows,
}; };
}, },
data() { data() {
@ -373,6 +379,9 @@ export default defineComponent({
this.addFlow(payload); this.addFlow(payload);
} }
break; break;
case "clear":
this.clearFlows();
break;
default: default:
this.$emit("action", type, payload); this.$emit("action", type, payload);
} }

View File

@ -54,6 +54,15 @@
> >
<q-tooltip>保存</q-tooltip> <q-tooltip>保存</q-tooltip>
</q-btn> </q-btn>
<q-btn
dense
flat
icon="delete_sweep"
@click="handleClear"
v-if="!disabledButtons.includes('clear')"
>
<q-tooltip>清空所有流程</q-tooltip>
</q-btn>
<q-btn <q-btn
flat flat
dense dense
@ -138,6 +147,14 @@ export default defineComponent({
const code = generateFlowsCode(this.flows); const code = generateFlowsCode(this.flows);
this.$emit("action", "apply", code); this.$emit("action", "apply", code);
}, },
handleClear() {
quickcommand
.showConfirmBox("确定要清空所有流程吗?", "FBI WARNING")
.then((isConfirm) => {
if (!isConfirm) return;
this.$emit("action", "clear");
});
},
}, },
}); });
</script> </script>