Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Desktop] Add quit command #2286

Merged
merged 5 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/extensions/core/electronAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { t } from '@/i18n'
import { app } from '@/scripts/app'
import { useDialogService } from '@/services/dialogService'
import { useWorkflowStore } from '@/stores/workflowStore'
import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'

;(async () => {
if (!isElectron()) return

const electronAPI = getElectronAPI()
const desktopAppVersion = await electronAPI.getElectronVersion()
const workflowStore = useWorkflowStore()

const onChangeRestartApp = (newValue: string, oldValue: string) => {
// Add a delay to allow changes to take effect before restarting.
Expand Down Expand Up @@ -149,6 +151,25 @@ import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
function() {
electronAPI.restartApp()
}
},
{
id: 'Comfy-Desktop.Quit',
label: 'Quit',
icon: 'pi pi-sign-out',
async function() {
// Confirm if unsaved workflows are open
if (workflowStore.modifiedWorkflows.length > 0) {
const confirmed = await useDialogService().confirm({
message: t('desktopMenu.confirmQuit'),
title: t('desktopMenu.quit'),
type: 'default'
})

if (!confirmed) return
}

electronAPI.quit()
}
}
],

Expand Down
3 changes: 3 additions & 0 deletions src/locales/en/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"Comfy-Desktop_OpenUserGuide": {
"label": "Desktop User Guide"
},
"Comfy-Desktop_Quit": {
"label": "Quit"
},
"Comfy-Desktop_Reinstall": {
"label": "Reinstall"
},
Expand Down
5 changes: 4 additions & 1 deletion src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@
"Open DevTools": "Open DevTools",
"Feedback": "Feedback",
"Desktop User Guide": "Desktop User Guide",
"Quit": "Quit",
"Reinstall": "Reinstall",
"Restart": "Restart",
"Browse Templates": "Browse Templates",
Expand Down Expand Up @@ -418,7 +419,9 @@
},
"desktopMenu": {
"reinstall": "Reinstall",
"confirmReinstall": "This will clear your extra_models_config.yaml file,\nand begin installation again.\n\nAre you sure?"
"confirmReinstall": "This will clear your extra_models_config.yaml file,\nand begin installation again.\n\nAre you sure?",
"quit": "Quit",
"confirmQuit": "There are unsaved workflows open; any unsaved changes will be lost. Ignore this and quit?"
},
"settingsCategories": {
"Comfy-Desktop": "Comfy-Desktop",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/fr/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"Comfy-Desktop_OpenUserGuide": {
"label": "Guide de l'utilisateur du bureau"
},
"Comfy-Desktop_Quit": {
"label": "Quitter"
},
"Comfy-Desktop_Reinstall": {
"label": "Réinstaller"
},
Expand Down
3 changes: 3 additions & 0 deletions src/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"WEBCAM": "WEBCAM"
},
"desktopMenu": {
"confirmQuit": "Il y a des flux de travail non enregistrés ouverts; toutes les modifications non enregistrées seront perdues. Ignorer cela et quitter?",
"confirmReinstall": "Cela effacera votre fichier extra_models_config.yaml,\net commencera l'installation à nouveau.\n\nÊtes-vous sûr ?",
"quit": "Quitter",
"reinstall": "Réinstaller"
},
"downloadGit": {
Expand Down Expand Up @@ -319,6 +321,7 @@
"Previous Opened Workflow": "Flux de travail ouvert précédent",
"Queue Prompt": "Invite de file d'attente",
"Queue Prompt (Front)": "Invite de file d'attente (Front)",
"Quit": "Quitter",
"Redo": "Refaire",
"Refresh Node Definitions": "Actualiser les définitions de nœud",
"Reinstall": "Réinstaller",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/ja/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"Comfy-Desktop_OpenUserGuide": {
"label": "デスクトップユーザーガイド"
},
"Comfy-Desktop_Quit": {
"label": "終了"
},
"Comfy-Desktop_Reinstall": {
"label": "再インストール"
},
Expand Down
3 changes: 3 additions & 0 deletions src/locales/ja/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"WEBCAM": "ウェブカメラ"
},
"desktopMenu": {
"confirmQuit": "保存されていないワークフローが開いています。保存されていない変更はすべて失われます。これを無視して終了しますか?",
"confirmReinstall": "これにより、extra_models_config.yamlファイルがクリアされ、再インストールが開始されます。本当によろしいですか?",
"quit": "終了",
"reinstall": "再インストール"
},
"downloadGit": {
Expand Down Expand Up @@ -319,6 +321,7 @@
"Previous Opened Workflow": "前に開いたワークフロー",
"Queue Prompt": "キューのプロンプト",
"Queue Prompt (Front)": "キューのプロンプト (前面)",
"Quit": "終了",
"Redo": "やり直す",
"Refresh Node Definitions": "ノード定義を更新",
"Reinstall": "再インストール",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/ko/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"Comfy-Desktop_OpenUserGuide": {
"label": "데스크톱 사용자 가이드"
},
"Comfy-Desktop_Quit": {
"label": "종료"
},
"Comfy-Desktop_Reinstall": {
"label": "재설치"
},
Expand Down
3 changes: 3 additions & 0 deletions src/locales/ko/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"WEBCAM": "웹캠"
},
"desktopMenu": {
"confirmQuit": "저장되지 않은 워크플로우가 열려 있습니다. 저장되지 않은 변경 사항은 모두 손실됩니다. 이를 무시하고 종료하시겠습니까?",
"confirmReinstall": "이 작업은 extra_models_config.yaml 파일을 지우고 설치를 다시 시작합니다. 정말로 진행하시겠습니까?",
"quit": "종료",
"reinstall": "재설치"
},
"downloadGit": {
Expand Down Expand Up @@ -319,6 +321,7 @@
"Previous Opened Workflow": "이전 열린 워크플로",
"Queue Prompt": "실행 큐에 프롬프트 추가",
"Queue Prompt (Front)": "실행 큐 맨 앞에 프롬프트 추가",
"Quit": "종료",
"Redo": "다시 실행",
"Refresh Node Definitions": "노드 정의 새로 고침",
"Reinstall": "재설치",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/ru/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"Comfy-Desktop_OpenUserGuide": {
"label": "Руководство пользователя для рабочего стола"
},
"Comfy-Desktop_Quit": {
"label": "Выйти"
},
"Comfy-Desktop_Reinstall": {
"label": "Переустановить"
},
Expand Down
3 changes: 3 additions & 0 deletions src/locales/ru/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"WEBCAM": "ВЕБ-КАМЕРА"
},
"desktopMenu": {
"confirmQuit": "Открыты несохраненные рабочие процессы; все несохраненные изменения будут потеряны. Проигнорировать это и выйти?",
"quit": "Выйти",
"confirmReinstall": "Это очистит ваш файл extra_models_config.yaml и начнёт установку заново. Вы уверены?",
"reinstall": "Переустановить"
},
Expand Down Expand Up @@ -319,6 +321,7 @@
"Previous Opened Workflow": "Предыдущий открытый рабочий процесс",
"Queue Prompt": "Запрос в очереди",
"Queue Prompt (Front)": "Запрос в очереди (спереди)",
"Quit": "Выйти",
"Redo": "Повторить",
"Refresh Node Definitions": "Обновить определения нод",
"Reinstall": "Переустановить",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/zh/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"Comfy-Desktop_OpenUserGuide": {
"label": "桌面用户指南"
},
"Comfy-Desktop_Quit": {
"label": "退出"
},
"Comfy-Desktop_Reinstall": {
"label": "重新安装"
},
Expand Down
3 changes: 3 additions & 0 deletions src/locales/zh/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"WEBCAM": "摄像头"
},
"desktopMenu": {
"confirmQuit": "有未保存的工作流程开启;任何未保存的更改都将丢失。忽略此警告并退出?",
"confirmReinstall": "这将清除您的 extra_models_config.yaml 文件,并重新开始安装。您确定吗?",
"quit": "退出",
"reinstall": "重新安装"
},
"downloadGit": {
Expand Down Expand Up @@ -319,6 +321,7 @@
"Previous Opened Workflow": "上一个打开的工作流",
"Queue Prompt": "执行提示词",
"Queue Prompt (Front)": "执行提示词 (优先执行)",
"Quit": "退出",
"Redo": "重做",
"Refresh Node Definitions": "刷新节点定义",
"Reinstall": "重新安装",
Expand Down
Loading