This commit is contained in:
parent
06a2e6e4ac
commit
b185bb7d67
8
main.js
8
main.js
|
|
@ -115,7 +115,7 @@ app.on('ready', () => {
|
|||
uploadToServer: false,
|
||||
ignoreSystemCrashHandler: false
|
||||
})
|
||||
if (env === 'development') {
|
||||
if (!buildStatus) {
|
||||
Object.defineProperty(app, 'isPackaged', {
|
||||
get() {
|
||||
return true
|
||||
|
|
@ -763,14 +763,16 @@ function updateHandle() {
|
|||
autoUpdater.autoDownload = false // 不自动下载安装包
|
||||
autoUpdater.autoInstallOnAppQuit = false // 不自动安装
|
||||
autoUpdater.on('error', function (error) {
|
||||
sendUpdateMessage(message.error)
|
||||
sendUpdateMessage(error)
|
||||
})
|
||||
autoUpdater.on('checking-for-update', function () {
|
||||
sendUpdateMessage(message.checking)
|
||||
})
|
||||
autoUpdater.on('update-available', function (info) {
|
||||
let messageStr = JSON.stringify({ type: '0' })
|
||||
sendUpdateMessage(messageStr)
|
||||
setTimeout(() => {
|
||||
sendUpdateMessage(messageStr)
|
||||
}, 2000)
|
||||
mainWindow.webContents.send('changeLocalStorage', {
|
||||
isUpdate: true,
|
||||
});
|
||||
|
|
|
|||
10
src/App.tsx
10
src/App.tsx
|
|
@ -187,7 +187,7 @@ const App: React.FC = () => {
|
|||
if (location.href.indexOf('/login') !== -1) {
|
||||
window.electron.onStop()
|
||||
}
|
||||
if (location.hash.indexOf('/meeting') === -1) {
|
||||
if (location.hash && location.hash.indexOf('/meeting') === -1) {
|
||||
window.electron.updateHandle()
|
||||
}
|
||||
message.destroy('cameraTemporarily')
|
||||
|
|
@ -288,14 +288,6 @@ const App: React.FC = () => {
|
|||
storage.removeItem('user')
|
||||
navigate('/login')
|
||||
}
|
||||
} else if (e.key === 'reconnect') {
|
||||
if (e.value == true) {
|
||||
if (location.hash.indexOf('/meeting') === -1) {
|
||||
window.electron.updateHandle()
|
||||
}
|
||||
} else {
|
||||
updateModalRef.current.setProgress()
|
||||
}
|
||||
}
|
||||
};
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -4,42 +4,41 @@ import { getUpdateUrl } from '@/utils/package/public';
|
|||
import { Button, Flex, Modal, Progress } from 'antd';
|
||||
import { forwardRef, useImperativeHandle, useState, memo } from "react";
|
||||
|
||||
const UpdateModal = forwardRef((_props: any, ref: any) => {
|
||||
const UpdateModal = forwardRef((props: any, ref: any) => {
|
||||
useImperativeHandle(ref, () => ({
|
||||
changeModal: (data: any) => {
|
||||
try {
|
||||
let dataJson = JSON.parse(data)
|
||||
if (dataJson.type === '0') { // 打开弹窗
|
||||
setProgress(res => {
|
||||
if (res === 0) {
|
||||
if (res) {
|
||||
|
||||
} else {
|
||||
window.electron.onDownload('1')
|
||||
}
|
||||
if (res === 100) {
|
||||
if (location.hash.indexOf('/meeting') === -1) {
|
||||
getContent()
|
||||
setIsUpdateModal(true)
|
||||
}
|
||||
}
|
||||
return res
|
||||
})
|
||||
} else if (dataJson.type === '1') { // 下载中 返回进度值
|
||||
if (dataJson.value === 100 && location.hash.indexOf('/meeting') === -1) {
|
||||
setIsUpdateModal(true)
|
||||
getContent()
|
||||
}
|
||||
setProgress(dataJson.value.toFixed(2))
|
||||
} else if (dataJson.type === '2') { // 下载完成
|
||||
if (location.hash.indexOf('/meeting') === -1) {
|
||||
getContent()
|
||||
setIsUpdateModal(true)
|
||||
}
|
||||
setProgress(100)
|
||||
if (location.hash.indexOf('/meeting') === -1) {
|
||||
setIsUpdateModal(true)
|
||||
getContent()
|
||||
}
|
||||
} else if (dataJson.type === '3') {
|
||||
getContent()
|
||||
setIsUpdateModal(true)
|
||||
if (location.hash.indexOf('/meeting') === -1) {
|
||||
setIsUpdateModal(true)
|
||||
getContent()
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
},
|
||||
setProgress: () => {
|
||||
setProgress(0)
|
||||
}
|
||||
}))
|
||||
const [isUpdateModal, setIsUpdateModal] = useState(false);
|
||||
|
|
@ -54,9 +53,9 @@ const UpdateModal = forwardRef((_props: any, ref: any) => {
|
|||
}
|
||||
throw new Error('Network response was not ok.');
|
||||
})
|
||||
.then(_textContent => {
|
||||
.then(textContent => {
|
||||
})
|
||||
.catch(_error => {
|
||||
.catch(error => {
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +102,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`}
|
||||
>下载完成,立即重启</Button>
|
||||
>下载完成,点击安装</Button>
|
||||
}
|
||||
</div>
|
||||
</Modal>
|
||||
|
|
|
|||
|
|
@ -125,13 +125,14 @@
|
|||
color: #ccc;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
>span:nth-child(2) {
|
||||
background-color: red;
|
||||
padding: 2px 8px;
|
||||
font-size: 12px;
|
||||
padding: 0px 4px;
|
||||
border-radius: 10px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue