贡献指南
感谢你对 ClueLens 的关注!本文介绍如何搭建开发环境、了解项目结构和参与贡献。
环境要求
- Node.js 18+
- Yarn 1.x
- 推荐使用 VS Code 编辑器
快速开始
bash
# 克隆仓库
git clone https://github.com/cppakko/cluelens.git
cd cluelens
# 安装依赖
yarn install
# 启动开发(Chrome)
yarn dev
# 启动开发(Firefox)
yarn dev:firefox执行 yarn dev 后,WXT 会自动编译扩展并打开一个配置好的浏览器实例,文件修改后自动热重载。
项目目录结构
cluelens/
├── assets/ # 全局样式、图片等静态资源
├── components/
│ ├── dicts/ # 词典/翻译模块(核心)
│ │ ├── index.tsx # 元数据注册与模块加载
│ │ ├── types.ts # DictID、ModuleType 等类型定义
│ │ ├── shared/ # 共享组件(CommonView 等)
│ │ ├── bing/ # 各词典模块
│ │ ├── google/
│ │ └── ...
│ ├── panel/ # 查词面板组件
│ └── ui/ # 通用 UI 组件(Button、Dialog 等)
├── entrypoints/
│ ├── background.ts # Service Worker / 后台脚本
│ ├── content/ # 内容脚本(注入网页)
│ ├── options/ # 设置页面
│ ├── popup/ # 弹窗
│ └── sidepanel/ # 侧边栏
├── i18n/ # 国际化(en/ja/zh-CN)
├── utils/ # 工具函数
│ ├── storage.ts # 存储定义(设置、词典配置)
│ ├── messaging.ts # 消息通信协议
│ ├── detectLanguage.ts
│ └── ...
├── wxt.config.ts # WXT 构建配置
├── tsconfig.json
└── package.json常用命令
| 命令 | 说明 |
|---|---|
yarn dev | 开发模式(Chrome) |
yarn dev:firefox | 开发模式(Firefox) |
yarn build | 生产构建(Chrome) |
yarn build:firefox | 生产构建(Firefox) |
yarn zip | 打包为 .zip(用于发布) |
yarn compile | TypeScript 类型检查(tsc --noEmit) |
提交 Issue
- 在 GitHub Issues 中提交
- 请描述清楚问题、复现步骤、浏览器版本
- 功能建议也欢迎通过 Issue 提出
提交 Pull Request
- Fork 仓库
- 创建功能分支:
git checkout -b feature/your-feature - 开发并测试
- 提交 PR 到
main分支 - 在 PR 中说明改动内容
下一步
- 想添加新的词典模块?请阅读 添加新字典