Skip to content

Commit

Permalink
feat(web): 优化 CButton 组件的 loading 逻辑 (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
IronKinoko authored Dec 2, 2024
1 parent 86c9ca6 commit 2d419d1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions web/src/pages/components/CButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ const onClick = async (e: MouseEvent) => {
message.warning('处理中...');
return;
}
running.value = true;
await props.onAction(e);
running.value = false;
const ret = props.onAction(e);
if (ret instanceof Promise) {
try {
running.value = true;
await ret;
} finally {
running.value = false;
}
}
};
</script>

Expand Down

0 comments on commit 2d419d1

Please sign in to comment.