How yanstu/subjectthree works
Project type and purpose
• This is a single‑page application (SPA) built with Vue 3 and TypeScript, served via Vite.
• Purpose: a “科目三灯光模拟考试系统” – a driving‑test lighting simulation quiz to help learners practice and review exam points.
File structure
• Top‑level:
• index.html – SPA host page
• assets/ – images referenced in README (static assets)
• src/ – application source code
• ├── main.ts – Vue app bootstrap
• ├── App.vue – root component
• ├── views/ – page‐level view components (WelcomeView, QuizView, ResultView)
• ├── components/ – reusable UI pieces (QuizHeader, QuizOption, QuizFeedback)
• ├── stores/ – Pinia state store (quiz.ts)
• ├── composables/ – custom hook (useTimer.ts)
• └── data/ – static question bank (questions.ts)
• Config files: tsconfig.json, vite.config.ts, package.json
README for additional insights
• Key features: random question order, timer, answer explanation, responsive design
• Tech stack: Vue 3, TypeScript, Vite, Pinia
a. Main components
• Browser/Client (SPA)
• index.html + Vite dev server (or production static hosting)
• Bundler: Vite+Rollup build pipeline
• Application layers inside SPA:
1) Presentation layer (Vue components & views)
2) State management (Pinia store)
3) Business logic (composable: timer)
4) Data layer (static question data)
• External services: None (static asset hosting only)
b. Relationships & interactions
• Browser loads index.html -> boots main.ts -> mounts App.vue
• App.vue routes to WelcomeView → QuizView → ResultView based on state
• Views render child components (QuizHeader, QuizOption, QuizFeedback)
• Components dispatch actions or read state from Pinia (quiz store)
• Pinia store pulls raw questions from data/questions.ts, shuffles sequence
• useTimer composable invoked by QuizView to manage countdown and emits events to store
• User answers flow: Component → Store (record answer) → Component displays feedback
• At end, store computes score and ResultView presents results
c. Architectural patterns & design principles
• Modular single‑page architecture
• MVC‑like separation:
• Views = “V” (views/ + components/)
• Store = “M” (Pinia)
• Actions & composable = “C” (logic)
• Composability: composable hooks for cross‑cutting concerns (timer)
• Static resource layer for test data
d. Key technologies & frameworks
• Vue 3 (component system, reactive)
• TypeScript (static typing)
• Vite (bundler & dev server)
• Pinia (store)
• Optional: external hosting (Netlify, GitHub Pages) for static assets