How hiram-wong/zyplayer works
Project type & purpose
• ZyPlayer is a full‐stack desktop application built with Electron (Node.js main process + Chromium renderer), Vue 3 + TDesign in the frontend, and an embedded HTTP/IPC‐based backend. It bundles local database migrations, service modules, a mini‐Express‐style API server, Python “proxy” scripts, filesystem access, auto‐updater, tray/menu/shortcut managers, and a Vue-powered SPA UI.
Top‐level components
A. Electron Main Process (Node.js)
• Core modules:
– db (common, schema, migration, service layers)
– server (routes/v1/* REST endpoints for analyze, drive, file, history, lab, live, parse, player, plugin, proxy, setting, site, star, system)
– ipc (custom channels exposed via contextBridge)
– protocol (custom URL schemes)
– menu, tray, shortcut, winManager, update, logger
• Resources & scripts (resources/t3PyBase Python proxy & spider)
• Filesystem: config, user data, plugin, database directories
• Auto-Updater: GitHub Actions + electron‐builder orchestration
B. Preload Script
• Exposes safe IPC and Node APIs to renderer via contextBridge
C. Renderer Process (Chromium)
• Vue 3 SPA (src/renderer):
– Components & pages (media player cores, code‐editor, layouts)
– Vue Router for navigation (router/modules)
– Pinia store for state management (store/modules, plugins)
– API layer (api/*.ts) calling embedded backend via fetch
– Assets, locales (i18n), styles, sketches for design (desgin/*.sketch)
D. External Services
• Video platforms embedded via iframe or sniffer (iqiyi, qq, sohu, etc.)
• IPTV streams (m3u playlists, EPG)
• CMS adapters (nodejs, drpy, json, xml)
• Alist drives, WebDAV backup
Interactions & data flow
• Renderer → Preload (IPC invoke/listen) → Main modules (protocol, menu, window control, native dialogs)
• Renderer → HTTP API → Main/server/routes/v1/* → service layer → db → SQLite (on disk)
• Main → spawn Python proxy (resources/t3PyBase) → scrape external sites → return data via server endpoints
• Main → network calls (fetch) for CMS, IPTV, external APIs
• Main → file operations (fs) for plugins, config, local files
Architectural patterns & design principles
• Layered backend: Controller (server/routes) → Service (core/db/service) → Data Access (common/curd, schema)
• Separation of concerns: UI vs. business logic vs. persistence vs. native OS integration
• MVVM in the renderer (Vue components + Pinia stores)
• Modular plugin/adapter architecture for CMS & player cores
• IPC vs. HTTP boundary: use contextBridge for native vs. full REST API for data operations