Skip to content

Commit 36636f2

Browse files
committed
chore: improve loading state management in ToolFormDrawer
--bug=1062445 --user=刘瑞斌 【工具】创建工具完成后,在抽屉收起前可以再次点击创建,导致可重复创建工具 https://www.tapd.cn/62980211/s/1781953
1 parent 9406a2c commit 36636f2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ui/src/views/tool/ToolFormDrawer.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,10 @@ const submit = async (formEl: FormInstance | undefined) => {
415415
if (!formEl) return
416416
await formEl.validate((valid: any) => {
417417
if (valid) {
418+
loading.value = true
418419
if (isEdit.value) {
419420
loadSharedApi({ type: 'tool', systemType: apiType.value })
420-
.putTool(form.value?.id as string, form.value, loading)
421+
.putTool(form.value?.id as string, form.value)
421422
.then((res: any) => {
422423
MsgSuccess(t('common.editSuccess'))
423424
emit('refresh', res.data)
@@ -426,13 +427,16 @@ const submit = async (formEl: FormInstance | undefined) => {
426427
.then(() => {
427428
visible.value = false
428429
})
430+
.finally(() => {
431+
loading.value = false
432+
})
429433
} else {
430434
const obj = {
431435
folder_id: folder.currentFolder?.id,
432436
...form.value,
433437
}
434438
loadSharedApi({ type: 'tool', systemType: apiType.value })
435-
.postTool(obj, loading)
439+
.postTool(obj)
436440
.then((res: any) => {
437441
MsgSuccess(t('common.createSuccess'))
438442
emit('refresh')
@@ -441,6 +445,9 @@ const submit = async (formEl: FormInstance | undefined) => {
441445
.then(() => {
442446
visible.value = false
443447
})
448+
.finally(() => {
449+
loading.value = false
450+
})
444451
}
445452
}
446453
})

0 commit comments

Comments
 (0)