@@ -74,6 +74,7 @@ import ChainStyles from "./flow/ChainStyles.vue";
7474import EmptyFlow from " ./flow/EmptyFlow.vue" ;
7575import DropArea from " ./flow/DropArea.vue" ;
7676import { findCommandByValue } from " js/composer/composerConfig" ;
77+ import { processVariable } from " js/composer/variableManager" ;
7778
7879export default defineComponent ({
7980 name: " ComposerFlow" ,
@@ -96,11 +97,11 @@ export default defineComponent({
9697 required: true ,
9798 },
9899 },
99- emits: [" update:modelValue" , " add-command" , " action" ],
100100 setup () {
101- const removeVariable = inject (" removeVariable " );
102- return { removeVariable };
101+ const getCurrentVariables = inject (" getCurrentVariables " );
102+ return { getCurrentVariables };
103103 },
104+ emits: [" update:modelValue" , " add-command" , " action" ],
104105 data () {
105106 return {
106107 dragIndex: - 1 ,
@@ -261,13 +262,17 @@ export default defineComponent({
261262 } catch (error) {}
262263 },
263264 createNewCommand (parsedAction ) {
264- return {
265+ const newCommand = {
265266 ... parsedAction,
266267 id: this .getUniqueId (),
267- saveOutput: false ,
268- useOutput: null ,
269- outputVariable: null ,
270268 };
269+ if (newCommand .saveOutput && newCommand .outputVariable ) {
270+ newCommand .outputVariable = processVariable ({
271+ value: newCommand .outputVariable ,
272+ existingVars: this .getCurrentVariables ().map ((v ) => v .name ),
273+ }).processedValue ;
274+ }
275+ return newCommand;
271276 },
272277 getUniqueId () {
273278 return this .$root .getUniqueId ();
@@ -284,9 +289,6 @@ export default defineComponent({
284289 const cmd = newCommands[i];
285290 // 如果chainId不为空,则只删除指定chainId的命令
286291 if (chainId && cmd .chainId !== chainId) continue ;
287- if (cmd .outputVariable ) {
288- this .removeVariable (cmd .outputVariable );
289- }
290292 newCommands .splice (i, 1 );
291293 }
292294 this .$emit (" update:modelValue" , newCommands);
@@ -326,7 +328,7 @@ export default defineComponent({
326328 command,
327329 {
328330 // 没有输出,则不打印
329- code: ` ${ command .outputVariable } && console.log(${ command .outputVariable } )` ,
331+ code: ` if( ${ command .outputVariable } !==undefined){ console.log(${ command .outputVariable } )} ` ,
330332 },
331333 ];
332334 // 触发运行事件
0 commit comments