mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-10-10 07:23:23 +08:00
runComposer自动保存的命令也进行简化处理
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
<script>
|
||||
import CommandComposer from "components/composer/CommandComposer.vue";
|
||||
import CommandRunResult from "components/CommandRunResult";
|
||||
import { findCommandByValue } from "js/composer/composerConfig";
|
||||
import { useCommandManager } from "js/commandManager.js";
|
||||
|
||||
export default {
|
||||
@@ -21,68 +20,17 @@ export default {
|
||||
setup() {
|
||||
const commandManager = useCommandManager();
|
||||
|
||||
const retoreToFullCommand = (command) => {
|
||||
const newCommand = window.lodashM.cloneDeep(command);
|
||||
const { flows } = newCommand;
|
||||
if (!flows) return newCommand;
|
||||
const newFlows = flows.map((flow) => ({
|
||||
...flow,
|
||||
commands: flow.commands.map((cmd) => {
|
||||
// 恢复所有属性
|
||||
const command = findCommandByValue(cmd.value);
|
||||
return {
|
||||
...command,
|
||||
...cmd,
|
||||
};
|
||||
}),
|
||||
}));
|
||||
return {
|
||||
...command,
|
||||
flows: newFlows,
|
||||
};
|
||||
};
|
||||
|
||||
const getLitedComposerCommand = (command) => {
|
||||
const { flows } = command;
|
||||
if (!flows) return command;
|
||||
const newFlows = flows.map((flow) => ({
|
||||
...flow,
|
||||
commands: flow.commands.map((cmd) => {
|
||||
const cmdCopy = { ...cmd };
|
||||
// 移除不必要保存的属性
|
||||
const uselessProps = [
|
||||
"config",
|
||||
"label",
|
||||
"component",
|
||||
"subCommands",
|
||||
"outputs",
|
||||
"options",
|
||||
"icon",
|
||||
"width",
|
||||
"placeholder",
|
||||
"summary",
|
||||
"type",
|
||||
];
|
||||
uselessProps.forEach((prop) => delete cmdCopy[prop]);
|
||||
return cmdCopy;
|
||||
}),
|
||||
}));
|
||||
return {
|
||||
...command,
|
||||
flows: newFlows,
|
||||
};
|
||||
};
|
||||
|
||||
const defaultCommand = commandManager.getDefaultCommand("quickcomposer");
|
||||
|
||||
commandManager.state.currentCommand = {
|
||||
...defaultCommand,
|
||||
...retoreToFullCommand(commandManager.state.currentCommand),
|
||||
...commandManager.getFullComposerCommand(
|
||||
commandManager.state.currentCommand
|
||||
),
|
||||
};
|
||||
|
||||
return {
|
||||
commandManager,
|
||||
getLitedComposerCommand,
|
||||
};
|
||||
},
|
||||
emits: ["editorEvent"],
|
||||
@@ -105,7 +53,7 @@ export default {
|
||||
return this.$emit(
|
||||
"editorEvent",
|
||||
"save",
|
||||
this.getLitedComposerCommand(command)
|
||||
this.commandManager.getLitedComposerCommand(command)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user