From bde5002e1ed25d9aec5461199ac56fbac977106a Mon Sep 17 00:00:00 2001
From: yj <1336058017@qq.com>
Date: Thu, 6 Mar 2025 09:46:45 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=94=99=E8=AF=AF=E5=BC=B9?=
=?UTF-8?q?=E7=AA=97=E6=89=8B=E5=8A=A8=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/UpdateModal/index.tsx | 108 ++++++++++++++-------------
1 file changed, 55 insertions(+), 53 deletions(-)
diff --git a/src/components/UpdateModal/index.tsx b/src/components/UpdateModal/index.tsx
index b60a177..7a72508 100644
--- a/src/components/UpdateModal/index.tsx
+++ b/src/components/UpdateModal/index.tsx
@@ -9,62 +9,64 @@ const { confirm } = Modal;
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) {
+ if (JSON.stringify(data).includes('Error') || JSON.stringify(data).includes('{}')) {
+ setIsError(res => {
+ if (res) {
+ setIsError(false)
+ confirm({
+ keyboard: false,
+ title: '提示',
+ icon: ,
+ 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') { // 打开弹窗
+ setProgress(res => {
+ if (res) {
- } else {
- window.electron.onDownload('1')
+ } else {
+ window.electron.onDownload('1')
+ }
+ return res
+ })
+ } else if (dataJson.type === '1') { // 下载中 返回进度值
+ if (dataJson.value === 100 && location.hash.indexOf('/meeting') === -1) {
+ setIsUpdateModal(true)
+ getContent()
}
- 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') { // 下载完成
- setProgress(100)
- if (location.hash.indexOf('/meeting') === -1) {
- setIsUpdateModal(true)
- getContent()
- }
- } else if (dataJson.type === '3') {
- if (location.hash.indexOf('/meeting') === -1) {
- setIsUpdateModal(true)
- getContent()
- }
- }
- } catch (error) {
- if (typeof data === 'string' && data.includes('Error')) {
- setIsError(res => {
- if (res) {
- setIsError(false)
- confirm({
- keyboard: false,
- title: '提示',
- icon: ,
- 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}`
- })
- }
- })
- },
- })
+ setProgress(dataJson.value.toFixed(2))
+ } else if (dataJson.type === '2') { // 下载完成
+ setProgress(100)
+ if (location.hash.indexOf('/meeting') === -1) {
+ setIsUpdateModal(true)
+ getContent()
}
- return res
- })
+ } else if (dataJson.type === '3') {
+ if (location.hash.indexOf('/meeting') === -1) {
+ setIsUpdateModal(true)
+ getContent()
+ }
+ }
+ } catch (error) {
+
}
}
}