-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add electron adapter extension (#1538)
- Loading branch information
Showing
2 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import { app } from '@/scripts/app' | ||
import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil' | ||
;(async () => { | ||
if (!isElectron()) return | ||
|
||
const electronAPI = getElectronAPI() | ||
const desktopAppVersion = await electronAPI.getElectronVersion() | ||
app.registerExtension({ | ||
name: 'Comfy.ElectronAdapter', | ||
settings: [ | ||
{ | ||
id: 'Comfy-Desktop.AutoUpdate', | ||
category: ['Comfy-Desktop', 'General', 'AutoUpdate'], | ||
name: 'Automatically check for updates', | ||
type: 'boolean', | ||
defaultValue: true, | ||
onChange(newValue, oldValue) { | ||
if (oldValue !== undefined && newValue !== oldValue) { | ||
electronAPI.restartApp( | ||
'Restart ComfyUI to apply changes.', | ||
1500 // add delay to allow changes to take effect before restarting. | ||
) | ||
} | ||
} | ||
} | ||
], | ||
|
||
commands: [ | ||
{ | ||
id: 'Comfy-Desktop.Folders.OpenLogsFolder', | ||
label: 'Open Logs Folder', | ||
icon: 'pi pi-folder-open', | ||
function() { | ||
electronAPI.openLogsFolder() | ||
} | ||
}, | ||
{ | ||
id: 'Comfy-Desktop.Folders.OpenModelsFolder', | ||
label: 'Open Models Folder', | ||
icon: 'pi pi-folder-open', | ||
function() { | ||
electronAPI.openModelsFolder() | ||
} | ||
}, | ||
{ | ||
id: 'Comfy-Desktop.Folders.OpenOutputsFolder', | ||
label: 'Open Outputs Folder', | ||
icon: 'pi pi-folder-open', | ||
function() { | ||
electronAPI.openOutputsFolder() | ||
} | ||
}, | ||
{ | ||
id: 'Comfy-Desktop.Folders.OpenInputsFolder', | ||
label: 'Open Inputs Folder', | ||
icon: 'pi pi-folder-open', | ||
function() { | ||
electronAPI.openInputsFolder() | ||
} | ||
}, | ||
{ | ||
id: 'Comfy-Desktop.Folders.OpenCustomNodesFolder', | ||
label: 'Open Custom Nodes Folder', | ||
icon: 'pi pi-folder-open', | ||
function() { | ||
electronAPI.openCustomNodesFolder() | ||
} | ||
}, | ||
{ | ||
id: 'Comfy-Desktop.Folders.OpenModelConfig', | ||
label: 'Open extra_model_paths.yaml', | ||
icon: 'pi pi-file', | ||
function() { | ||
electronAPI.openModelConfig() | ||
} | ||
}, | ||
{ | ||
id: 'Comfy-Desktop.OpenDevTools', | ||
label: 'Open DevTools', | ||
icon: 'pi pi-code', | ||
function() { | ||
electronAPI.openDevTools() | ||
} | ||
}, | ||
{ | ||
id: 'Comfy-Desktop.OpenFeedbackPage', | ||
label: 'Feedback', | ||
icon: 'pi pi-envelope', | ||
function() { | ||
window.open('https://forum.comfy.org/c/v1-feedback/', '_blank') | ||
} | ||
}, | ||
{ | ||
id: 'Comfy-Desktop.Reinstall', | ||
label: 'Reinstall', | ||
icon: 'pi pi-refresh', | ||
function() { | ||
// TODO(huchenlei): Add a confirmation dialog. | ||
electronAPI.reinstall() | ||
} | ||
} | ||
], | ||
|
||
menuCommands: [ | ||
{ | ||
path: ['Help'], | ||
commands: ['Comfy-Desktop.OpenFeedbackPage'] | ||
}, | ||
{ | ||
path: ['Help'], | ||
commands: ['Comfy-Desktop.OpenDevTools'] | ||
}, | ||
{ | ||
path: ['Help', 'Open Folder'], | ||
commands: [ | ||
'Comfy-Desktop.Folders.OpenLogsFolder', | ||
'Comfy-Desktop.Folders.OpenModelsFolder', | ||
'Comfy-Desktop.Folders.OpenOutputsFolder', | ||
'Comfy-Desktop.Folders.OpenInputsFolder', | ||
'Comfy-Desktop.Folders.OpenCustomNodesFolder', | ||
'Comfy-Desktop.Folders.OpenModelConfig' | ||
] | ||
}, | ||
{ | ||
path: ['Help'], | ||
commands: ['Comfy-Desktop.Reinstall'] | ||
} | ||
], | ||
|
||
aboutPageBadges: [ | ||
{ | ||
label: 'ComfyUI_Desktop ' + desktopAppVersion, | ||
url: 'https://github.com/Comfy-Org/electron', | ||
icon: 'pi pi-github' | ||
} | ||
] | ||
}) | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters