Skip to content

Commit

Permalink
Add button for re-installing Comfy location. (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinjhuang authored Oct 16, 2024
1 parent 4491dc7 commit dbcc059
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
12 changes: 5 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ if (!gotTheLock) {
});
await handleFirstTimeSetup();
const { appResourcesPath, pythonInstallPath, modelConfigPath, basePath } = await determineResourcesPaths();
SetupTray(mainWindow, basePath);
SetupTray(mainWindow, basePath, () => {
log.info('Resetting install location');
fs.rmSync(modelConfigPath);
restartApp();
});
port = await findAvailablePort(8000, 9999).catch((err) => {
log.error(`ERROR: Failed to find available port: ${err}`);
throw err;
Expand Down Expand Up @@ -317,12 +321,6 @@ export const createWindow = async (userResourcesPath?: string): Promise<BrowserW
await loadRendererIntoMainWindow();
log.info('Renderer loaded into main window');

// Set up the System Tray Icon for all platforms
// Returns a tray so you can set a global var to access.
if (userResourcesPath) {
SetupTray(mainWindow, userResourcesPath);
}

const updateBounds = () => {
const { width, height, x, y } = mainWindow.getBounds();
store.set('windowWidth', width);
Expand Down
48 changes: 24 additions & 24 deletions src/tray.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Tray, Menu, BrowserWindow, app, shell } from 'electron';
import path from 'path';

export function SetupTray(mainView: BrowserWindow, basePath: string): Tray {
export function SetupTray(mainView: BrowserWindow, basePath: string, reinstall: () => void): Tray {
// Set icon for the tray
// I think there is a way to packaged the icon in so you don't need to reference resourcesPath
const trayImage = path.join(
Expand Down Expand Up @@ -48,29 +48,29 @@ export function SetupTray(mainView: BrowserWindow, basePath: string): Tray {
},
{ type: 'separator' },
{
label: 'Open Folder',
submenu: [
{
label: 'Models',
click: () => shell.openPath(path.join(basePath, 'models')),
},
{
label: 'Outputs',
click: () => shell.openPath(path.join(basePath, 'output')),
},
{
label: 'Inputs',
click: () => shell.openPath(path.join(basePath, 'input')),
},
{
label: 'Custom Nodes',
click: () => shell.openPath(path.join(basePath, 'custom_nodes')),
},
{
label: 'Logs',
click: () => shell.openPath(app.getPath('logs')),
},
],
label: 'Reset Install Location',
click: () => reinstall(),
},
{ type: 'separator' },
{
label: 'Open Models Folder',
click: () => shell.openPath(path.join(basePath, 'models')),
},
{
label: 'Open Outputs Folder',
click: () => shell.openPath(path.join(basePath, 'output')),
},
{
label: 'Open Inputs Folder',
click: () => shell.openPath(path.join(basePath, 'input')),
},
{
label: 'Open Custom Nodes Folder',
click: () => shell.openPath(path.join(basePath, 'custom_nodes')),
},
{
label: 'Open Logs Folder',
click: () => shell.openPath(app.getPath('logs')),
},
]);

Expand Down

0 comments on commit dbcc059

Please sign in to comment.