下载错误手动下载

This commit is contained in:
yj 2025-03-05 18:15:40 +08:00
parent 55deae9654
commit bcfc790dd3
2 changed files with 36 additions and 7 deletions

View File

@ -1,10 +1,12 @@
import styles from '@/components/UpdateModal/index.module.scss'
import ImageUrl from '@/utils/package/imageUrl';
import { getUpdateUrl } from '@/utils/package/public';
import { getUpdateUrl, isVersion } from '@/utils/package/public';
import { ExclamationCircleFilled } from '@ant-design/icons';
import { Button, Flex, Modal, Progress } from 'antd';
import { forwardRef, useImperativeHandle, useState, memo, useEffect } from "react";
const { confirm } = Modal;
const UpdateModal = forwardRef((props: any, ref: any) => {
const UpdateModal = forwardRef((_props: any, ref: any) => {
useImperativeHandle(ref, () => ({
changeModal: (data: any) => {
try {
@ -37,7 +39,33 @@ 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
})
}
}
}
}))
@ -45,6 +73,7 @@ const UpdateModal = forwardRef((props: any, ref: any) => {
const [progress, setProgress] = useState(0); // 下载进度值
const [updateContent, setUpdateContent] = useState('') // 版本更新内容
const [env, setEnv] = useState('')
const [_isError, setIsError] = useState(true)
useEffect(() => {
window.electron.getEnv().then(res => {
setEnv(res)
@ -59,9 +88,9 @@ const UpdateModal = forwardRef((props: any, ref: any) => {
}
throw new Error('Network response was not ok.');
})
.then(textContent => {
.then(_textContent => {
})
.catch(error => {
.catch(_error => {
});
})
}

View File

@ -107,9 +107,9 @@ export const isVersion = (callBack: Function) => {
const data = yaml.load(res.data); // 解析 YAML 内容
window.electron.getVersion().then(req => {
if (compareVersions(data.version, req) == 1) {
callBack(true)
callBack(true, data)
} else {
callBack(false)
callBack(false, data)
}
})
} else {