针对某些运行较慢的命令,添加载入界面

This commit is contained in:
fofolee 2025-01-12 12:44:52 +08:00
parent e13f778f2a
commit 2fcad53ef9

View File

@ -17,6 +17,9 @@
/>
</div>
</div>
<q-inner-loading :showing="hasCommandNeedLoading && $root.isRunningCommand">
<q-spinner-cube size="50px" color="primary" />
</q-inner-loading>
</div>
</template>
@ -70,6 +73,7 @@ export default defineComponent({
data() {
return {
availableCommands,
hasCommandNeedLoading: false,
};
},
emits: ["use-composer", "update:modelValue"],
@ -87,11 +91,23 @@ export default defineComponent({
return generateCode(this.commandFlow);
},
handleComposer(type, flow) {
if (type === "save") return this.saveFlow();
if (type === "load") return this.loadFlow();
const code = flow ? generateCode(flow) : generateCode(this.commandFlow);
this.$emit("use-composer", { type, code });
if (type !== "run") return this.$emit("update:modelValue", false);
switch (type) {
case "save":
return this.saveFlow();
case "load":
return this.loadFlow();
case "run":
return this.runFlow(flow);
default:
this.$emit("use-composer", { type, code });
return this.$emit("update:modelValue", false);
}
},
// flow
runFlow(flow) {
this.hasCommandNeedLoading = this.findCommandNeedLoading(flow);
const code = generateCode(flow || this.commandFlow);
this.$emit("use-composer", { type: "run", code });
if (!code.includes("console.log")) quickcommand.showMessageBox("已运行");
},
saveFlow() {
@ -129,6 +145,16 @@ export default defineComponent({
};
});
},
findCommandNeedLoading(flow) {
//
// showLoading
if (!flow) return;
return flow.some(
(cmd) =>
cmd.showLoading ||
cmd.subCommands?.find((c) => c.value === cmd.value)?.showLoading
);
},
},
});
</script>