chore : update electron-auto-update

This commit is contained in:
任帅 2023-03-10 17:36:45 +08:00
parent be9d1bc874
commit 51244c3976
3 changed files with 23 additions and 11 deletions

View File

@ -7,7 +7,7 @@
border: 1px solid #000; border: 1px solid #000;
border-radius: 3px; border-radius: 3px;
height: 6px; height: 6px;
width: 100px; width: 200px;
} }
.progress-rate { .progress-rate {

View File

@ -39,6 +39,7 @@ const Update = () => {
const onUpdateCanAvailable = useCallback((_event: Electron.IpcRendererEvent, arg1: VersionInfo) => { const onUpdateCanAvailable = useCallback((_event: Electron.IpcRendererEvent, arg1: VersionInfo) => {
setVersionInfo(arg1) setVersionInfo(arg1)
setUpdateError(undefined)
// Can be update // Can be update
if (arg1.update) { if (arg1.update) {
setModalBtn(state => ({ setModalBtn(state => ({
@ -50,7 +51,6 @@ const Update = () => {
setUpdateAvailable(true) setUpdateAvailable(true)
} else { } else {
setUpdateAvailable(false) setUpdateAvailable(false)
setUpdateError(undefined)
} }
}, []) }, [])
@ -89,8 +89,6 @@ const Update = () => {
} }
}, []) }, [])
const isUpdate = updateAvailable && versionInfo
return ( return (
<> <>
<Modal <Modal
@ -99,7 +97,7 @@ const Update = () => {
okText={modalBtn?.okText} okText={modalBtn?.okText}
onCancel={modalBtn?.onCancel} onCancel={modalBtn?.onCancel}
onOk={modalBtn?.onOk} onOk={modalBtn?.onOk}
footer={isUpdate ? /* hide footer */null : undefined} footer={updateAvailable ? /* hide footer */null : undefined}
> >
<div className={styles.modalslot}> <div className={styles.modalslot}>
{updateError {updateError
@ -108,11 +106,11 @@ const Update = () => {
<p>Error downloading the latest version.</p> <p>Error downloading the latest version.</p>
<p>{updateError.message}</p> <p>{updateError.message}</p>
</div> </div>
) : isUpdate ) : updateAvailable
? ( ? (
<div> <div className='new-version'>
<div>The last version is: v{versionInfo.newVersion}</div> <div>The last version is: v{versionInfo?.newVersion}</div>
<div>v{versionInfo.version} -&gt; v{versionInfo.newVersion}</div> <div className='new-version-target'>v{versionInfo?.version} -&gt; v{versionInfo?.newVersion}</div>
<div className='update-progress'> <div className='update-progress'>
<div className='progress-title'>Update progress:</div> <div className='progress-title'>Update progress:</div>
<div className='progress-bar'> <div className='progress-bar'>
@ -121,7 +119,9 @@ const Update = () => {
</div> </div>
</div> </div>
) )
: <div>Checking...</div>} : (
<div className='last-version'>Now is the last version: v{versionInfo?.version}.</div>
)}
</div> </div>
</Modal> </Modal>
<button disabled={checking} onClick={checkUpdate}> <button disabled={checking} onClick={checkUpdate}>

View File

@ -16,5 +16,17 @@
width: 0; width: 0;
flex-grow: 1; flex-grow: 1;
} }
.new-version {
.new-version-target,.update-progress {
margin-left: 40px;
}
}
.last-version {
height: 80px;
line-height: 80px;
text-align: center;
}
} }
} }