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