Skip to content

Commit a0fe31e

Browse files
committed
fix: 修复应用列表上点演示没有api传入参数的问题
--bug=1049947 --user=刘瑞斌 【应用】应用列表中点演示按钮,跳转的页面没有带默认的api参数 https://www.tapd.cn/57709429/s/1625074
1 parent 7346ef6 commit a0fe31e

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

ui/src/views/application/index.vue

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ const selectUserId = ref('all')
185185
186186
const searchValue = ref('')
187187
188+
const apiInputParams = ref([])
189+
188190
function copyApplication(row: any) {
189191
application.asyncGetApplicationDetail(row.id, loading).then((res: any) => {
190192
CopyApplicationDialogRef.value.open({ ...res.data, model_id: res.data.model })
@@ -234,9 +236,44 @@ function searchHandle() {
234236
paginationConfig.total = 0
235237
getList()
236238
}
239+
240+
function mapToUrlParams(map: any[]) {
241+
const params = new URLSearchParams()
242+
243+
map.forEach((item: any) => {
244+
params.append(encodeURIComponent(item.name), encodeURIComponent(item.value))
245+
})
246+
247+
return params.toString() // 返回 URL 查询字符串
248+
}
249+
237250
function getAccessToken(id: string) {
251+
applicationList.value.filter((app)=>app.id === id)[0]?.work_flow?.nodes
252+
?.filter((v: any) => v.id === 'base-node')
253+
.map((v: any) => {
254+
apiInputParams.value = v.properties.api_input_field_list
255+
? v.properties.api_input_field_list
256+
.map((v: any) => {
257+
return {
258+
name: v.variable,
259+
value: v.default_value
260+
}
261+
})
262+
: v.properties.input_field_list
263+
? v.properties.input_field_list
264+
.filter((v: any) => v.assignment_method === 'api_input')
265+
.map((v: any) => {
266+
return {
267+
name: v.variable,
268+
value: v.default_value
269+
}
270+
})
271+
: []
272+
})
273+
274+
const apiParams = mapToUrlParams(apiInputParams.value) ? '?' + mapToUrlParams(apiInputParams.value) : ''
238275
application.asyncGetAccessToken(id, loading).then((res: any) => {
239-
window.open(application.location + res?.data?.access_token)
276+
window.open(application.location + res?.data?.access_token + apiParams)
240277
})
241278
}
242279

0 commit comments

Comments
 (0)