From 1813bc8c0b305d12e8f218ae4c831048598735ea Mon Sep 17 00:00:00 2001 From: wwh <496479012@qq.com> Date: Mon, 18 May 2026 15:15:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=A3=80=E6=B5=8B=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=8B=86?= =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BB=B6=E5=B9=B6=E4=BC=98=E5=8C=96=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 后端api修改:将图片结果返回从文件路径改为base64格式,移除本地文件存储 2. 新增图片检测组件ImageDetection.vue,封装独立的图片检测UI逻辑 3. 重构Home页面,使用tab切换图片/视频检测模块,简化原有布局 4. 更新web包名与rollup依赖版本 --- apps/server/api/detection.py | 13 +- apps/web/src/components/ImageDetection.vue | 673 +++++++++++++++ apps/web/src/components/VideoDetection.vue | 932 +++++++++++++++++++++ apps/web/src/views/Home.vue | 806 +----------------- 4 files changed, 1657 insertions(+), 767 deletions(-) create mode 100644 apps/web/src/components/ImageDetection.vue create mode 100644 apps/web/src/components/VideoDetection.vue diff --git a/apps/server/api/detection.py b/apps/server/api/detection.py index 95d2c17..d986789 100644 --- a/apps/server/api/detection.py +++ b/apps/server/api/detection.py @@ -36,18 +36,17 @@ async def detect_image( if result['success']: annotated_frame = detection_service.draw_detections(frame, result['detections']) - - import uuid - result_filename = f"result_{uuid.uuid4().hex[:8]}.jpg" - result_path = f"static/results/{result_filename}" - cv2.imwrite(result_path, annotated_frame) - + + # 将标注后的图片转换为 base64 + _, buffer = cv2.imencode('.jpg', annotated_frame) + img_base64 = base64.b64encode(buffer).decode('utf-8') + return ImageDetectionResult( success=True, message="检测完成", data={ "detections": result['detections'], - "image_url": f"/static/results/{result_filename}", + "image_base64": img_base64, "stats": result['stats'] } ) diff --git a/apps/web/src/components/ImageDetection.vue b/apps/web/src/components/ImageDetection.vue new file mode 100644 index 0000000..c97c118 --- /dev/null +++ b/apps/web/src/components/ImageDetection.vue @@ -0,0 +1,673 @@ + + + + + diff --git a/apps/web/src/components/VideoDetection.vue b/apps/web/src/components/VideoDetection.vue new file mode 100644 index 0000000..d3ed688 --- /dev/null +++ b/apps/web/src/components/VideoDetection.vue @@ -0,0 +1,932 @@ + + + + + diff --git a/apps/web/src/views/Home.vue b/apps/web/src/views/Home.vue index aee4c5b..02eb238 100644 --- a/apps/web/src/views/Home.vue +++ b/apps/web/src/views/Home.vue @@ -1,809 +1,95 @@ + \ No newline at end of file