4.8 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is the GFast UI project, a Vue 3 admin management system based on the vue-next-admin template, customized for a digital advertising/trading platform.
Commands
npm install- Install dependencies (usenpm install --registry=https://registry.npmmirror.comfor China mainland)npm run dev- Start development servernpm run build- Build for productionnpm run lint- Run ESLint checknpm run lint-fix- Fix ESLint issues automaticallynpm run type-check- Run TypeScript type checkingnpm run quality- Run both lint and type-check
Architecture Overview
Tech Stack:
- Vue 3 with Composition API (script setup)
- TypeScript
- Vite
- Element Plus (UI framework)
- Pinia (state management)
- Vue Router (with hash mode)
- Axios (HTTP client)
- i18n (internationalization)
- mitt (event bus)
Directory Structure:
src/api/- API client methods organized by business domain (ads, assets, cid, customerService, digitalHuman, knowledge, login, menu, settings, system, etc.)src/components/- Reusable Vue componentssrc/directives/- Custom Vue directivessrc/i18n/- Internationalization configurationsrc/layout/- Main layout componentssrc/router/- Route configurationindex.ts- Router setup and guardbackEnd.ts- Backend-controlled route initializationfrontEnd.ts- Frontend-controlled route initializationroute.ts- Static route definitions
src/stores/- Pinia state storesthemeConfig.ts- Theme and global configurationuserInfo.ts- User informationroutesList.ts- Dynamic route managementkeepAliveNames.ts- keep-alive cache management
src/theme/- Theme related stylessrc/types/- TypeScript type definitionssrc/utils/- Utility functionsrequest.ts- Axios instance with interceptors, error handling, and token managementstorage.ts- Session storage wrappergfast.ts- GFast-specific helpers (file URL construction, tree building, date formatting)diffUtils.ts- Field change detection for PUT requests
src/views/- Page components organized by business module
Key Patterns:
-
Routing: Supports both frontend and backend controlled routing. When backend control is enabled (
isRequestRoutes: truein themeConfig), routes are fetched from the backend and dynamically added. -
API Requests:
- API methods are organized by domain in
src/api/(each subdomain has its own directory structure) - The Axios instance in
src/utils/request.tsautomatically:- Adds Bearer token from session storage
- Sends only changed fields for PUT requests (diff comparison with original data)
- Handles token expiration globally with redirect to login
- Provides error message extraction from multiple response formats (
message,msg,error,detail) - Supports error mode configuration via
requestOptions.errorMode:global: (default) Global error popup with backend messagepage: No automatic popup, reject the error for page-level handlingsilent: Completely silent, no error display
- Special handling for
code === 402: Triggers module not enabled subscription flow (except for specific asset endpoints)
- Response format expects
code,message/msg, and data. Known success codes:0,200. - Use
getApiErrorMessage(error)from/@/utils/requestto extract user-friendly error messages in catch blocks when usingpageorsilentmode.
- API methods are organized by domain in
-
Global Properties & Components:
- Helpers registered globally for template use:
getUpFileUrl,handleTree,useDict,selectDictLabel,parseTime,getItems,setItems,getOptionValue,isEmpty
- Global components:
pagination- Reusable pagination component
- Global event bus via mitt:
app.config.globalProperties.mittBus
- Helpers registered globally for template use:
-
Authentication: Token is stored in session storage via the
Sessionutility. 401 responses (HTTP or business code) trigger automatic logout. -
Keep-alive: Route components can be cached via keep-alive, managed by the
useKeepALiveNamesstore.
Environment Variables
.env.development- Development environment settings.env.production- Production environment settingsVITE_API_URL- Backend API base URLVITE_PORT- Dev server portVITE_PUBLIC_PATH- Public base path for production buildVITE_OPEN_CDN- Enable CDN for external dependencies
Development Notes
- The project uses
/@alias forsrc/ - Components use the Composition API with
<script setup lang="ts"> - Styling is done with SCSS
- ESLint enforces code quality
- Node version requirement:
>=16.0.0(supported: v16.x ~ v20.x)