chore: 项目基线提交 - 拼豆图纸生成器 V1.0 核心代码

- 前端: React+Vite 首页/AI专区, 算法库(MARD色板/量化/背景去除), API对接
- 后端: Express+SQLite, 兑换码/订单/支付/chibi生成, 风控+云端同步
- CI/CD: GitHub Actions + Docker + nginx 配置
- 文档: PRD/DESIGN/LAUNCH/ROADMAP/E2E/竞品对照等 15 份
- 工程: 任务看板(taskboard) + 健康巡检(agent-health) + Git流程(gitflow)
This commit is contained in:
Sisyphus (主代理) committed 2026-08-13 21:40:27 +08:00
commit 02762400fb
174 files changed
+28059

No files matched your search

+105
View File
@@ -0,0 +1,105 @@
# =============================================================================
# PERLER LAB — Nginx 前端服务配置
# 用途:SPA 路由回退 + 静态资源缓存 + 安全头 + Gzip + API 反向代理
# 部署方式:docker-compose 中作为 frontend 服务,/api 反向代理到 server 服务
# =============================================================================
#
# 兼容性说明:
# - 当前 perler-lab 为 Vite + React 单页应用(vite build → dist/)
# - 若未来迁移到 Next.js,需改为 next build + node server 模式,此配置转为
# 上层 Nginx 反代(参考 DEPLOY.md 的域名 HTTPS 方案)
#
# =============================================================================
upstream backend {
# docker-compose 中 backend 服务名为 server,端口 8788
server server:8788;
}
server {
listen 80 default_server;
server_name _;
# ── 静态文件根目录(Vite 构建产物 dist/ 合并至此,index.html 在根目录) ──
root /usr/share/nginx/html;
index index.html;
# ── Gzip 压缩 ──
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_min_length 1024;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/json
application/javascript
application/xml
application/xml+rss
application/octet-stream
image/svg+xml
image/x-icon;
# ── 安全头 ──
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
# 若需 CSP 可在此加,但拼豆工具需要加载用户上传图片,暂不限制过严
# add_header Content-Security-Policy "default-src 'self'; img-src 'self' data: blob:; ..." always;
# ── 静态资源:强缓存(Vite 产物文件名带内容 hash,可 immutable) ──
location /assets/ {
expires 30d;
add_header Cache-Control "public, immutable, max-age=2592000";
access_log off;
}
# ── Favicon ──
location = /favicon.svg {
expires 7d;
add_header Cache-Control "public, max-age=604800";
access_log off;
}
# ── API 反向代理 → 后端服务 ──
location /api/ {
proxy_pass http://backend;
proxy_http_version 1.1;
# 传递客户端真实信息
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# 超时配置(后端可能有较长时间计算,酌情调大)
proxy_read_timeout 120s;
proxy_send_timeout 30s;
# 关闭缓冲,便于 SSE / 大响应
proxy_buffering off;
}
# ── 健康检查端点 ──
location = /healthz {
access_log off;
return 200 "OK";
}
# ── SPA 路由回退 ──
location / {
try_files $uri $uri/ /index.html;
}
# ── 拒绝访问隐藏文件 ──
location ~ /\.(?!well-known) {
deny all;
access_log off;
log_not_found off;
}
}