Skip to content

Commit 8e186d9

Browse files
legendtklclaude
andcommitted
Add project planning and documentation for WebTranslator Chrome extension
- Create comprehensive implementation plan for Chrome extension development - Add CLAUDE.md with project context for team collaboration - Define architecture with modular LLM provider support - MVP focuses on Azure OpenAI integration - Plan includes support for Chinese LLM providers (Doubao, Qwen, Kimi, GLM) - All Chinese providers use OpenAI-compatible APIs for easier integration - Establish 6-stage development roadmap from MVP to production 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 63742e6 commit 8e186d9

File tree

2 files changed

+570
-0
lines changed

2 files changed

+570
-0
lines changed

CLAUDE.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# WebTranslator Chrome Extension - Project Context
2+
3+
## 项目概述
4+
WebTranslator 是一个 Chrome 浏览器扩展,用于将网页内容翻译成用户指定的语言。该扩展支持多种 LLM 后端,包括 Azure OpenAI(MVP)和中国国产大模型。
5+
6+
## 当前进展
7+
8+
### 已完成
9+
1. **需求分析**:明确了将网页从一种语言翻译成另一种语言的核心功能
10+
2. **技术调研**
11+
- Azure OpenAI 作为 MVP 版本的主要后端
12+
- 调研了中国国产模型(豆包、千问、Kimi、GLM)的 API,发现都支持 OpenAI 兼容格式
13+
3. **架构设计**:完成了详细的实现计划(见 IMPLEMENTATION_PLAN.md)
14+
15+
### 技术决策
16+
1. **MVP 使用 Azure OpenAI**
17+
- Endpoint: `https://xx/gpt_openapi`
18+
- API Version: `2024-03-01-preview`
19+
- 支持自定义 headers(如 X-TT-LOGID)
20+
21+
2. **支持的 LLM 提供商**(计划)
22+
- Azure OpenAI (MVP)
23+
- 豆包 (Doubao) - OpenAI 兼容
24+
- 千问 (Qwen) - OpenAI 兼容
25+
- Kimi (Moonshot) - OpenAI 兼容
26+
- GLM (智谱) - OpenAI 兼容
27+
- OpenAI
28+
- Claude
29+
30+
3. **核心架构**
31+
- 模块化 Provider 系统
32+
- 基于 Chrome Extension Manifest V3
33+
- 支持国际化(i18n)
34+
- 缓存机制提升性能
35+
36+
## 项目结构
37+
```
38+
WebTranslator/
39+
├── manifest.json # Chrome 扩展清单
40+
├── src/
41+
│ ├── background/ # Service Worker
42+
│ │ └── llm-providers/ # LLM 提供商集成
43+
│ ├── content/ # 内容脚本
44+
│ ├── popup/ # 弹出界面
45+
│ └── options/ # 设置页面
46+
├── _locales/ # 多语言支持
47+
└── IMPLEMENTATION_PLAN.md # 详细实现计划
48+
```
49+
50+
## 下一步工作
51+
52+
### 立即需要实现(Stage 1 - MVP)
53+
1. [ ] 创建 manifest.json 配置文件
54+
2. [ ] 实现 Azure OpenAI Provider
55+
3. [ ] 基础内容脚本(文本提取)
56+
4. [ ] 简单的 popup 界面
57+
5. [ ] 基本的翻译功能
58+
59+
### 后续迭代
60+
- Stage 2: 完善内容脚本和 DOM 处理
61+
- Stage 3: UI 开发(popup 和 options 页面)
62+
- Stage 4: 集成中国 LLM 提供商
63+
- Stage 5: 高级功能和优化
64+
- Stage 6: 国际化和 Chrome 商店准备
65+
66+
## 技术要点
67+
68+
### 翻译策略
69+
- 智能文本提取,保持 HTML 结构
70+
- 批量处理文本以优化 API 调用
71+
- 缓存翻译结果
72+
- 渐进式渲染
73+
74+
### 安全考虑
75+
- API 密钥加密存储
76+
- CSP 合规
77+
- XSS 防护
78+
- HTTPS only
79+
80+
### 性能目标
81+
- 启动时间 < 100ms
82+
- 平均页面翻译 < 2s
83+
- 支持大页面的渐进式翻译
84+
85+
## 开发指南
86+
87+
### 环境要求
88+
- Node.js 18+
89+
- Chrome 120+
90+
- npm/pnpm
91+
92+
### 开发命令
93+
```bash
94+
npm install # 安装依赖
95+
npm run dev # 开发模式
96+
npm run build # 生产构建
97+
npm run test # 运行测试
98+
npm run package # 打包扩展
99+
```
100+
101+
## API 示例
102+
103+
### Azure OpenAI 配置
104+
```javascript
105+
{
106+
provider: 'azure-openai',
107+
config: {
108+
endpoint: 'https://xx/gpt_openapi',
109+
apiVersion: '2024-03-01-preview',
110+
apiKey: 'sk-xxx',
111+
model: 'gpt-5-chat-2025-08-07',
112+
maxTokens: 1000,
113+
customHeaders: {
114+
'X-TT-LOGID': ''
115+
}
116+
}
117+
}
118+
```
119+
120+
## 注意事项
121+
1. MVP 版本优先支持 Azure OpenAI
122+
2. 所有中国国产模型都提供 OpenAI 兼容接口,便于统一集成
123+
3. 需要考虑全球用户,支持多语言 UI
124+
4. 遵循 Chrome Web Store 的所有要求
125+
126+
## 参考资源
127+
- [Chrome Extension Manifest V3 文档](https://developer.chrome.com/docs/extensions/mv3/)
128+
- [Azure OpenAI API 文档](https://learn.microsoft.com/azure/ai-services/openai/)
129+
- IMPLEMENTATION_PLAN.md - 详细的实现计划和技术细节
130+
131+
---
132+
*最后更新:2025-01-17*
133+
*下一步:开始实现 manifest.json 和基础扩展结构*

0 commit comments

Comments
 (0)