Skip to content

Commit

Permalink
refactor: 优化更新的错误处理
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb committed Sep 20, 2024
1 parent 9414eff commit 900ee84
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/Update/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import styles from "./index.module.scss";

interface State {
open?: boolean;
downloading?: boolean;
loading?: boolean;
manifest?: UpdateManifest;
}

Expand Down Expand Up @@ -90,6 +90,8 @@ const Update = () => {
});
}
} catch (error: any) {
state.loading = false;

if (!showMessage) return;

messageApi.open({
Expand Down Expand Up @@ -118,7 +120,7 @@ const Update = () => {
};

const handleOk = async () => {
state.downloading = true;
state.loading = true;

installUpdate();

Expand All @@ -129,7 +131,7 @@ const Update = () => {
case "DONE":
return relaunch();
case "ERROR":
state.downloading = false;
state.loading = false;

return messageApi.open({
key: MESSAGE_KEY,
Expand Down Expand Up @@ -159,8 +161,8 @@ const Update = () => {
okText={t("component.app_update.button.confirm_update")}
cancelText={t("component.app_update.button.cancel_update")}
className={styles.modal}
confirmLoading={state.downloading}
cancelButtonProps={{ disabled: state.downloading }}
confirmLoading={state.loading}
cancelButtonProps={{ disabled: state.loading }}
onOk={handleOk}
onCancel={handleCancel}
>
Expand Down

0 comments on commit 900ee84

Please sign in to comment.