How fengtianxi001/mf-stationmonitor works
Project Type & Purpose
• This is a front-end single‐page application (SPA) built with Vue 3 + Vite and TypeScript.
• Its goal is to present a “digital twin” dashboard for a power substation—rendering 3D models (via Three.js + Draco) and real-time charts (via ECharts) on a large screen.
File Structure at a Glance
• Top-level config files: .env*, tsconfig*.json, vite.config.ts, linters, formatter.
• src/: all application source code
• main.ts – bootstraps the Vue app
• App.vue – root component, mounts header/footer/panels
• components/ – UI building blocks (LayoutHeader, LayoutPanel, WidgetPanel01–06, etc.)
• hooks/ – Composition API hooks (useThree.ts, useEcharts.ts, useStation.ts)
• docs/: production output (built site for GitHub Pages).
• screenshots/: for README.
Key Insights from README
• Minimal text, but confirms it’s a “substation digital twin big-screen case” and is hosted on GitHub Pages under docs/.
Components
a. Main Components
• Developer Machine: runs Vite dev server (vite.config.ts) + HMR + local .env.development.
• Build Pipeline: Vite bundles src/ + static public/ → output to docs/.
• Hosting: GitHub Pages (serving docs/index.html, JS bundles, static assets).
• Client (Browser): loads index.html → runs Vue 3 SPA.
• Vue SPA Layers:
• Presentation Layer: LayoutHeader/Footer, WidgetPanels
• Visualization Engines:
– Three.js + Draco WASM (in useThree.ts) for 3D models (.glb, .gltf)
– ECharts (in useEcharts.ts) for charts
• Data Layer: useStation.ts fetches real-time data from an external Monitoring API (configured in .env.production)
• Asset Store: model files, textures, fonts served from /public/models, /public/textures, /public/fontawesome.
• External Services: real-time telemetry API (IoT platform or mock service).
b. Relationships & Data Flows
1. Developer → Vite Dev Server → serves SPA + assets to browser (local .env).
2. Vite Build → outputs to docs/ → GitHub Pages.
3. Browser → fetch index.html + JS/CSS bundles + static assets → bootstrap Vue app.
4. Vue app → calls useStation → HTTP(s) calls → External Monitoring API → JSON data → updates charts & 3D overlays.
5. Vue components → call useThree → load and decode 3D models via Draco WASM → render WebGL scene.
6. Vue components → call useEcharts → initialize charts.
c. Architectural Patterns & Principles
• Component‐based (Vue components for UI panels).
• Composition API pattern for encapsulating logic (hooks for 3D, charts, data).
• Clear separation of concerns: UI vs data‐fetching vs rendering engines.
• Static‐site deployment: no backend code in repo, data fetching lives in browser.
d. Key Technologies & Libraries
• Vue 3 (Single File Components)
• Vite (ESM dev server, build bundler)
• TypeScript
• Three.js + Draco (3D engine + model compression)
• ECharts (charting)
• GitHub Pages for static hosting