From 51f1fe96bf69b9e3bcf6d1e560c672bb374dfa36 Mon Sep 17 00:00:00 2001
From: "tao.chen" <93983997+taochen-ct@users.noreply.github.com>
Date: Fri, 28 Aug 2026 10:54:08 +0800
Subject: [PATCH] feat: batch delete
---
README.md | 27 +++--
batch.go | 255 ++++++++++++++++++++++++++++++++++++++++++
embed.go | 40 +++----
handlers.go | 133 ----------------------
main.go | 16 ++-
security_test.sh | 65 +++++++++++
static/app.css | 2 +
static/app.js | 4 +-
static/batch.js | 39 ++++++-
static/helpers.js | 2 +-
static/index.html.tpl | 9 +-
11 files changed, 408 insertions(+), 184 deletions(-)
create mode 100644 batch.go
diff --git a/README.md b/README.md
index 87ddebd..b70dc30 100644
--- a/README.md
+++ b/README.md
@@ -48,11 +48,12 @@ curl -F "file=@report.pdf" http://localhost:8080/upload
| Method | Path | 说明 |
|--------|----------------------------|--------------------------------------------|
-| GET | `/` | Web UI(单 HTML 响应,内联 CSS + JS) |
+| GET | `/` | Web UI(单 HTML 响应,CSS/JS 经 `/static` 引用) |
| POST | `/upload` | 上传文件(`multipart/form-data`,字段名 `file`) |
| GET | `/files` | 列出当前未过期文件 |
| GET | `/download/:filename` | 下载文件 |
| POST | `/download-zip` | 批量下载 (body: `{"files":[...]}`, 最多 100 项) |
+| POST | `/files-delete` | 批量删除 (body: `{"files":[...]}`, 最多 100 项) |
| DELETE | `/files/:filename` | 删除文件 |
---
@@ -61,29 +62,31 @@ curl -F "file=@report.pdf" http://localhost:8080/upload
```text
tmp-upload/
-├── main.go # 入口、配置、路由注册 (61 行)
-├── embed.go # //go:embed + init() 拼接 (38 行)
+├── main.go # 入口、配置、路由注册 (72 行)
+├── embed.go # //go:embed + fs.Sub 静态资源 (26 行)
├── audit.go # 审计日志子系统 (102 行)
├── quota.go # 配额管理 + formatSize (112 行)
-├── handlers.go # HTTP handlers + DTOs (440 行)
+├── handlers.go # HTTP handlers + DTOs (308 行)
+├── batch.go # 批量下载 / 批量删除 handlers (248 行)
├── 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 (357 行)
- ├── app.js # JS — 主程序 (441 行)
+ ├── index.html.tpl # HTML 骨架 (经 /static 引用 CSS/JS, 含批量删除按钮)
+ ├── app.css # CSS (359 行)
+ ├── app.js # JS — 主程序 (443 行)
├── helpers.js # JS — 纯函数 + 倒计时 (58 行)
- └── batch.js # JS — 批量选择 / 批量下载 (87 行)
+ └── batch.js # JS — 批量选择 / 批量下载 / 批量删除 (119 行)
```
### 单文件部署说明
-`embed.go` 用 `//go:embed` 把三个静态文件全部编入二进制,
-在 `init()` 中用 `strings.Replace` 把 CSS/JS 拼到 HTML 骨架里生成 `pageHTML`。
-浏览器访问 `/` 拿到的是**一个**完整 HTML 响应(HTML+CSS+JS 全部内联),
-不产生额外的 `` / `
+
+
+