diff --git a/src/extensions/core/electronAdapter.ts b/src/extensions/core/electronAdapter.ts index 034f5ca37..da28ac0c2 100644 --- a/src/extensions/core/electronAdapter.ts +++ b/src/extensions/core/electronAdapter.ts @@ -1,7 +1,10 @@ +import log from 'loglevel' + import { PYTHON_MIRROR } from '@/constants/uvMirrors' import { t } from '@/i18n' import { app } from '@/scripts/app' import { useDialogService } from '@/services/dialogService' +import { useToastStore } from '@/stores/toastStore' import { useWorkflowStore } from '@/stores/workflowStore' import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil' import { checkMirrorReachable } from '@/utils/networkUtil' @@ -12,6 +15,7 @@ import { checkMirrorReachable } from '@/utils/networkUtil' const electronAPI = getElectronAPI() const desktopAppVersion = await electronAPI.getElectronVersion() const workflowStore = useWorkflowStore() + const toastStore = useToastStore() const onChangeRestartApp = (newValue: string, oldValue: string) => { // Add a delay to allow changes to take effect before restarting. @@ -163,19 +167,48 @@ import { checkMirrorReachable } from '@/utils/networkUtil' label: 'Check for Updates', icon: 'pi pi-sync', async function() { - const updateAvailable = await electronAPI.checkForUpdates({ - disableUpdateReadyAction: true - }) - if (updateAvailable.isUpdateAvailable) { - const version = updateAvailable.version + try { + const updateInfo = await electronAPI.checkForUpdates({ + disableUpdateReadyAction: true + }) + + if (!updateInfo.isUpdateAvailable) { + toastStore.add({ + severity: 'info', + summary: t('desktopUpdate.noUpdateFound'), + life: 5_000 + }) + return + } + const proceed = await useDialogService().confirm({ - title: t('desktopUpdate.updateFoundTitle', { version }), + title: t('desktopUpdate.updateFoundTitle', { + version: updateInfo.version + }), message: t('desktopUpdate.updateAvailableMessage'), type: 'default' }) if (proceed) { - electronAPI.restartAndInstall() + try { + electronAPI.restartAndInstall() + } catch (error) { + log.error('Error installing update:', error) + toastStore.add({ + severity: 'error', + summary: t('g.error'), + detail: t('desktopUpdate.errorInstallingUpdate'), + life: 10_000 + }) + } } + } catch (error) { + log.error('Error checking for updates:', error) + toastStore.add({ + severity: 'error', + summary: t('g.error'), + detail: t('desktopUpdate.errorCheckingUpdate'), + life: 10_000 + }) } } }, diff --git a/src/locales/en/main.json b/src/locales/en/main.json index a3d9276dd..f74617009 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -1019,7 +1019,10 @@ "description": "ComfyUI Desktop is installing new dependencies. This may take a few minutes.", "terminalDefaultMessage": "Any console output from the update will be shown here.", "updateFoundTitle": "Update Found (v{version})", - "updateAvailableMessage": "An update is available. Do you want to restart and update now?" + "updateAvailableMessage": "An update is available. Do you want to restart and update now?", + "noUpdateFound": "No update found", + "errorCheckingUpdate": "Error checking for updates", + "errorInstallingUpdate": "Error installing update" }, "clipboard": { "successMessage": "Copied to clipboard", diff --git a/src/locales/es/main.json b/src/locales/es/main.json index d155ce0c9..8e31759fa 100644 --- a/src/locales/es/main.json +++ b/src/locales/es/main.json @@ -171,6 +171,9 @@ }, "desktopUpdate": { "description": "ComfyUI Desktop está instalando nuevas dependencias. Esto puede tardar unos minutos.", + "errorCheckingUpdate": "Error al buscar actualizaciones", + "errorInstallingUpdate": "Error al instalar la actualización", + "noUpdateFound": "No se encontró ninguna actualización", "terminalDefaultMessage": "Cualquier salida de consola de la actualización se mostrará aquí.", "title": "Actualizando ComfyUI Desktop", "updateAvailableMessage": "Hay una actualización disponible. ¿Quieres reiniciar y actualizar ahora?", diff --git a/src/locales/fr/main.json b/src/locales/fr/main.json index aba61e8ad..8aeaf5d82 100644 --- a/src/locales/fr/main.json +++ b/src/locales/fr/main.json @@ -171,6 +171,9 @@ }, "desktopUpdate": { "description": "ComfyUI Desktop installe de nouvelles dépendances. Cela peut prendre quelques minutes.", + "errorCheckingUpdate": "Erreur lors de la vérification des mises à jour", + "errorInstallingUpdate": "Erreur lors de l'installation de la mise à jour", + "noUpdateFound": "Aucune mise à jour trouvée", "terminalDefaultMessage": "Toute sortie de console de la mise à jour sera affichée ici.", "title": "Mise à jour de ComfyUI Desktop", "updateAvailableMessage": "Une mise à jour est disponible. Voulez-vous redémarrer et mettre à jour maintenant?", diff --git a/src/locales/ja/main.json b/src/locales/ja/main.json index d8be75a8f..1399f6f93 100644 --- a/src/locales/ja/main.json +++ b/src/locales/ja/main.json @@ -171,6 +171,9 @@ }, "desktopUpdate": { "description": "ComfyUIデスクトップは新しい依存関係をインストールしています。これには数分かかる場合があります。", + "errorCheckingUpdate": "アップデートの確認中にエラーが発生しました", + "errorInstallingUpdate": "アップデートのインストール中にエラーが発生しました", + "noUpdateFound": "アップデートは見つかりませんでした", "terminalDefaultMessage": "更新からの任意のコンソール出力はここに表示されます。", "title": "ComfyUIデスクトップの更新", "updateAvailableMessage": "アップデートが利用可能です。今すぐ再起動してアップデートしますか?", diff --git a/src/locales/ko/main.json b/src/locales/ko/main.json index 9344c23b8..c23abffb7 100644 --- a/src/locales/ko/main.json +++ b/src/locales/ko/main.json @@ -171,6 +171,9 @@ }, "desktopUpdate": { "description": "ComfyUI 데스크톱이 새로운 종속성을 설치하고 있습니다. 이 작업은 몇 분 정도 걸릴 수 있습니다.", + "errorCheckingUpdate": "업데이트 확인 중 오류가 발생했습니다", + "errorInstallingUpdate": "업데이트 설치 중 오류가 발생했습니다", + "noUpdateFound": "업데이트를 찾을 수 없습니다", "terminalDefaultMessage": "업데이트 콘솔 출력은 여기에 표시됩니다.", "title": "ComfyUI 데스크톱 업데이트 중", "updateAvailableMessage": "업데이트가 가능합니다. 지금 재시작하고 업데이트하시겠습니까?", diff --git a/src/locales/ru/main.json b/src/locales/ru/main.json index 7831b6043..03509f6ec 100644 --- a/src/locales/ru/main.json +++ b/src/locales/ru/main.json @@ -171,6 +171,9 @@ }, "desktopUpdate": { "description": "ComfyUI Desktop устанавливает новые зависимости. Это может занять несколько минут.", + "errorCheckingUpdate": "Ошибка при проверке обновлений", + "errorInstallingUpdate": "Ошибка при установке обновления", + "noUpdateFound": "Обновлений не найдено", "terminalDefaultMessage": "Любой вывод консоли из обновления будет отображаться здесь.", "title": "Обновление ComfyUI Desktop", "updateAvailableMessage": "Доступно обновление. Вы хотите перезагрузить и обновить сейчас?", diff --git a/src/locales/zh/main.json b/src/locales/zh/main.json index fd8ed8ab4..d78ec63c7 100644 --- a/src/locales/zh/main.json +++ b/src/locales/zh/main.json @@ -171,6 +171,9 @@ }, "desktopUpdate": { "description": "ComfyUI桌面正在安装新的依赖项。这可能需要几分钟的时间。", + "errorCheckingUpdate": "检查更新时出错", + "errorInstallingUpdate": "安装更新时出错", + "noUpdateFound": "未发现更新", "terminalDefaultMessage": "更新过程中的任何控制台输出都将在这里显示。", "title": "正在更新ComfyUI桌面", "updateAvailableMessage": "有可用的更新。您现在要重启并更新吗?",