mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-05 09:33:07 +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:
36
apps/ui/src/electron/ipc/channels.ts
Normal file
36
apps/ui/src/electron/ipc/channels.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* IPC channel constants
|
||||
*
|
||||
* Single source of truth for all IPC channel names.
|
||||
* Used by both main process handlers and preload script.
|
||||
*/
|
||||
|
||||
export const IPC_CHANNELS = {
|
||||
DIALOG: {
|
||||
OPEN_DIRECTORY: 'dialog:openDirectory',
|
||||
OPEN_FILE: 'dialog:openFile',
|
||||
SAVE_FILE: 'dialog:saveFile',
|
||||
},
|
||||
SHELL: {
|
||||
OPEN_EXTERNAL: 'shell:openExternal',
|
||||
OPEN_PATH: 'shell:openPath',
|
||||
OPEN_IN_EDITOR: 'shell:openInEditor',
|
||||
},
|
||||
APP: {
|
||||
GET_PATH: 'app:getPath',
|
||||
GET_VERSION: 'app:getVersion',
|
||||
IS_PACKAGED: 'app:isPackaged',
|
||||
QUIT: 'app:quit',
|
||||
},
|
||||
AUTH: {
|
||||
GET_API_KEY: 'auth:getApiKey',
|
||||
IS_EXTERNAL_SERVER_MODE: 'auth:isExternalServerMode',
|
||||
},
|
||||
WINDOW: {
|
||||
UPDATE_MIN_WIDTH: 'window:updateMinWidth',
|
||||
},
|
||||
SERVER: {
|
||||
GET_URL: 'server:getUrl',
|
||||
},
|
||||
PING: 'ping',
|
||||
} as const;
|
||||
Reference in New Issue
Block a user