mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-22 23:53:08 +00:00
refactor: Modularize Electron main process into single-responsibility components
Extract the monolithic main.ts (~1000 lines) into focused modules: - electron/constants.ts - Window sizing, port defaults, filenames - electron/state.ts - Shared state container - electron/utils/ - Port availability and icon utilities - electron/security/ - API key management - electron/windows/ - Window bounds and main window creation - electron/server/ - Backend and static server management - electron/ipc/ - IPC handlers with shared channel constants Benefits: - Improved testability with isolated modules - Better discoverability and maintainability - Single source of truth for IPC channels (used by both main and preload) - Clear separation of concerns Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
45
apps/ui/src/electron/utils/icon-manager.ts
Normal file
45
apps/ui/src/electron/utils/icon-manager.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Icon management utilities
|
||||
*
|
||||
* Functions for getting the application icon path.
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import { app } from 'electron';
|
||||
import { electronAppExists } from '@automaker/platform';
|
||||
import { createLogger } from '@automaker/utils/logger';
|
||||
|
||||
const logger = createLogger('IconManager');
|
||||
|
||||
/**
|
||||
* Get icon path - works in both dev and production, cross-platform
|
||||
* Uses centralized electronApp methods for path validation.
|
||||
*/
|
||||
export function getIconPath(): string | null {
|
||||
const isDev = !app.isPackaged;
|
||||
|
||||
let iconFile: string;
|
||||
if (process.platform === 'win32') {
|
||||
iconFile = 'icon.ico';
|
||||
} else if (process.platform === 'darwin') {
|
||||
iconFile = 'logo_larger.png';
|
||||
} else {
|
||||
iconFile = 'logo_larger.png';
|
||||
}
|
||||
|
||||
const iconPath = isDev
|
||||
? path.join(__dirname, '../../public', iconFile)
|
||||
: path.join(__dirname, '../../dist/public', iconFile);
|
||||
|
||||
try {
|
||||
if (!electronAppExists(iconPath)) {
|
||||
logger.warn('Icon not found at:', iconPath);
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
logger.warn('Icon check failed:', iconPath, error);
|
||||
return null;
|
||||
}
|
||||
|
||||
return iconPath;
|
||||
}
|
||||
Reference in New Issue
Block a user