diff --git a/src/components/composer/ComposerCard.vue b/src/components/composer/ComposerCard.vue
index fd9ce7f..5e9212a 100644
--- a/src/components/composer/ComposerCard.vue
+++ b/src/components/composer/ComposerCard.vue
@@ -146,12 +146,10 @@ export default defineComponent({
},
},
setup(props) {
- const getCurrentExistingVar = inject("getCurrentExistingVar");
// 创建响应式的commandIndex
const commandIndex = computed(() => props.commandIndex);
// 主要用于VariableInput组件的变量选择下拉框,获取当前命令的索引
provide("commandIndex", commandIndex);
- return { getCurrentExistingVar };
},
methods: {
handleOutputVariableUpdate(result) {
diff --git a/src/components/composer/ComposerFlow.vue b/src/components/composer/ComposerFlow.vue
index 46d6537..cddeea0 100644
--- a/src/components/composer/ComposerFlow.vue
+++ b/src/components/composer/ComposerFlow.vue
@@ -90,10 +90,6 @@ export default defineComponent({
default: true,
},
},
- setup() {
- const getCurrentExistingVar = inject("getCurrentExistingVar");
- return { getCurrentExistingVar };
- },
emits: ["update:modelValue", "add-command", "action"],
data() {
return {
diff --git a/src/components/composer/FlowTabs.vue b/src/components/composer/FlowTabs.vue
index e301be4..f7e18e0 100644
--- a/src/components/composer/FlowTabs.vue
+++ b/src/components/composer/FlowTabs.vue
@@ -151,7 +151,7 @@ export default defineComponent({
const getOutputVariables = (flow = getCurrentFlow()) => {
const variables = [];
for (const [index, cmd] of flow.commands.entries()) {
- if (cmd.outputVariable) {
+ if (cmd.outputVariable && cmd.asyncMode !== "then") {
const { name, details = {} } = cmd.outputVariable;
variables.push(
...[name, ...Object.values(details)].map((variable) => ({
@@ -199,12 +199,6 @@ export default defineComponent({
provide("getCurrentVariables", getCurrentVariables);
- const getCurrentExistingVar = () => {
- return [...getCurrentVariables(), ...getCurrentFunctions()];
- };
-
- provide("getCurrentExistingVar", getCurrentExistingVar);
-
return {
flows,
mainFlow,
@@ -352,6 +346,7 @@ export default defineComponent({
"placeholder",
"summary",
"type",
+ "defaultOutputVariable",
];
uselessProps.forEach((prop) => delete cmdCopy[prop]);
return cmdCopy;
diff --git a/src/components/composer/MultiParams.vue b/src/components/composer/MultiParams.vue
index 836a763..0b15bed 100644
--- a/src/components/composer/MultiParams.vue
+++ b/src/components/composer/MultiParams.vue
@@ -3,7 +3,7 @@
@@ -204,6 +204,15 @@ export default defineComponent({
width: `calc(${columnWidth}% - var(--grid-gap))`,
};
},
+ updateFuncName(value) {
+ this.funcName = value;
+ // 如果切换了子命令,更新输出变量
+ const selectSubCommand = this.getSelectSubCommand(value);
+ if (!selectSubCommand) return;
+ const newModelValue = { ...this.modelValue, value: value };
+ delete newModelValue.outputVariable;
+ this.$emit("update:modelValue", newModelValue);
+ },
},
mounted() {
const argvs = this.modelValue.argvs || this.defaultArgvs;
diff --git a/src/components/composer/card/OutputEditor.vue b/src/components/composer/card/OutputEditor.vue
index 20fab7d..8eb6c97 100644
--- a/src/components/composer/card/OutputEditor.vue
+++ b/src/components/composer/card/OutputEditor.vue
@@ -10,6 +10,7 @@
cmd.value === this.command.value
);
},
+ defaultOutputVariable() {
+ return (
+ this.currentSubCommand?.defaultOutputVariable ||
+ this.command.defaultOutputVariable
+ );
+ },
commandName() {
return this.currentSubCommand.label || this.command.label;
},
@@ -158,35 +165,36 @@ export default defineComponent({
},
watch: {
"command.outputVariable": {
- immediate: true,
- deep: true,
- handler(newValue) {
- this.initOutputVars(newValue);
+ handler(value) {
+ this.initOutputVars(value);
},
+ immediate: true,
},
"command.asyncMode": {
- immediate: true,
- handler(newValue) {
- this.asyncMode = newValue;
+ handler(value) {
+ this.asyncMode = value;
},
+ immediate: true,
},
"command.callbackFunc": {
- immediate: true,
- handler(newValue) {
- this.callbackFunc = newValue;
+ handler(value) {
+ this.callbackFunc = value;
},
+ immediate: true,
},
},
methods: {
- initOutputVars(outputVariable) {
+ initOutputVars(value) {
+ const outputVariable = value || this.defaultOutputVariable;
// 初始化完整输出变量名
- if (!outputVariable) return;
- this.simpleOutputVar = outputVariable.name || "";
-
- if (this.currentOutputs) {
- // 初始化详细输出变量,直接使用扁平化的结构
- this.outputVars = outputVariable?.details || {};
+ if (!outputVariable) {
+ this.simpleOutputVar = "";
+ this.outputVars = {};
+ return;
}
+
+ this.simpleOutputVar = outputVariable.name;
+ this.outputVars = outputVariable.details;
},
handleConfirm() {
const outputVariable = {};
diff --git a/src/components/composer/card/output/OutputField.vue b/src/components/composer/card/output/OutputField.vue
index 3ec7bcc..2f30704 100644
--- a/src/components/composer/card/output/OutputField.vue
+++ b/src/components/composer/card/output/OutputField.vue
@@ -13,6 +13,21 @@
{{ label }}
+
+
+ 取名困难症?点我!
+
@@ -118,7 +162,7 @@ export default defineComponent({
}
.variable-list-btn {
- padding: 0 12px;
+ padding: 0 12px 0 3px;
}
/* 去掉下拉按钮的焦点效果 */
diff --git a/src/components/composer/card/output/OutputStructure.vue b/src/components/composer/card/output/OutputStructure.vue
index 917f5f4..0440ff1 100644
--- a/src/components/composer/card/output/OutputStructure.vue
+++ b/src/components/composer/card/output/OutputStructure.vue
@@ -11,6 +11,7 @@
@update:model-value="updateField(subKey, $event)"
:label="subOutput.label"
:placeholder="subOutput.placeholder"
+ :suggest-name="subOutput.suggestName"
autofocus
/>
@@ -25,6 +26,7 @@
@update:model-value="updateField('', $event)"
:label="output.label"
:placeholder="output.placeholder"
+ :suggest-name="output.suggestName"
autofocus
/>
@@ -78,18 +80,23 @@ export default defineComponent({
default: () => ({}),
},
},
+ data() {
+ return {
+ fixedFields: ["label", "placeholder", "suggestName"],
+ };
+ },
emits: ["update:modelValue"],
computed: {
hasNestedFields() {
if (!this.output) return false;
return Object.keys(this.output).some(
- (key) => key !== "label" && key !== "placeholder"
+ (key) => !this.fixedFields.includes(key)
);
},
getNestedFields() {
const fields = {};
Object.entries(this.output).forEach(([key, value]) => {
- if (key !== "label" && key !== "placeholder") {
+ if (!this.fixedFields.includes(key)) {
fields[key] = value;
}
});
diff --git a/src/js/composer/commands/macosCommands.js b/src/js/composer/commands/macosCommands.js
index c66e66e..492adfc 100644
--- a/src/js/composer/commands/macosCommands.js
+++ b/src/js/composer/commands/macosCommands.js
@@ -15,31 +15,46 @@ export const macosCommands = {
icon: "front_hand",
outputs: {
label: "前台应用信息",
+ suggestName: "frontmostApp",
structure: {
- name: { label: "应用名称" },
- displayedName: { label: "应用显示名称" },
- path: { label: "应用路径" },
- version: { label: "应用版本" },
- pid: { label: "应用进程ID" },
- backgroundOnly: { label: "是否后台运行" },
- visible: { label: "是否可见" },
- frontmost: { label: "是否前台运行" },
+ name: { label: "应用名称", suggestName: "appName" },
+ displayedName: {
+ label: "应用显示名称",
+ suggestName: "appDisplayName",
+ },
+ path: { label: "应用路径", suggestName: "appPath" },
+ version: { label: "应用版本", suggestName: "appVersion" },
+ pid: { label: "应用进程ID", suggestName: "appPid" },
+ backgroundOnly: {
+ label: "是否后台运行",
+ suggestName: "appBackgroundOnly",
+ },
+ visible: { label: "是否可见", suggestName: "appVisible" },
+ frontmost: { label: "是否前台运行", suggestName: "appFrontmost" },
window: {
label: "窗口信息",
- name: { label: "窗口名称" },
- title: { label: "窗口标题" },
- index: { label: "窗口索引" },
+ name: { label: "窗口名称", suggestName: "windowName" },
+ title: { label: "窗口标题", suggestName: "windowTitle" },
+ index: { label: "窗口索引", suggestName: "windowIndex" },
position: {
label: "窗口位置",
placeholder:
"数组, 第一个元素是 x 坐标,第二个元素是 y 坐标",
+ suggestName: "windowPosition",
},
size: {
label: "窗口大小",
placeholder: "数组, 第一个元素是宽度,第二个元素是高度",
+ suggestName: "windowSize",
+ },
+ minimized: {
+ label: "是否最小化",
+ suggestName: "windowMinimized",
+ },
+ fullscreen: {
+ label: "是否全屏",
+ suggestName: "windowFullscreen",
},
- minimized: { label: "是否最小化" },
- fullscreen: { label: "是否全屏" },
},
},
},
@@ -48,6 +63,10 @@ export const macosCommands = {
value: "quickcomposer.macos.app.getRunningApps",
label: "获取活动应用",
icon: "list",
+ outputs: {
+ label: "活动应用列表(数组)",
+ suggestName: "runningApps",
+ },
},
{
value: "quickcomposer.macos.app.launch",