How vitaminc1989/electron-template works
Main Components
• Main Process – This includes components for initializing the application, managing windows, setting up IPC communication, logging, and data persistence. Files like src/main/index.ts, src/main/ipc.ts, src/main/windows/main.ts, src/main/logger.ts, and src/main/electronStore.ts are key here.
• Preload Scripts – These scripts run before the renderer process and expose a controlled API to it. Key files include src/preload/index.ts, src/preload/logger.ts, and src/preload/store.ts.
• Renderer Process – This part is built with Vue 3 and handles the user interface, routing, state management, and display of components. Look to files such as src/renderer/src/main.ts, App.vue, the Vue components, and router and store configurations.
• Configuration & Build Tools – Although not core logic, configuration files (like electron.vite.config.ts, electron-builder.yml, vite.config.ts, and the various tsconfig files) underline how the app is built, bundled, and deployed.
Relationships and Interactions
• Main Process and Preload: The preload scripts act as an intermediary, safely exposing IPC and storage APIs (e.g., logger, electron-store) from the main process to the renderer process.
• Data Persistence and Logging: Highlight how components like electronStore (in the main process) and the custom logging utilities (in both main and preload) interact with user actions or system events.
• External Configurations: Display how build and deployment configurations (such as electron-builder, Vite, and TypeScript settings) support the overall structure without being primary runtime components.
Architectural Patterns and Design Principles
• Separation of Concerns: The clear split between main, preload, and renderer processes.
• IPC Communication: The design ensures secure bi-directional communication between the renderer and the main process using preloaded APIs.
• Modular Organization: Components are organized modularly (e.g., different directories for components, plugins, router, and store in the Vue app; separate folders for main process utilities and window management).
Relevant Technologies
• Electron – Underlying framework for building the desktop application.
• Vue 3 – For building the UI in the renderer process.
• TypeScript – Enforces type safety across the project.
• electron-store – For persistent local data storage.
• electron-log – For logging functionality.
• Vite – For bundling and development server setups.
• ESLint/Prettier – For coding standards and formatting.