Skip to content

Commit 6594e17

Browse files
committed
feat: 完整的力扣56题合并区间可视化项目
✨ 新功能: - 完整的区间合并算法可视化 - 多彩色编码系统,不同合并结果用不同颜色标识 - 智能数轴显示,支持动态刻度、端点值、连接线 - 多轨道布局,避免重叠区间互相遮挡 - Web Speech API 语音讲解(默认开启) - 双语支持(中文/英文切换) - 完善的交互控制(播放/暂停/单步/速度调节) - 键盘快捷键支持 - 响应式单屏布局,无需滚动 - 详细的算法步骤说明和复杂度分析 🎨 视觉优化: - 题目难度标签和相关标签显示 - 6种配色方案(无紫色),金色表示处理中状态 - 流畅的动画效果和过渡 - 箭头连接显示合并关系 - 图例和状态图标 🚀 部署配置: - GitHub Actions 自动部署 - 完整的部署文档(DEPLOYMENT.md) - 快速开始指南(QUICKSTART.md) - 部署状态徽章 📦 技术栈: - React 18 - CSS3 动画和渐变 - Web Speech API - GitHub Actions 🔧 配置文件: - 完善的 .gitignore - 端口配置 49406(严禁修改) - 详细的 README 文档
1 parent 51c590a commit 6594e17

18 files changed

+3302
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main # 当推送到main分支时触发
7+
workflow_dispatch: # 允许手动触发
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
# 只允许一个并发部署
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: true
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: 检出代码
25+
uses: actions/checkout@v4
26+
27+
- name: 设置 Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: '18'
31+
cache: 'npm'
32+
33+
- name: 安装依赖
34+
run: npm ci
35+
36+
- name: 构建项目
37+
run: npm run build
38+
env:
39+
CI: false # 忽略警告,避免构建失败
40+
41+
- name: 设置 Pages
42+
uses: actions/configure-pages@v4
43+
44+
- name: 上传构建产物
45+
uses: actions/upload-pages-artifact@v3
46+
with:
47+
path: ./build
48+
49+
deploy:
50+
environment:
51+
name: github-pages
52+
url: ${{ steps.deployment.outputs.page_url }}
53+
54+
runs-on: ubuntu-latest
55+
needs: build
56+
57+
steps:
58+
- name: 部署到 GitHub Pages
59+
id: deployment
60+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
package-lock.json
8+
yarn.lock
9+
10+
# testing
11+
/coverage
12+
13+
# production
14+
/build
15+
16+
# misc
17+
.DS_Store
18+
.env.local
19+
.env.development.local
20+
.env.test.local
21+
.env.production.local
22+
23+
# logs
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
lerna-debug.log*
28+
*.log
29+
30+
# IDE
31+
.idea/
32+
.vscode/
33+
*.swp
34+
*.swo
35+
*~
36+
.project
37+
.classpath
38+
.settings/
39+
*.sublime-project
40+
*.sublime-workspace
41+
42+
# OS
43+
.DS_Store
44+
.DS_Store?
45+
._*
46+
.Spotlight-V100
47+
.Trashes
48+
ehthumbs.db
49+
Thumbs.db
50+
Desktop.ini
51+
52+
# Optional npm cache directory
53+
.npm
54+
55+
# Optional eslint cache
56+
.eslintcache
57+
58+
# Optional REPL history
59+
.node_repl_history
60+
61+
# Output of 'npm pack'
62+
*.tgz
63+
64+
# Yarn Integrity file
65+
.yarn-integrity
66+
67+
# dotenv environment variables file
68+
.env
69+
.env.test
70+
71+
# Next.js
72+
.next/
73+
out/
74+
75+
# Gatsby
76+
.cache/
77+
public/
78+
79+
# Debug
80+
npm-debug.log*
81+
yarn-debug.log*
82+
yarn-error.log*
83+
84+
# Local env files
85+
.env*.local
86+
87+
# Vercel
88+
.vercel
89+
90+
# TypeScript
91+
*.tsbuildinfo

