diff --git a/README.md b/README.md index 35a851b..27aa6f3 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ ├── web/ │ ├── app.py # Web 服务入口 │ ├── templates/ -│ │ └── index.html # Web 前端页面 +│ │ ├── index.html # Web 前端页面 +│ │ └── mobile_upload.html # 移动端扫码上传页面 │ └── uploads/ # 用户上传文件目录 ├── *.pdf # 发票 PDF(按需放置) ├── *.png / *.jpg # 与 PDF 同名的支付截图 @@ -133,6 +134,7 @@ python web/app.py | 实时日志 | 处理进度通过 SSE 实时推送 | | 下载 CSV | 处理后下载发票汇总表 | | 配置上传 | 可上传 `config.json` 自动填充表单 | +| 手机扫码上传 | 支付截图区域显示二维码,手机端扫码后可拍照/选图上传,PC 端实时同步接收 | > Web 模式下浏览器以无头模式运行,不会弹出窗口。 > 若未上传 PDF 附件,浏览器填报阶段将自动跳过附件上传步骤。 diff --git a/web/app.py b/web/app.py index 51498c9..eedaec2 100644 --- a/web/app.py +++ b/web/app.py @@ -369,6 +369,21 @@ def _escape_sse(text: str) -> str: return text.replace("\r\n", "\n").replace("\r", "\n").replace("\n", "\ndata: ") +@app.route("/mobile/") +def mobile_upload(session_id: str): + """移动端上传页面""" + session_dir = UPLOAD_BASE / session_id + if not session_dir.exists(): + return render_template("mobile_upload.html", error="会话不存在"), 404 + return render_template("mobile_upload.html", session_id=session_id) + + +@app.route("/api/mobile-upload/", methods=["POST"]) +def mobile_upload_file(session_id: str): + """移动端上传图片(复用 PC 上传逻辑)""" + return upload_file(session_id) + + if __name__ == "__main__": UPLOAD_BASE.mkdir(parents=True, exist_ok=True) print(f"启动 Web 服务: http://localhost:5000") diff --git a/web/templates/index.html b/web/templates/index.html index cb03d0d..affac5b 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -37,7 +37,7 @@ body { background: #f5f7fa; }
-
+
📄 发票 PDF (多选)
📁
@@ -46,7 +46,7 @@ body { background: #f5f7fa; }
-
+
🖼️ 支付截图 (多选)
🖼️
@@ -55,6 +55,11 @@ body { background: #f5f7fa; }
+
+
📱 手机扫码上传
+
+

扫码即可拍照上传

+
@@ -126,6 +131,7 @@ body { background: #f5f7fa; }
+ \ No newline at end of file diff --git a/web/templates/mobile_upload.html b/web/templates/mobile_upload.html new file mode 100644 index 0000000..3e45eaa --- /dev/null +++ b/web/templates/mobile_upload.html @@ -0,0 +1,124 @@ + + + + + +支付截图上传 + + + + + +{% if error %} +
错误

{{ error }}

+{% else %} + +
+
📸 支付截图上传
+

拍照或从相册选择图片

+
+ +
+ + + + + + + +
+ + +
已上传 ({{ server_count | default(0) }})
+
+ +
+{% endif %} + + + + \ No newline at end of file