2.3 KiB
2.3 KiB
Architect Mode Rules (Non-Obvious Only)
Architecture Overview
- Vue 3 SPA with dynamic route loading from server
- Pinia stores:
app,user,tab-bar(seesrc/store/) - Two-layer route guard: user login check + permission check
Dynamic Route System
- Server menu fetched in
app storeviafetchServerMenuConfig() - Routes registered dynamically in
permission.ts - Uses
isMenuLoading/isMenuLoadedflags to prevent duplicate loads
API Architecture
- Two axios instances for different auth patterns:
request.ts: Workspace header + custom token formatinterceptor.ts: Bearer token + code 20000 validation
- Choose based on backend API requirements
API Response Format
- Standard response structure:
{code: 0, details: {data: [...], total: number}} - Success code is
0, NOT200or20000 request.tsreturnsresponse.datadirectly- Access list data via
response.details.data - Access total count via
response.details.total
State Management
SafeStoragerequired for all localStorage access- Supports TTL expiry and type-safe keys via enum
Component Patterns
- Global components registered in
components/index.ts - ECharts modules manually imported for bundle size optimization
- Use
SearchTablecomposite component for list pages
Directory Structure
src/
api/ # API layer (ops/ for business, module/ for auth)
components/ # Global reusable components
hooks/ # Composition functions
router/ # Route config and guards
store/ # Pinia stores
utils/ # Utility functions
views/ops/ # Main business modules
pages/
dc/ # Data center management
monitor/ # Monitoring modules
netarch/ # Network architecture
report/ # Reports
system-settings/ # System config
Module Creation Checklist
- Create API file in
src/api/ops/ - Create page directory in
src/views/ops/pages/ - Create
config/columns.tsfor table config - Create
config/search-form.tsfor search config - Create main
index.vuewith SearchTable - Create
components/FormDialog.vuefor CRUD - Create
components/Detail.vuefor detail view