Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/scheduled_tasks.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sessionId":"bd9043e5-dcab-43a3-826d-9357921127e9","pid":69910,"acquiredAt":1773451558942}
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Bug Report
about: Create a report to help us improve
title: '[BUG] '
labels: bug
assignees: ''
---

## Bug Description
<!-- A clear description of the bug -->

## Steps to Reproduce
1.
2.
3.

## Expected Behavior
<!-- What you expected to happen -->

## Actual Behavior
<!-- What actually happened -->

## Environment
- OS:
- Browser:
- Version:

## Additional Context
<!-- Add any other context about the problem -->
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Feature Request
about: Suggest an idea for this project
title: '[FEATURE] '
labels: enhancement
assignees: ''
---

## Feature Description
<!-- A clear description of the feature -->

## Problem Statement
<!-- What problem does this solve? -->

## Proposed Solution
<!-- How should this feature work? -->

## Alternatives Considered
<!-- Any alternative solutions -->

## Additional Context
<!-- Add any other context or screenshots -->
28 changes: 28 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Summary
<!-- Provide a brief summary of the changes -->

## Related Issue
<!-- Link to the issue this PR addresses -->
Fixes #

## Changes Made
<!-- Describe the changes in detail -->
-
-
-

## Testing
<!-- Describe how you tested the changes -->
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed

## Screenshots (if applicable)
<!-- Add screenshots for UI changes -->

## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Comments added for complex logic
- [ ] Documentation updated (if needed)
- [ ] No new warnings generated
34 changes: 34 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Backend CI

on:
push:
branches: [main, develop]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Lint with flake8
run: |
pip install flake8
flake8 apps/api/ --max-line-length=120 --extend-ignore=E203,W503 || true

- name: Check Python syntax
run: |
python -m py_compile apps/api/main_api.py
22 changes: 22 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Deploy to Vercel

on:
push:
branches: [main]

jobs:
deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Deploy to Vercel
uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
working-directory: apps/web
37 changes: 37 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Frontend CI

on:
push:
branches: [main, develop]
pull_request:
branches: [main]

jobs:
build-and-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: apps/web

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: apps/web/package-lock.json

- name: Install dependencies
run: npm ci

- name: Run linting
run: npm run lint

- name: Type check
run: npm run type-check || true

- name: Build
run: npm run build
176 changes: 176 additions & 0 deletions NEXTJS-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# 🍌 Edit Banana - Next.js 改造完成

## ✅ 已完成内容

### 1. Next.js 15 前端 (apps/web/)

```
apps/web/
├── app/
│ ├── page.tsx # 首页 (Landing Page)
│ ├── layout.tsx # 根布局
│ ├── upload/page.tsx # 上传页面
│ ├── processing/[id]/ # 处理进度页面
│ └── globals.css
├── components/
│ ├── ui/ # 基础UI组件
│ │ ├── button.tsx
│ │ └── card.tsx
│ ├── upload/
│ │ └── file-upload.tsx # 文件上传组件
│ ├── progress/
│ │ └── progress-bar.tsx # 进度条组件
│ └── navbar.tsx # 导航栏
├── lib/
│ ├── utils.ts # 工具函数
│ ├── config.ts # 配置
│ ├── types.ts # TypeScript类型
│ ├── api.ts # API客户端
│ └── websocket.ts # WebSocket hook
├── package.json # 依赖
├── next.config.ts # Next.js配置
└── vercel.json # Vercel部署配置
```

**技术栈:**
- Next.js 15 + React 19 + TypeScript
- Tailwind CSS 4
- Framer Motion (动画)
- react-dropzone (文件上传)
- Lucide React (图标)

### 2. Python FastAPI 后端 (apps/api/)

```
apps/api/
├── main_api.py # FastAPI主入口
├── main.py -> ../../main.py (符号链接)
├── modules -> ../../modules (符号链接)
├── config -> ../../config (符号链接)
├── requirements.txt # Python依赖
├── railway.toml # Railway部署配置
└── fly.toml # Fly.io部署配置
```

**API端点:**
- `POST /api/v1/convert` - 创建转换任务
- `GET /api/v1/jobs/{id}` - 查询任务状态
- `GET /api/v1/jobs/{id}/result` - 下载结果
- `DELETE /api/v1/jobs/{id}` - 取消任务
- `WS /ws/jobs/{id}/progress` - 实时进度推送

### 3. CI/CD 配置 (.github/workflows/)

- `deploy-web.yml` - Vercel自动部署
- `deploy-api.yml` - Railway/Fly.io自动部署

### 4. 文档

- `PROJECT-NEXTJS.md` - 项目说明
- `.env.local.example` - 环境变量示例

---

## 🚀 部署指南

### 前端 → Vercel

```bash
# 安装Vercel CLI
npm i -g vercel

# 部署
cd apps/web
vercel --prod
```

**环境变量:**
```
NEXT_PUBLIC_API_URL=https://api.yoursite.com
NEXT_PUBLIC_WS_URL=wss://api.yoursite.com
```

### 后端 → Railway

```bash
# 安装Railway CLI
npm i -g @railway/cli

# 部署
cd apps/api
railway login
railway init
railway up
```

### 后端 → Fly.io

```bash
# 安装Fly CLI
brew install flyctl

# 部署
cd apps/api
flyctl launch
flyctl deploy
```

---

## 🏃 本地开发

```bash
# 1. 启动Python后端
cd apps/api
pip install -r requirements.txt
python main_api.py

# 2. 启动Next.js前端 (新终端)
cd apps/web
npm install
npm run dev

# 3. 访问 http://localhost:3000
```

---

## 📁 文件清单

| 路径 | 说明 |
|------|------|
| `apps/web/app/page.tsx` | 首页Landing Page |
| `apps/web/app/upload/page.tsx` | 文件上传页面 |
| `apps/web/app/processing/[id]/page.tsx` | 处理进度页面 |
| `apps/web/lib/websocket.ts` | WebSocket hook |
| `apps/web/lib/api.ts` | API客户端 |
| `apps/web/components/upload/file-upload.tsx` | 上传组件 |
| `apps/web/components/progress/progress-bar.tsx` | 进度条 |
| `apps/api/main_api.py` | FastAPI后端 |
| `apps/api/railway.toml` | Railway配置 |
| `apps/api/fly.toml` | Fly.io配置 |
| `.github/workflows/` | CI/CD工作流 |
| `PROJECT-NEXTJS.md` | 完整说明文档 |

---

## ⚠️ 注意事项

1. **Python后端无法部署到Vercel**,因为Vercel只支持Node.js运行时
2. 推荐部署方案:
- 前端: **Vercel** (免费)
- 后端: **Railway** 或 **Fly.io** (有免费额度)
3. SAM3模型需要GPU,确保后端部署在支持GPU的平台上
4. 需要配置环境变量 `NEXT_PUBLIC_API_URL` 指向后端地址

---

## 🎯 特性

- ✅ 拖拽上传图片/PDF
- ✅ WebSocket实时进度推送
- ✅ 多阶段处理显示 (预处理 → OCR → 分割 → 处理 → XML生成)
- ✅ 可配置转换选项
- ✅ 响应式设计
- ✅ 现代化UI
- ✅ 自动CI/CD部署
Loading