feat(upload): 分片断点续传 + 前端静态资源去 CDN 化

1) 分片上传(routes/chunked.py)
   - POST /api/upload/init  建会话,校验表单/字段/扩展名/体积
   - POST /api/upload/chunk 单片上传,幂等可重传,http body 直写磁盘
   - GET  /api/upload/status 查询已收分片
   - POST /api/upload/complete 按序合并 + sha256 校验 + 清理分片
   - /api/submit 新增 field fileTokens 挂载已上传文件(零拷贝 os.replace)
   - 过期会话(24h)由定时任务清理

2) 弱网下的样式可靠性
   - Tailwind Play CDN / GSAP 改为本地自托管(static/js/vendor/)
   - vendor 资源 1 年 immutable 缓存,自家 css/js 1 小时
   - CSS link 失败自动带 ?r= 重试一次
   - status 页加关键内联样式兜底,极端情况下仍可读

3) 大文件落盘沿用流式写入(无 400MB 内存峰值)
This commit is contained in:
zzy
2026-11-13 12:06:32 +08:00
parent 92dedc38e7
commit 84f8516c37
20 changed files with 614 additions and 59 deletions
+17 -4
View File
@@ -11,7 +11,7 @@
<title>表单状态</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script src="/static/js/vendor/tailwind-play.js"></script>
<script>
tailwind.config = {
darkMode: 'class',
@@ -39,11 +39,24 @@
<!-- ECharts for data visualization -->
<script src="/static/js/echart.js"></script>
<!-- GSAP for animations -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="/static/js/vendor/gsap.min.js"></script>
<script src="/static/js/particles.js"></script>
<script src="/static/js/toast.js"></script>
<link rel="stylesheet" href="/static/css/basic.css">
<link rel="stylesheet" href="/static/css/common.css">
<style id="critical-fallback">
/* 弱网兜底:即使外部 CSS/JS 全部失败,页面仍是可读的深色卡片布局,
不会退化成无样式的一长串文字。Tailwind 加载成功后会接管细节样式。 */
html, body { background: #0b1220; color: #e5e7eb; margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
body > * { max-width: 1100px; margin: 0 auto; }
h1, h2, h3 { line-height: 1.3; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid #1f2a3a; text-align: left; font-size: 14px; }
a { color: #7dd3fc; }
button { font: inherit; padding: 6px 12px; border-radius: 8px; border: 1px solid #334155;
background: #16233a; color: #e5e7eb; cursor: pointer; }
</style>
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
<script src="/static/js/common.js"></script>
<style>