diff --git a/README.md b/README.md index b0d567b..87ddebd 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ curl -F "file=@report.pdf" http://localhost:8080/upload | POST | `/upload` | 上传文件(`multipart/form-data`,字段名 `file`) | | GET | `/files` | 列出当前未过期文件 | | GET | `/download/:filename` | 下载文件 | +| POST | `/download-zip` | 批量下载 (body: `{"files":[...]}`, 最多 100 项) | | DELETE | `/files/:filename` | 删除文件 | --- @@ -60,19 +61,21 @@ curl -F "file=@report.pdf" http://localhost:8080/upload ```text tmp-upload/ -├── main.go # 入口、配置、路由注册 (60 行) -├── embed.go # //go:embed + init() 拼接 (29 行) +├── main.go # 入口、配置、路由注册 (61 行) +├── embed.go # //go:embed + init() 拼接 (38 行) ├── audit.go # 审计日志子系统 (102 行) ├── quota.go # 配额管理 + formatSize (112 行) -├── handlers.go # HTTP handlers + DTOs (296 行) +├── handlers.go # HTTP handlers + DTOs (440 行) ├── cleaner.go # TTL 过期清理 (57 行) ├── audit_test.go # audit 单元测试 ├── security_test.sh # HTTP 端到端测试 ├── go.mod / go.sum └── static/ ├── index.html.tpl # HTML 骨架 (含 /*EMBED_CSS*/、/*EMBED_JS*/ 占位符) - ├── app.css # CSS (327 行) - └── app.js # JS (486 行) + ├── app.css # CSS (357 行) + ├── app.js # JS — 主程序 (441 行) + ├── helpers.js # JS — 纯函数 + 倒计时 (58 行) + └── batch.js # JS — 批量选择 / 批量下载 (87 行) ``` ### 单文件部署说明 diff --git a/embed.go b/embed.go index dbbc6fc..a2a95a2 100644 --- a/embed.go +++ b/embed.go @@ -17,6 +17,12 @@ var appCSS []byte //go:embed static/app.js var appJS []byte +//go:embed static/helpers.js +var helpersJS []byte + +//go:embed static/batch.js +var batchJS []byte + // pageHTML is the assembled single-file deployment response. // Computed once at startup; same bytes served on every GET /. var pageHTML []byte @@ -24,6 +30,9 @@ var pageHTML []byte func init() { s := string(indexTpl) s = strings.Replace(s, "/*EMBED_CSS*/", string(appCSS), 1) - s = strings.Replace(s, "/*EMBED_JS*/", string(appJS), 1) + // JS 顺序敏感: app 先声明 consts / 注册 handlers; helpers 后注入纯函数; + // batch 最后使用 consts 并启动 boot. 同