DEPLOYMENT.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# GitHub Pages 自动部署配置
2+
3+
本项目已配置 GitHub Actions 自动部署到 GitHub Pages。
4+
5+
## 部署流程
6+
7+
### 1. 启用 GitHub Pages
8+
9+
在 GitHub 仓库设置中启用 GitHub Pages:
10+
11+
1. 进入仓库的 **Settings****Pages**
12+
2.**Source** 下拉菜单中选择 **GitHub Actions**
13+
3. 保存设置
14+
15+
### 2. 自动部署
16+
17+
配置完成后,每次推送代码到 `main` 分支时,GitHub Actions 会自动:
18+
19+
1. ✅ 检出代码
20+
2. ✅ 安装 Node.js 和依赖
21+
3. ✅ 构建 React 应用
22+
4. ✅ 部署到 GitHub Pages
23+
24+
### 3. 手动触发部署
25+
26+
也可以在 GitHub 仓库的 **Actions** 页面手动触发部署:
27+
28+
1. 进入 **Actions** 标签页
29+
2. 选择 **Deploy to GitHub Pages** workflow
30+
3. 点击 **Run workflow** 按钮
31+
32+
## 访问地址
33+
34+
部署成功后,可以通过以下地址访问:
35+
36+
```
37+
https://fuck-algorithm.github.io/leetcode-56-merge-intervals/
38+
```
39+
40+
或者在仓库的 GitHub Pages 设置页面查看实际的部署地址。
41+
42+
## 部署状态
43+
44+
可以在以下位置查看部署状态:
45+
46+
- **Actions 页面**:查看构建和部署日志
47+
- **Deployments**:在仓库主页右侧边栏查看部署历史
48+
- **徽章**:可以添加部署状态徽章到 README
49+
50+
## 配置文件说明
51+
52+
### `.github/workflows/deploy.yml`
53+
54+
GitHub Actions 工作流配置文件,包含:
55+
56+
- **触发条件**:推送到 main 分支或手动触发
57+
- **构建步骤**:安装依赖、构建项目
58+
- **部署步骤**:上传到 GitHub Pages
59+
60+
### `package.json`
61+
62+
确保包含以下配置:
63+
64+
```json
65+
{
66+
"homepage": ".",
67+
"scripts": {
68+
"build": "react-scripts build"
69+
}
70+
}
71+
```
72+
73+
## 注意事项
74+
75+
1. **分支名称**:确保主分支名称是 `main`,如果是 `master` 需要修改 workflow 文件
76+
2. **构建时间**:首次部署可能需要几分钟
77+
3. **缓存**:浏览器可能会缓存旧版本,可以使用硬刷新(Ctrl+F5 或 Cmd+Shift+R)
78+
4. **端口配置**:GitHub Pages 使用默认端口,`.env` 中的 `PORT=49406` 仅用于本地开发
79+
80+
## 本地测试构建
81+
82+
在推送前可以本地测试构建:
83+
84+
```bash
85+
# 构建项目
86+
npm run build
87+
88+
# 本地预览构建结果(需要安装 serve)
89+
npx serve -s build
90+
```
91+
92+
## 故障排查
93+
94+
### 构建失败
95+
96+
1. 检查 Actions 页面的错误日志
97+
2. 确保所有依赖都在 `package.json`
98+
3. 本地运行 `npm run build` 测试
99+
100+
### 页面空白
101+
102+
1. 检查 `homepage` 配置是否正确
103+
2. 查看浏览器控制台是否有错误
104+
3. 确认静态资源路径正确
105+
106+
### 更新未生效
107+
108+
1. 等待 1-2 分钟让部署完成
109+
2. 清除浏览器缓存
110+
3. 检查 Actions 是否成功运行
111+
112+
## 开发工作流
113+
114+
推荐的开发和部署流程:
115+
116+
```bash
117+
# 1. 本地开发
118+
npm start
119+
120+
# 2. 测试功能
121+
# 访问 http://localhost:49406
122+
123+
# 3. 提交代码
124+
git add .
125+
git commit -m "功能更新"
126+
127+
# 4. 推送到 GitHub(自动触发部署)
128+
git push origin main
129+
130+
# 5. 等待部署完成
131+
# 在 Actions 页面查看进度
132+
133+
# 6. 访问线上地址验证
134+
# https://fuck-algorithm.github.io/leetcode-56-merge-intervals/
135+
```
136+
137+
## 环境变量
138+
139+
本地开发和生产环境使用不同的配置:
140+
141+
- **本地开发**:使用 `.env` 文件,端口 49406
142+
- **生产环境**:GitHub Pages 自动配置,使用标准 HTTPS
143+
144+
## 更新日志
145+
146+
部署配置会在 Actions 页面自动记录每次部署的时间和提交信息。

0 commit comments

Comments
 (0)