后台静默版本升级

This commit is contained in:
yj 2025-02-14 16:09:40 +08:00
parent 7f6c0bffb4
commit 0fb2b4bf75
3 changed files with 28 additions and 9 deletions

View File

@ -154,7 +154,7 @@ app.on('ready', () => {
if (startNumber === 0) { if (startNumber === 0) {
updateHandle() // 检查更新 updateHandle() // 检查更新
setInterval(() => { setInterval(() => {
updateHandle() // 每一小时检查更新 autoUpdater.checkForUpdates()
}, 1000 * 60 * 60) }, 1000 * 60 * 60)
createTray() createTray()
startNumber++ startNumber++
@ -162,7 +162,7 @@ app.on('ready', () => {
}); });
// 更新 // 更新
ipcMain.handle('updateHandle', () => { ipcMain.handle('updateHandle', () => {
updateHandle() autoUpdater.checkForUpdates()
}); });
// socket // socket
ipcMain.handle('startSignalr', (event, user) => { ipcMain.handle('startSignalr', (event, user) => {
@ -715,7 +715,6 @@ app.on('ready', () => {
}); });
// 检测更新在你想要检查更新的时候执行renderer事件触发后的操作自行编写 // 检测更新在你想要检查更新的时候执行renderer事件触发后的操作自行编写
function updateHandle() { function updateHandle() {
autoUpdater.checkForUpdates()
// autoUpdater.checkForUpdatesAndNotify().catch(); // autoUpdater.checkForUpdatesAndNotify().catch();
const message = { const message = {
error: '检查更新出错', error: '检查更新出错',

View File

@ -127,9 +127,7 @@ const App: React.FC = () => {
}, []) }, [])
useEffect(() => { useEffect(() => {
window.electron.onUpdate((_e: any, data: any) => { 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')) { if (!storage.getItem('setting')) {
storage.setItem('setting', JSON.stringify(storageSeeting)) storage.setItem('setting', JSON.stringify(storageSeeting))
@ -164,6 +162,9 @@ const App: React.FC = () => {
if (location.href.indexOf('/login') !== -1) { if (location.href.indexOf('/login') !== -1) {
window.electron.onStop() window.electron.onStop()
} }
if (location.hash.indexOf('/meeting') === -1) {
window.electron.updateHandle()
}
message.destroy('cameraTemporarily') message.destroy('cameraTemporarily')
}, [navigate]) }, [navigate])
} }
@ -265,6 +266,8 @@ const App: React.FC = () => {
if (location.hash.indexOf('/meeting') === -1) { if (location.hash.indexOf('/meeting') === -1) {
window.electron.updateHandle() window.electron.updateHandle()
} }
} else {
updateModalRef.current.setProgress()
} }
} }
}; };

View File

@ -9,17 +9,34 @@ const UpdateModal = forwardRef((props: any, ref: any) => {
changeModal: (data: any) => { changeModal: (data: any) => {
try { try {
let dataJson = JSON.parse(data) let dataJson = JSON.parse(data)
getContent()
if (dataJson.type === '0') { // 打开弹窗 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') { // 下载中 返回进度值 } else if (dataJson.type === '1') { // 下载中 返回进度值
setProgress(dataJson.value.toFixed(2)) setProgress(dataJson.value.toFixed(2))
} else if (dataJson.type === '2') { // 下载完成 } else if (dataJson.type === '2') { // 下载完成
if (location.hash.indexOf('/meeting') === -1) {
getContent()
setIsUpdateModal(true)
}
setProgress(100) setProgress(100)
} }
} catch (error) { } catch (error) {
} }
},
setProgress: () => {
setProgress(0)
} }
})) }))
const [isUpdateModal, setIsUpdateModal] = useState(false); const [isUpdateModal, setIsUpdateModal] = useState(false);
@ -83,7 +100,7 @@ const UpdateModal = forwardRef((props: any, ref: any) => {
onClick={() => window.electron.onDownload('2')} onClick={() => window.electron.onDownload('2')}
style={{ width: '100%', height: '40px', margin: '20px 0' }} style={{ width: '100%', height: '40px', margin: '20px 0' }}
className={`m-ant-btn`} className={`m-ant-btn`}
></Button> ></Button>
} }
</div> </div>
</Modal> </Modal>