convertor/docs/開發指南/本地開發.md
Your Name a06df23b1d feat: 新增 OCRmyPDF 轉換引擎 (v0.1.14)
## 新功能
- OCRmyPDF 轉換引擎:將掃描版 PDF 轉換為可搜尋 PDF
  - 支援 7 種語言:en, zh-TW, zh, ja, ko, de, fr
  - 與 PDFMathTranslate 風格一致的 UI 格式 (pdf-<lang>)
  - 自動偵測頁面方向並旋轉
  - 自動校正傾斜
  - 跳過已有文字層的頁面
  - 詳細的 5 階段處理進度輸出

## 建置
- Dockerfile:安裝 ocrmypdf 與 Tesseract OCR 語言包

## 文件
- 更新 OCR 功能文件
- 文件目錄結構改為中文名稱

## 測試
- 修復 BabelDOC 和 PDFMathTranslate 測試的 OCR mock
- 所有 345 個測試通過
2026-01-23 16:28:33 +08:00

207 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 本地開發
本文件說明如何在本地環境進行 ConvertX-CN 開發。
---
## 環境需求
- **Node.js** 20+ 或 **Bun** 1.0+
- **Docker**(用於測試)
- **Git**
### 可選
- **Rust** 1.75+(開發 API Server
- 轉換工具FFmpeg、ImageMagick 等)
---
## 快速開始
### 1. Clone 專案
```bash
git clone https://github.com/pi-docket/ConvertX-CN.git
cd ConvertX-CN
```
### 2. 安裝依賴
```bash
# 使用 Bun推薦
bun install
# 或使用 npm
npm install
```
### 3. 啟動開發伺服器
```bash
bun run dev
```
開啟 `http://localhost:3000`
---
## 開發工具
### 程式碼格式化
```bash
# Prettier
bun run format
# ESLint
bun run lint
```
### 類型檢查
```bash
bun run typecheck
```
### 建構
```bash
bun run build
```
---
## 目錄說明
| 目錄 | 說明 |
| ------------- | ---------- |
| `src/` | 前端原始碼 |
| `public/` | 靜態資源 |
| `api-server/` | API Server |
| `tests/` | 測試檔案 |
| `docs/` | 文件 |
| `scripts/` | 腳本 |
---
## 常見開發任務
### 新增轉換器
1.`src/converters/` 建立新檔案
2. 定義輸入/輸出格式
3.`src/converters/main.ts` 註冊
```typescript
// src/converters/myconverter.ts
export const myConverter: Converter = {
id: "myconverter",
name: "My Converter",
inputFormats: ["abc", "xyz"],
outputFormats: ["pdf", "txt"],
convert: async (input, output, format) => {
// 轉換邏輯
},
};
```
### 新增翻譯
1.`src/locales/` 新增或修改翻譯檔
2.`src/i18n/index.ts` 註冊(如果是新語言)
```json
// src/locales/xx.json
{
"title": "ConvertX-CN",
"upload": "上傳",
...
}
```
### 修改樣式
TailwindCSS 設定在 `tailwind.config.js`
```bash
# 重新生成 CSS
bun run build:css
```
---
## API Server 開發
### 環境設定
```bash
cd api-server
```
### 建構
```bash
cargo build
```
### 執行
```bash
cargo run
```
### 測試
```bash
cargo test
```
---
## Docker 開發
### 建構本地映像
```bash
docker build -t convertx-cn-dev .
```
### 使用本地映像
```yaml
# docker-compose.yml
services:
convertx:
image: convertx-cn-dev
# ...
```
---
## 偵錯
### 前端偵錯
使用瀏覽器開發者工具F12
### 後端偵錯
```bash
# 詳細日誌
DEBUG=* bun run dev
```
### API Server 偵錯
```bash
RUST_LOG=debug cargo run
```
---
## 相關文件
- [專案結構](project-structure.md)
- [貢獻指南](contribution.md)
- [測試策略](../testing/test-strategy.md)