How hadryan/splayer works
Major Components
• Electron Main Process & Preload Scripts:
• In the “electron/main” directory you have files such as createGlobalShortcut.js, startMainServer.js, and mainIpcMain.js that constitute the Electron main process. This handles system-level operations (shortcuts, server startup, IPC coordination).
• The “electron/preload” folder holds the preload script(s) that form the bridge between the main process and the renderer (UI) process.
• Renderer / Frontend (Vue Application):
• The “src” folder comprises components, views, routing (in src/router), state management (src/stores), APIs (src/api), and utilities. This area is responsible for the UI, user interactions, and business logic.
• Public Assets:
• The “public” directory includes static assets (images, fonts) used by the UI.
• External API Service:
• Although not part of this repository, the README makes clear that the application depends on an external NeteaseCloudMusicApi server and also supports services like UnblockNeteaseMusic.
• Build and Configuration:
• Documents like electron-builder.yml and electron.vite.config.js, along with other config files at the root, facilitate bundling and deployment for various platforms (Windows, Linux, macOS).
Relationships and Data Flow
• The Electron Main process starts the native application shell and spawns the renderer process.
• The Preload script exposes selective APIs to the Vue frontend (renderer), allowing safe interaction with Node/Electron resources (for example, global shortcuts and filesystem access).
• Within the Vue application, components communicate via the Vue Router and Vuex-like state management (or similar store in “src/stores”) to handle UI state, user actions, and routing.
• The Vue frontend makes RESTful API calls (visible in “src/api”) to the external music API. This layer also handles local song management and other client-specific tasks.
• There is also an interaction flow between local file operations (for local song management) and core Electron functions.
• Requests from UI components → API utility functions → External Music API.
• User interaction events → local state store updates → UI updates across components.
• Electron IPC communication between main and renderer processes.
Architectural Patterns & Design Principles
• Separation of Concerns:
• Clear split between Electron’s main process (system-level functionality) and the Vue renderer (UI logic).
• Modular Design:
• The “src” folder is organized by features (api, views, components, stores, and utils) to ensure each functional piece is encapsulated.
• Client-Server Communication:
• The project uses RESTful API calls to fetch music data and perform actions (login, playlist management).
• Multi-Platform Considerations:
• Distinct build pipelines for web and desktop (with scripts for win/linux/mac) indicate platform-specific concerns managed through build scripts and configuration.
Relevant Technologies, Frameworks, and Libraries
• Vue 3 and its ecosystem (router, state management).
• Naïve UI for the component library.
• Electron for packaging the desktop application.
• Vite as a bundler (see electron.vite.config.js, along with development build commands in the README).
• External dependencies like NeteaseCloudMusicApi and UnblockNeteaseMusic which are essential for service integration.