mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-11 02:20:08 +00:00
[Desktop] Add quit command (#2286)
Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Chenlei Hu <huchenlei@proton.me>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
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 () => {
|
||||
@@ -8,6 +9,7 @@ import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
|
||||
|
||||
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.
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
Reference in New Issue
Block a user