AGENTS.md 3.3 KB

AGENTS.md

Architecture

  • Stack: Vue 3 <script setup> + TypeScript (strict) + Vite 6 + Element Plus + Pinia + Vue Router 4
  • Entry: src/main.ts — mounts Element Plus, router, and Pinia (with pinia-plugin-persistedstate)
  • API layer: Orval-generated only. Never write raw axios/fetch calls.
    • Config: orval.config.ts — reads http://localhost:8090/v3/api-docs, writes to src/api/endpoints/ and src/api/models/
    • Generated controllers use factory pattern: getItems(), getOrders(), etc., each returning { methodName: () => Promise<T> }
    • Endpoint stubs at src/api/endpoints/ are Orval-generated — run npm run api:gen to regenerate
    • Custom mutator: src/util/axios-instance.ts (session-based, withCredentials: true, no Bearer token, 401 redirect via router)
    • Response types: each endpoint returns a typed Result wrapper (e.g., ResultPageResultItemVO, ResultUserProfileVO)
  • Routing: src/router/index.ts — flat list with requiresAuth / requiresAdmin / requiresVerified / noAuth meta guards, all lazy-loaded
    • C端: /home, /item/:id, /search, /publish, /my/items, /my/orders, /order/:id, /messages, /messages/:userId, /profile, /profile/password
    • B端: /admin/review/user, /admin/review/item, /admin/users, /admin/categories
  • Stores: useUserStore (auth, non-persisted — session-based) and useMetaStore (site config, persisted), both re-exported from src/store/index.ts
  • Auth: Session-based (withCredentials: true) — login() in store sets flat state; logout() clears state
  • Path alias: @/ → ./src/ (configured in both vite.config.ts and tsconfig.app.json)
  • Components: src/components/ImageUploader.vue (el-upload wrapper) and EmptyState.vue (empty placeholder)

Commands

Command What it does
npm run dev Start Vite dev server (proxies /api → http://localhost:8090, strips /api prefix)
npm run build vue-tsc -b then vite build (typecheck must pass first)
npm run preview Preview production build
npm run api:gen Regenerate Orval API code (requires backend at localhost:8090/v3/api-docs)

Important

  • No lint / test / format scripts beyond what Orval runs (prettier --write after codegen). No ESLint. No test framework.
  • TypeScript strict mode — noUnusedLocals, noUnusedParameters, erasableSyntaxOnly all on.
  • Responsive design — every view must work on mobile and desktop. Use Element Plus responsive utilities and CSS media queries. UserLayout has a bottom TabBar visible on mobile (< 768px).
  • work.md was used as the implementation plan and is now fully implemented (phases 1–7). Keep as historical reference.
  • API endpoint stubs at src/api/endpoints/ are Orval-generated from http://localhost:8090/v3/api-docs. Re-run npm run api:gen when the backend spec changes.
  • Build artifacts: dist/ is gitignored. The large index chunk (Element Plus) can be split via build.rollupOptions.output.manualChunks if needed.
  • Views: All views are lazy-loaded via const Xxx = () => import('@/view/Xxx.vue'). Admin views are under src/view/admin/.
  • src/type/ was removed — all type definitions now come from src/api/models/ (Orval-generated) or are inlined in endpoint stubs.