From 0a417ce4f5391365dc1eb21c4f9dd2b5345f8201 Mon Sep 17 00:00:00 2001
From: root <13910913995@163.com>
Date: Wed, 10 Sep 2025 18:38:22 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86=E6=A3=80=E6=B5=8B?=
=?UTF-8?q?=E9=A1=B5=E9=9D=A2=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/main.py | 2 +-
frontend/src/renderer/src/views/Detection.vue | 38 +++++++++----------
2 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/backend/main.py b/backend/main.py
index cf65c454..9133e58d 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -985,7 +985,7 @@ class AppServer:
# 调用create_detection_session方法,settings传空字典
session_id = self.db_manager.create_detection_session(patient_id, settings={}, creator_id=creator_id)
- return jsonify({'success': True, 'session_id': session_id, 'detectionStartTime': start_time})
+ return jsonify({'success': True, 'session_id': session_id})
except Exception as e:
self.logger.error(f'开始检测失败: {e}')
return jsonify({'success': False, 'error': str(e)}), 500
diff --git a/frontend/src/renderer/src/views/Detection.vue b/frontend/src/renderer/src/views/Detection.vue
index b7db3264..7740bd10 100644
--- a/frontend/src/renderer/src/views/Detection.vue
+++ b/frontend/src/renderer/src/views/Detection.vue
@@ -26,15 +26,15 @@
class="start-title-btn" style="background-image: linear-gradient(to right, rgb(236, 50, 166), rgb(160, 5, 216));
--el-button-border-color: #409EFF;
--el-button-border-color: transparent;width: 120px;height: 30px;font-size: 20px;">
- {{ isConnected ? '开始' : '连接中...' }}
+ {{ isConnected ? '开始录像' : '录像中...' }}
- 结束
+ 结束录像
-
保存数据
@@ -1513,7 +1513,7 @@ async function handleDiagnosticInfo(status) {
message: status + '诊断信息成功',
duration: 5000
})
- patientInfo.value.sessionId = null
+
} else {
throw new Error(result.message || '诊断信息失败')
}
@@ -1522,9 +1522,9 @@ async function handleDiagnosticInfo(status) {
message: errorMessage,
duration: 5000
})
- patientInfo.value.sessionId = null
+
} finally {
- patientInfo.value.sessionId = null
+
}
}
@@ -1672,8 +1672,7 @@ async function handleStartStop() {
if (isStart.value) {
// 停止录制视频
await stopRecord()
- } else {
- patientInfo.value.sessionId = null
+ } else {
// 开始录制视频
await startRecord()
}
@@ -1681,8 +1680,8 @@ async function handleStartStop() {
// 开始检测
async function startDetection() {
try {
- console.log('🚀 正在开始检测...')
- startTimer()
+ console.log('🚀 正在开始检测...')
+
// 验证患者信息
if (!patientInfo.value || !patientInfo.value.id) {
throw new Error('缺少患者信息,无法开始检测')
@@ -1704,7 +1703,7 @@ async function startDetection() {
}
const result = await response.json()
-
+ debugger
if (result.success) {
console.log('✅ 检测开始成功')
// 保存会话ID和检测开始时间
@@ -1767,6 +1766,7 @@ const loadPatientInfo = async () => {
const result = await response.json()
if (result.success) {
patientInfo.value = { ...result.data, sessionId: null }
+ startDetection()
console.log('患者信息加载成功:', patientInfo.value)
} else {
throw new Error(result.message)
@@ -1782,18 +1782,15 @@ const loadPatientInfo = async () => {
// 处理页面关闭或刷新事件
const handleBeforeUnload = (event) => {
- console.log('页面即将关闭,正在清理资源...')
-
- // 停止检测(如果正在检测)
- if (isStart.value) {
- stopDetection()
- }
+ console.log('页面即将关闭,正在清理资源...')
// 停止录像(如果正在录像)
if (isRecording.value) {
stopRecording()
}
-
+
+ // 停止检测
+ stopDetection()
// 断开WebSocket连接
disconnectWebSocket()
@@ -1947,7 +1944,7 @@ onMounted(() => {
loadPatientInfo()
// 页面加载时自动连接WebSocket
connectWebSocket()
- startDetection()
+
// 监听页面关闭或刷新事件
window.addEventListener('beforeunload', handleBeforeUnload)
if (authStore.currentUser) {
@@ -1966,7 +1963,6 @@ onUnmounted(() => {
stopRecording()
}
if(isStart.value == true){
-
stopRecord()
}
@@ -2007,7 +2003,7 @@ onUnmounted(() => {
const startRecord = async () => { // 开始录屏
try {
console.log('🚀 正在开始录屏...')
-
+ debugger
// 验证患者信息
if (!patientInfo.value || !patientInfo.value.sessionId) {
throw new Error('缺少患者信息,无法开始录屏')