Skip to content

Commit 5fa7f99

Browse files
committed
claude初始配置
1 parent 43a2b6c commit 5fa7f99

1 file changed

Lines changed: 142 additions & 0 deletions

File tree

jeecgboot-vue3/CLAUDE.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
JeecgBoot Vue3 frontend — an enterprise low-code platform built with Vue 3 + Vite 6 + Ant Design Vue 4 + TypeScript. Uses pnpm as package manager. Node 20+ required.
8+
9+
## Common Commands
10+
11+
```bash
12+
pnpm dev # Start dev server (port 3100, mock enabled)
13+
pnpm build # Production build (output: dist/)
14+
pnpm build:report # Build with bundle visualizer
15+
pnpm preview # Build + preview
16+
17+
# Linting (no unified "lint" script — run individually)
18+
npx eslint src/path/to/file.vue # Lint specific file
19+
npx stylelint "src/**/*.{vue,less,css}" # Stylelint
20+
pnpm batch:prettier # Format all src files
21+
22+
# Testing
23+
npx jest # Run all tests
24+
npx jest tests/test.spec.ts # Run specific test
25+
# Framework: Jest 29 + ts-jest, config in jest.config.mjs
26+
27+
pnpm clean:cache # Clear Vite cache
28+
pnpm gen:icon # Regenerate icon data
29+
```
30+
31+
## Path Aliases
32+
33+
- `/@/` and `@/``src/`
34+
- `/#/` and `#/``types/`
35+
- `~icons/{collection}/{name}` → unplugin-icons (compile-time icon imports)
36+
37+
The `/@/` prefix (with leading slash) is the project's conventional alias — prefer it for consistency.
38+
39+
## Architecture
40+
41+
### Bootstrap Sequence (src/main.ts)
42+
43+
`createApp` → pinia → i18n → app config → registerPackages (@jeecg/online) → registerGlobComp (core Ant Design components) → SSO login → registerSuper (dynamic module discovery) → router setup → guards → directives → error handler → registerThirdComp (vxe-table, emoji, dayjs) → mount
44+
45+
### Routing & Permissions
46+
47+
- **Permission mode: BACK** — routes and menus are fetched from the backend API via `getBackMenuAndPerms()`
48+
- Dynamic routes added at runtime in `src/store/modules/permission.ts`
49+
- Static routes: login, oauth2-login, token-login, error pages, AI dashboard
50+
- Router mode: HTML5 history (hash mode when running in Electron)
51+
- Super modules discovered dynamically via `import.meta.glob('./**/register.ts')` in `src/views/super/registerSuper.ts`
52+
53+
### State Management (Pinia)
54+
55+
Key stores in `src/store/modules/`:
56+
- `user.ts` (app-user) — auth token, user info, roles, tenant, dict items
57+
- `permission.ts` (app-permission) — dynamic routes, permission codes, backend menus
58+
- `app.ts` (app) — project config, theme, layout settings
59+
- `locale.ts` (app-locale) — i18n locale
60+
- `multipleTab.ts` (app-multiple-tab) — tab state
61+
62+
Auth persisted in localStorage via `src/utils/auth/index.ts`.
63+
64+
### API Layer
65+
66+
- Custom Axios wrapper: `src/utils/http/axios/` — configured instance exported as `defHttp`
67+
- All requests signed with MD5 via `signMd5Utils`
68+
- Tenant ID injected as header when `VITE_GLOB_TENANT_MODE` is enabled
69+
- Response format: `{ code, result, message, success }` where `code === 200` is success
70+
71+
### Component Registration
72+
73+
- **Auto-import**: `unplugin-vue-components` with `AntDesignVueResolver` auto-imports all Ant Design Vue components (no manual import needed in templates)
74+
- **Global manual**: `registerGlobComp.ts` registers Icon, AIcon, JUploadButton, Button, TinyMCE Editor
75+
- **Third-party**: `registerThirdComp.ts` registers vxe-table (full import), custom vxe cell components, emoji picker, dayjs plugins
76+
- **Async loading**: Heavy components use `src/utils/factory/createAsyncComponent.tsx`
77+
78+
### Icon System
79+
80+
Three icon approaches:
81+
1. **Iconify runtime**`<Icon icon="mdi:home" />` via `@iconify/iconify` CDN lazy-load
82+
2. **SVG sprites**`<Icon icon="icon-name|svg" />` via `vite-plugin-svg-icons`
83+
3. **unplugin-icons**`import IconName from '~icons/collection/name'` for compile-time tree-shaken icons
84+
85+
### Theme System
86+
87+
- Less variables generated by `build/generate/generateModifyVars.ts`
88+
- Dark mode via Ant Design Vue `theme.darkAlgorithm`
89+
- CSS variable `--j-global-primary-color` set dynamically from theme color
90+
- CSS class prefix: `jeecg` (defined in `src/settings/designSetting.ts`)
91+
92+
### External Packages
93+
94+
- `@jeecg/online` and `@jeecg/aiflow` are external monorepo packages excluded from Vite optimizeDeps (CJS compatibility issues)
95+
- Registered via `registerPackages(app)` in main.ts
96+
97+
### Micro-Frontend (Qiankun)
98+
99+
- Can run as master (hosting sub-apps) or child (embedded in parent)
100+
- Config in `src/qiankun/`, sub-apps via `VITE_APP_SUB_*` env vars
101+
- Child mode activated when `VITE_GLOB_QIANKUN_MICRO_APP_NAME` is set
102+
103+
### Electron Support
104+
105+
- `src/electron/` — uses hash router mode
106+
- Platform detected via `VITE_GLOB_RUN_PLATFORM === 'electron'`
107+
108+
## Key Configuration
109+
110+
### Environment Variables
111+
112+
- `.env` — base config (port 3100, app title, SSO/qiankun flags)
113+
- `.env.development` — mock enabled, proxy to `localhost:8080/jeecg-boot`
114+
- `.env.production` — mock disabled, gzip compression
115+
- `VITE_GLOB_*` vars are injected at runtime via `dist/_app.config.js` (changeable post-build)
116+
117+
### Build
118+
119+
- Manual chunks: `vue-vendor`, `antd-vue-vendor`, `vxe-table-vendor`, `emoji-mart-vue-fast`, `china-area-data-vendor`
120+
- Post-build: `build/script/postBuild.ts` generates runtime config; `copyChat.ts` copies chat assets
121+
- Console/debugger stripped in production via esbuild
122+
123+
## Code Style
124+
125+
- **Prettier**: 150 char width, single quotes, trailing commas (es5), 2-space indent, `endOfLine: 'auto'`
126+
- **ESLint**: Vue3 recommended + TypeScript recommended + Prettier. `any` is allowed. Unused vars prefixed with `_` are ignored
127+
- **Commits**: Conventional commits enforced via commitlint. Types: feat, fix, perf, style, docs, test, refactor, build, ci, chore, revert, wip, workflow, types, release. Max header: 108 chars
128+
- **i18n**: Chinese (zh-CN) and English supported. Locale files in `src/locales/lang/`
129+
130+
## Important Directories
131+
132+
```
133+
build/ # Vite plugins, build scripts, theme generation
134+
src/api/ # API definitions (sys/, common/, demo/)
135+
src/components/jeecg/ # Jeecg-specific components (JVxeTable, OnLine, etc.)
136+
src/layouts/default/ # Main app layout (header, sider, tabs, menu)
137+
src/settings/ # Project settings (design, components, locale, encryption)
138+
src/utils/http/axios/ # HTTP client configuration
139+
src/views/system/ # System management pages (user, role, menu, dict, etc.)
140+
src/views/super/ # Dynamically-discovered extension modules
141+
types/ # Global TypeScript declarations
142+
```

0 commit comments

Comments
 (0)