mirror of https://github.com/halo-dev/halo
fix: loading state is not restored when Dialog's onConfirm method has exception (#3852)
#### What type of PR is this? /kind bug /area console /milestone 2.5.x #### What this PR does / why we need it: 修复在 Dialog 组件中,如果 onConfirm 方法出现异常,按钮加载状态没有复原的问题。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/3844 #### Does this PR introduce a user-facing change? ```release-note None ```pull/3842/head
parent
4cd6c2f67c
commit
abd0f42dab
|
@ -78,7 +78,14 @@ const handleCancel = () => {
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
if (props.onConfirm) {
|
if (props.onConfirm) {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
|
try {
|
||||||
await props.onConfirm();
|
await props.onConfirm();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to execute onConfirm: ", error);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
handleClose();
|
handleClose();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue