@@ -11,6 +11,7 @@ import darkIcon from "./imgs/dark-icon.png";
1111import { useThemeStore } from "@/stores/themeStore" ;
1212import { useUpdateStore } from "@/stores/updateStore" ;
1313import { OpenURLWithBrowser } from "@/utils/index" ;
14+ import { useAppStore } from "@/stores/appStore" ;
1415
1516interface State {
1617 loading ?: boolean ;
@@ -33,6 +34,7 @@ const UpdateApp = ({ checkUpdate, relaunchApp }: UpdateAppProps) => {
3334 const isOptional = useUpdateStore ( ( state ) => state . isOptional ) ;
3435 const updateInfo = useUpdateStore ( ( state ) => state . updateInfo ) ;
3536 const setUpdateInfo = useUpdateStore ( ( state ) => state . setUpdateInfo ) ;
37+ const addError = useAppStore ( ( state ) => state . addError ) ;
3638
3739 const state = useReactive < State > ( { download : 0 } ) ;
3840
@@ -65,24 +67,28 @@ const UpdateApp = ({ checkUpdate, relaunchApp }: UpdateAppProps) => {
6567 } , [ state . total , state . download ] ) ;
6668
6769 const handleDownload = async ( ) => {
68- if ( state . loading ) return ;
69-
70- state . loading = true ;
71-
72- await updateInfo ?. downloadAndInstall ( ( progress : any ) => {
73- switch ( progress . event ) {
74- case "Started" :
75- state . total = progress . data . contentLength ;
76- break ;
77- case "Progress" :
78- state . download += progress . data . chunkLength ;
79- break ;
80- }
81- } ) ;
82-
83- state . loading = false ;
84-
85- relaunchApp ( ) ;
70+ try {
71+ if ( state . loading ) return ;
72+
73+ state . loading = true ;
74+
75+ await updateInfo ?. downloadAndInstall ( ( progress : any ) => {
76+ switch ( progress . event ) {
77+ case "Started" :
78+ state . total = progress . data . contentLength ;
79+ break ;
80+ case "Progress" :
81+ state . download += progress . data . chunkLength ;
82+ break ;
83+ }
84+ } ) ;
85+
86+ relaunchApp ( ) ;
87+ } catch ( error ) {
88+ addError ( String ( error ) ) ;
89+ } finally {
90+ state . loading = false ;
91+ }
8692 } ;
8793
8894 const handleCancel = ( ) => {
0 commit comments