@@ -58,6 +58,10 @@ import useStore from '@/stores'
58
58
59
59
const { application } = useStore ()
60
60
61
+ const props = defineProps ({
62
+ data: Object
63
+ })
64
+
61
65
const emit = defineEmits ([' addData' ])
62
66
63
67
const dialogVisible = ref <boolean >(false )
@@ -66,6 +70,8 @@ const source1 = ref('')
66
70
67
71
const source2 = ref (' ' )
68
72
73
+ const apiInputParams = ref ({})
74
+
69
75
watch (dialogVisible , (bool ) => {
70
76
if (! bool ) {
71
77
source1 .value = ' '
@@ -75,7 +81,7 @@ watch(dialogVisible, (bool) => {
75
81
76
82
const open = (val : string ) => {
77
83
source1 .value = ` <iframe
78
- src="${application .location + val }"
84
+ src="${application .location + val }?${ mapToUrlParams ( apiInputParams . value )} "
79
85
style="width: 100%; height: 100%;"
80
86
frameborder="0"
81
87
allow="microphone">
@@ -88,12 +94,43 @@ defer
88
94
src="${window .location .origin }/api/application/embed?protocol=${window .location .protocol .replace (
89
95
' :' ,
90
96
' '
91
- )}&host=${window .location .host }&token=${val }">
97
+ )}&host=${window .location .host }&token=${val }&${ mapToUrlParams ( apiInputParams . value )} ">
92
98
<\/ script>
93
99
`
94
100
dialogVisible .value = true
95
101
}
96
102
103
+ function mapToUrlParams(map ) {
104
+ const params = new URLSearchParams ();
105
+
106
+ map .forEach ((item : any ) => {
107
+ params .append (encodeURIComponent (item .name ), encodeURIComponent (item .value ));
108
+ });
109
+
110
+ return params .toString (); // 返回 URL 查询字符串
111
+ }
112
+
113
+ watch (() => props .data ,
114
+ (val ) => {
115
+ if (val ) {
116
+ val .work_flow ?.nodes
117
+ ?.filter ((v : any ) => v .id === ' base-node' )
118
+ .map ((v : any ) => {
119
+ apiInputParams .value = v .properties .input_field_list
120
+ ? v .properties .input_field_list
121
+ .filter ((v : any ) => v .assignment_method === ' api_input' )
122
+ .map ((v : any ) => {
123
+ return {
124
+ name: v .variable ,
125
+ value: v .default_value
126
+ }
127
+ })
128
+ : []
129
+ })
130
+ }
131
+ }
132
+ )
133
+
97
134
defineExpose ({ open })
98
135
</script >
99
136
<style lang="scss" scope>
0 commit comments