From 0fb2b4bf75152402a23f8777679329170f3bebf5 Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Fri, 14 Feb 2025 16:09:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E9=9D=99=E9=BB=98=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 5 ++--- src/App.tsx | 9 ++++++--- src/components/UpdateModal/index.tsx | 23 ++++++++++++++++++++--- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/main.js b/main.js index 86d7857..4f3c602 100644 --- a/main.js +++ b/main.js @@ -154,7 +154,7 @@ app.on('ready', () => { if (startNumber === 0) { updateHandle() // 检查更新 setInterval(() => { - updateHandle() // 每一小时检查更新 + autoUpdater.checkForUpdates() }, 1000 * 60 * 60) createTray() startNumber++ @@ -162,7 +162,7 @@ app.on('ready', () => { }); // 更新 ipcMain.handle('updateHandle', () => { - updateHandle() + autoUpdater.checkForUpdates() }); // socket ipcMain.handle('startSignalr', (event, user) => { @@ -715,7 +715,6 @@ app.on('ready', () => { }); // 检测更新,在你想要检查更新的时候执行,renderer事件触发后的操作自行编写 function updateHandle() { - autoUpdater.checkForUpdates() // autoUpdater.checkForUpdatesAndNotify().catch(); const message = { error: '检查更新出错', diff --git a/src/App.tsx b/src/App.tsx index 3e264ca..3426a4f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -127,9 +127,7 @@ const App: React.FC = () => { }, []) useEffect(() => { window.electron.onUpdate((_e: any, data: any) => { - if (location.hash.indexOf('/meeting') === -1) { - updateModalRef.current.changeModal(data) - } + updateModalRef.current.changeModal(data) }) if (!storage.getItem('setting')) { storage.setItem('setting', JSON.stringify(storageSeeting)) @@ -164,6 +162,9 @@ const App: React.FC = () => { if (location.href.indexOf('/login') !== -1) { window.electron.onStop() } + if (location.hash.indexOf('/meeting') === -1) { + window.electron.updateHandle() + } message.destroy('cameraTemporarily') }, [navigate]) } @@ -265,6 +266,8 @@ const App: React.FC = () => { if (location.hash.indexOf('/meeting') === -1) { window.electron.updateHandle() } + } else { + updateModalRef.current.setProgress() } } }; diff --git a/src/components/UpdateModal/index.tsx b/src/components/UpdateModal/index.tsx index 61e7b03..5d77680 100644 --- a/src/components/UpdateModal/index.tsx +++ b/src/components/UpdateModal/index.tsx @@ -9,17 +9,34 @@ const UpdateModal = forwardRef((props: any, ref: any) => { changeModal: (data: any) => { try { let dataJson = JSON.parse(data) - getContent() if (dataJson.type === '0') { // 打开弹窗 - setIsUpdateModal(true) + setProgress(res => { + if (res === 0) { + window.electron.onDownload('1') + } + if (res === 100) { + if (location.hash.indexOf('/meeting') === -1) { + getContent() + setIsUpdateModal(true) + } + } + return res + }) } else if (dataJson.type === '1') { // 下载中 返回进度值 setProgress(dataJson.value.toFixed(2)) } else if (dataJson.type === '2') { // 下载完成 + if (location.hash.indexOf('/meeting') === -1) { + getContent() + setIsUpdateModal(true) + } setProgress(100) } } catch (error) { } + }, + setProgress: () => { + setProgress(0) } })) const [isUpdateModal, setIsUpdateModal] = useState(false); @@ -83,7 +100,7 @@ const UpdateModal = forwardRef((props: any, ref: any) => { onClick={() => window.electron.onDownload('2')} style={{ width: '100%', height: '40px', margin: '20px 0' }} className={`m-ant-btn`} - >下载完成,点击安装 + >下载完成,立即重启 }