更新错误弹窗手动更新
This commit is contained in:
parent
bcfc790dd3
commit
bde5002e1e
|
|
@ -9,6 +9,33 @@ const { confirm } = Modal;
|
|||
const UpdateModal = forwardRef((_props: any, ref: any) => {
|
||||
useImperativeHandle(ref, () => ({
|
||||
changeModal: (data: any) => {
|
||||
if (JSON.stringify(data).includes('Error') || JSON.stringify(data).includes('{}')) {
|
||||
setIsError(res => {
|
||||
if (res) {
|
||||
setIsError(false)
|
||||
confirm({
|
||||
keyboard: false,
|
||||
title: '提示',
|
||||
icon: <ExclamationCircleFilled />,
|
||||
content: `更新失败,请尝试手动更新!`,
|
||||
centered: true,
|
||||
okText: '立即更新',
|
||||
wrapClassName: 'hideCancelText',
|
||||
cancelText: '',
|
||||
async onOk() {
|
||||
isVersion((bool: boolean, req: any) => {
|
||||
if (bool && req) {
|
||||
window.electron.getEnv().then(res => {
|
||||
location.href = `${getUpdateUrl(res)}/${req.path}`
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
return res
|
||||
})
|
||||
} else {
|
||||
try {
|
||||
let dataJson = JSON.parse(data)
|
||||
if (dataJson.type === '0') { // 打开弹窗
|
||||
|
|
@ -39,32 +66,7 @@ const UpdateModal = forwardRef((_props: any, ref: any) => {
|
|||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (typeof data === 'string' && data.includes('Error')) {
|
||||
setIsError(res => {
|
||||
if (res) {
|
||||
setIsError(false)
|
||||
confirm({
|
||||
keyboard: false,
|
||||
title: '提示',
|
||||
icon: <ExclamationCircleFilled />,
|
||||
content: `更新失败,请尝试手动更新!`,
|
||||
centered: true,
|
||||
okText: '立即更新',
|
||||
wrapClassName: 'hideCancelText',
|
||||
cancelText: '',
|
||||
async onOk() {
|
||||
isVersion((bool: boolean, req: any) => {
|
||||
if (bool && req) {
|
||||
window.electron.getEnv().then(res => {
|
||||
location.href = `${getUpdateUrl(res)}/${req.path}`
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
return res
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue