mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-28 20:02:44 +08:00
runComposer自动保存的命令也进行简化处理
This commit is contained in:
parent
ddd1fc11d7
commit
ca24afe4b2
@ -132,10 +132,15 @@ export default defineComponent({
|
||||
// 退出时保存RunCode和RunComposer的命令
|
||||
if (!["code", "composer"].includes(this.$route.name)) return;
|
||||
|
||||
const currentCommand = window.lodashM.cloneDeep(
|
||||
let currentCommand = window.lodashM.cloneDeep(
|
||||
this.commandManager.state.currentCommand
|
||||
);
|
||||
|
||||
if (this.$route.name === "composer") {
|
||||
currentCommand =
|
||||
this.commandManager.getLitedComposerCommand(currentCommand);
|
||||
}
|
||||
|
||||
dbManager.putDB(currentCommand, `cfg_${this.$route.name}History`);
|
||||
|
||||
this.$router.push("/");
|
||||
|
@ -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)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -3,6 +3,7 @@ import quickcommandParser from "js/common/quickcommandParser.js";
|
||||
import importAll from "js/common/importAll.js";
|
||||
import { utoolsFull, dbManager } from "js/utools.js";
|
||||
import { getUniqueId } from "js/common/uuid.js";
|
||||
import { findCommandByValue } from "js/composer/composerConfig";
|
||||
import programs from "js/options/programs.js";
|
||||
import outputTypes from "js/options/outputTypes.js";
|
||||
|
||||
@ -287,6 +288,58 @@ export function useCommandManager() {
|
||||
: quickcommandCommand;
|
||||
};
|
||||
|
||||
const getFullComposerCommand = (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,
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
state,
|
||||
getAllQuickCommands,
|
||||
@ -303,5 +356,7 @@ export function useCommandManager() {
|
||||
clearAllCommands,
|
||||
changeCurrentTag,
|
||||
getDefaultCommand,
|
||||
getFullComposerCommand,
|
||||
getLitedComposerCommand,
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user