Commit 385cdb1e by Jaxon

chron: AI初始化

1 parent 64817be0
# CodeGraph data files
# These are local to each machine and should not be committed
# Database
*.db
*.db-wal
*.db-shm
# Cache
cache/
# Logs
*.log
# Hook markers
.dirty
---
description: CodeGraph MCP usage guide — when to use which tool
alwaysApply: true
---
<!-- CODEGRAPH_START -->
## CodeGraph
This project has a CodeGraph MCP server (`codegraph_*` tools) configured. CodeGraph is a tree-sitter-parsed knowledge graph of every symbol, edge, and file. Reads are sub-millisecond and return structural information grep cannot.
### When to prefer codegraph over native search
Use codegraph for **structural** questions — what calls what, what would break, where is X defined, what is X's signature. Use native grep/read only for **literal text** queries (string contents, comments, log messages) or after you already have a specific file open.
| Question | Tool |
|---|---|
| "Where is X defined?" / "Find symbol named X" | `codegraph_search` |
| "What calls function Y?" | `codegraph_callers` |
| "What does Y call?" | `codegraph_callees` |
| "How does X reach/become Y? / trace the flow from X to Y" | `codegraph_trace` (one call = the whole path, incl. callback/React/JSX dynamic hops) |
| "What would break if I changed Z?" | `codegraph_impact` |
| "Show me Y's signature / source / docstring" | `codegraph_node` |
| "Give me focused context for a task/area" | `codegraph_context` |
| "See several related symbols' source at once" | `codegraph_explore` |
| "What files exist under path/" | `codegraph_files` |
| "Is the index healthy?" | `codegraph_status` |
### Rules of thumb
- **Answer directly — don't delegate exploration.** For "how does X work" / architecture questions, answer with 2-3 codegraph calls: `codegraph_context` first, then ONE `codegraph_explore` for the source of the symbols it surfaces. For a specific **flow** ("how does X reach Y") start with `codegraph_trace` from→to — one call returns the whole path with dynamic hops bridged — then ONE `codegraph_explore` for the bodies; don't rebuild the path with `codegraph_search` + `codegraph_callers`. Codegraph IS the pre-built index, so spawning a separate file-reading sub-task/agent — or running a grep + read loop — repeats work codegraph already did and costs more for the same answer.
- **Trust codegraph results.** They come from a full AST parse. Do NOT re-verify them with grep — that's slower, less accurate, and wastes context.
- **Don't grep first** when looking up a symbol by name. `codegraph_search` is faster and returns kind + location + signature in one call.
- **Don't chain `codegraph_search` + `codegraph_node`** when you just want context — `codegraph_context` is one call.
- **Don't loop `codegraph_node` over many symbols** — one `codegraph_explore` call returns several symbols' source grouped in a single capped call, while each separate node/Read call re-reads the whole context and costs far more.
- **Index lag**: the file watcher debounces ~500ms behind writes; don't re-query immediately after editing a file in the same turn.
### If `.codegraph/` doesn't exist
The MCP server returns "not initialized." Ask the user: *"I notice this project doesn't have CodeGraph initialized. Want me to run `codegraph init -i` to build the index?"*
<!-- CODEGRAPH_END -->
......@@ -21,6 +21,7 @@ yarn-error.log*
*.njsproj
*.sln
*.sw?
*.local.json
package-lock.json
yarn.lock
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## 项目概述
**supervise-wecom** - 基于 Vue 2.7 + Vant UI 的移动端 H5 项目,用于企业微信端的工作台应用。
## 开发命令
```bash
# 安装依赖
pnpm install
# 本地开发
pnpm run serve
# 打包测试环境
pnpm run stage
# 打包生产环境
pnpm run build
# 代码检查
pnpm run lint
```
## 技术栈
- **Vue 2.7** + Vue Router 3 + Vuex 3
- **Vant 2.x** - UI 组件库
- **pnpm** - 包管理器
- **Node.js 20.20.2** (通过 Volta 管理)
## 目录结构
```
src/
├── api/ # 接口封装 (request.js, ssoApi.js, 业务 API)
├── assets/ # 静态资源 (css, icons, images, spritesmith)
├── components/ # 公共组件 (自动注册)
├── config/ # 配置文件 (环境配置,vant 配置)
├── layouts/ # 布局组件
├── mixins/ # 混入
├── plugins/ # 插件
├── router/ # 路由配置
├── store/ # Vuex 状态管理 (modules/app.js)
├── utils/ # 工具函数 (tools.js, util.js, eventBus.js)
└── views/ # 页面组件
├── image/ # 图片相关页面
├── mine/ # 个人中心
├── performance/ # 业绩概览
└── teamWork/ # 团队协作
```
## 架构特点
### 1. 环境配置
通过 `--mode xxx` 区分环境,配置文件位于 `src/config/env.*.js`:
- `npm run serve` → development
- `npm run stage` → staging
- `npm run build` → production
动态配置从远程接口获取 (`src/config/index.js` 中的 `fetchConfig`)
### 2. API 封装
- `src/api/request.js` - 基础请求封装,统一的 POST 方法
- `src/api/ssoApi.js` - SSO 登录相关接口
- `glsx-common` 库的 `Http` 类 - 二次封装,支持 `window.$DJ_HTTP` 和 `window.$SCRM_HTTP`
### 3. 样式方案
- **Less** 用于 Vant 主题定制 (`src/assets/css/vant-theme.less`)
- **Sass** 用于全局样式,通过 `vue.config.js` 的 `prependData` 注入全局变量 `$cdn`
- 雪碧图自动生成:`webpack-spritesmith` 插件处理 `src/assets/spritesmith/` 目录
### 4. 组件注册
- `src/components/index.js` 自动注册 `components/` 下所有 `.vue` 文件为全局组件
### 5. 登录流程
- 企业微信 OAuth 登录,通过 URL 参数 `code` 换取用户信息
- 开发环境跳过登录,使用模拟账号 (`13012345678`)
- 登录状态存储在 `localStorage` (`ww_userInfo`)
### 6. 代码规范
- ESLint 9 + `@antfu/eslint-config` 配置
- Prettier 格式化 (`.prettierrc`)
- VSCode 保存时自动修复 ESLint 问题
## 重要配置
### 路由模式
Hash 模式,`publicPath` 在生产环境为 `'./'`
### 打包优化
- 生产环境移除 `console.log`
- `splitChunks` 拆分第三方依赖 (libs, vantUI)
- `webpack-bundle-analyzer` 打包分析
### 已配置别名
- `@` → `src/`
---
## CodeGraph 代码知识库
本项目已初始化 CodeGraph MCP 服务器,可用于快速代码探索和理解。
### 索引统计
- **文件数**: 56
- **符号节点**: 251
- **调用边**: 320
- **数据库大小**: 0.43 MB
### 节点类型分布
| 类型 | 数量 |
|------|------|
| component | 16 |
| constant | 51 |
| file | 55 |
| function | 45 |
| import | 82 |
| variable | 2 |
### 语言分布
- JavaScript: 39 文件
- Vue: 16 文件
- YAML: 1 文件
---
## 核心模块详解
### 1. 启动流程 (`src/main.js`)
```
启动顺序:
1. 引入 vConsole (移动端调试)
2. 加载动态配置 fetchConfig()
3. 初始化 Vant UI
4. 全局注册 Vue 原型方法 (api, bus, tools, local, to)
5. 挂载 Vue 实例到 #app
```
**动态配置来源**: `https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=supervise-wecom-config`
配置项包括:`scrmRequest`, `djRequest`, `loginUrl`, `vconsole` 等
### 2. 路由架构
**三大业务模块**:
| 优先级 | 模块 | 路径 | 重定向 | 页面 |
|--------|------|------|--------|------|
| 1 | 团队协作 | `/teamWork` | `/teamWork/teamList` | 团队列表、督导日报、专项任务 |
| 2 | 业绩概览 | `/performance` | `/performance/index` | 督导业绩/门店业绩、督导 outlet |
| 3 | 我的任务 | `/mine` | `/mine/tasks` | 我的任务 |
**路由特点**:
- 使用 `RouteOutlet` 作为模块级布局组件
- `meta.showTabBar` 控制底部 TabBar 显示
- `meta.keepAlive` 控制组件缓存
- `meta.title` 自动设置页面标题
### 3. 状态管理 (Vuex)
**app.js 核心 state**:
- `showWindow`: 控制主窗口显示(登录完成后 true)
- `lastPath`: 记录最后访问的路由 name
**核心 actions**:
- `navigation`: 路由导航处理,触发登录检查
- `login`: 企业微信 OAuth 登录
- `registerHttp`: 注册 HTTP 实例 (`$SCRM_HTTP`, `$DJ_HTTP`)
- `setPageMeta`: 设置页面元信息(标题等)
### 4. 登录流程详解
```
开发环境 (非生产):
1. 检测非生产环境
2. 模拟用户信息 { phone: "13012345678" }
3. showWindow = true, 直接显示页面
生产环境:
1. 检查 URL 是否有 code 参数
2. 无 code → 跳转企业微信 OAuth 登录页
3. 有 code → 调用 ssoApi.login() 换取用户信息
4. 存储 userInfo 到 localStorage('ww_userInfo')
5. showWindow = true, 渲染页面
```
**企业微信参数**:
- `corpId`: 企业 ID
- `agentId`: 应用 ID
- `code`: OAuth 授权码
### 5. API 请求封装
**src/api/request.js**:
```javascript
post(method, data = {}, url = "supervisorUrl", options = {}, httpType = "djHttp")
```
**URL 配置**:
- `supervisorUrl`: `/rop-dj-supervisor-mini/router`
- `clueUrl`: `/rop-scrm-clue/router`
**HTTP 实例**:
- `window.$DJ_HTTP`: 督导业务 HTTP 实例
- `window.$SCRM_HTTP`: SCRM 业务 HTTP 实例
### 6. 公共组件
**全局自动注册组件** (`src/components/`):
| 组件 | 路径 | 功能 |
|------|------|------|
| DateSearch | `components/dateSearch/dateSearch.vue` | 日期范围选择 |
| SearchBar | `components/searchBar/index.vue` | 搜索输入框 |
| StaticInfo | `components/staticInfo/index.vue` | 静态数据展示卡片 |
| SvgIcon | `components/svgIcon/index.vue` | SVG 图标 |
| TabBar | `components/tabBar/index.vue` | 底部导航栏 |
**业务组件**:
- `BrandTabs`: 品牌分类 tabs (`performance/components/brandTabs/`)
- `StatisticsItem`: 统计项展示 (`performance/components/statisticsItem/`)
### 7. 工具函数
**src/utils/util.js** - 28 个工具函数,包括:
- localStorage 封装
- SessionId 管理
- Loading 控制
- 参数解析等
**src/utils/tools.js** - 9 个工具函数
**src/utils/eventBus.js** - 事件总线
### 8. Mixins
**reportTrackFunMixin**: 用于埋点数据上报
### 9. 环境区分
| 命令 | NODE_ENV | 说明 |
|------|----------|------|
| `pnpm serve` | development | 开发环境,跳过登录 |
| `pnpm stage` | staging | 测试环境 |
| `pnpm build` | production | 生产环境 |
### 10. 打包配置
**vue.config.js**:
- 生产环境 `publicPath: './'`
- `splitChunks` 拆分策略:
- `libs`: 第三方库
- `vantUI`: Vant 相关
- `webpack-bundle-analyzer`: 打包体积分析
- 生产环境移除 `console.log`
---
## CodeGraph 工具使用指南
在 Claude Code 中,优先使用 CodeGraph 工具进行代码探索:
| 需求 | 工具 |
|------|------|
| 查找符号定义 | `codegraph_search` |
| 谁调用了这个函数 | `codegraph_callers` |
| 这个函数调用了谁 | `codegraph_callees` |
| 追踪调用链路 | `codegraph_trace` |
| 修改会影响哪些地方 | `codegraph_impact` |
| 查看符号源码 | `codegraph_node` |
| 批量查看相关符号 | `codegraph_explore` |
| 获取任务/功能上下文 | `codegraph_context` |
| 浏览目录文件 | `codegraph_files` |
| 检查索引状态 | `codegraph_status` |
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!