# AGENTS.md

This file provides guidance to agents when working with code in this repository.

## Build Commands
- `pnpm dev` - Start dev server (config: `config/vite.config.dev.ts`)
- `pnpm build` - Production build (config: `config/vite.config.prod.ts`)
- `pnpm lint` - Run ESLint + Prettier
- No test framework configured

## Critical Architecture Notes

### Vite Config Location
Config files are in `config/` directory, NOT root. All vite commands reference `./config/vite.config.*.ts`.

### Two Axios Instances
- [`src/api/request.ts`](src/api/request.ts) - Custom instance with workspace header support and `needWorkspace` param
- [`src/api/interceptor.ts`](src/api/interceptor.ts) - Global instance with Bearer token and code 20000 validation

### Storage Pattern
Use [`SafeStorage`](src/utils/safeStorage.ts) instead of localStorage directly. Supports TTL expiry and type-safe keys via `AppStorageKey` enum.

### Dynamic Route Loading
Routes are loaded from server via [`fetchServerMenuConfig()`](src/store/modules/app/index.ts) with permission guard in [`permission.ts`](src/router/guard/permission.ts). Uses flags `isMenuLoading`/`isMenuLoaded` to prevent duplicate loads.

### useRequest Hook Limitation
[`useRequest()`](src/hooks/request.ts) does NOT work in async functions - it immediately invokes the API. Use `.bind(null, params)` to pass arguments.

## Code Style
- No semicolons (Prettier enforced)
- Single quotes, trailing commas (es5)
- Print width: 140 characters
- Path alias: `@/` → `src/`

## Vue/i18n Aliases Required
Vite config includes aliases for `vue-i18n/dist/vue-i18n.cjs.js` and `vue/dist/vue.esm-bundler.js` - don't remove these.