Ver Fonte

语音重试机制修改

Zhangbw há 2 meses atrás
pai
commit
37a7820660
4 ficheiros alterados com 13 adições e 17 exclusões
  1. 0 0
      dist/assets/index-Bu_yvNO8.css
  2. 0 0
      dist/assets/index-C-_6BDvZ.js
  3. 2 2
      dist/index.html
  4. 11 15
      src/CustomerService.vue

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
dist/assets/index-Bu_yvNO8.css


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
dist/assets/index-C-_6BDvZ.js


+ 2 - 2
dist/index.html

@@ -9,8 +9,8 @@
     html, body { width: 100%; height: 100%; overflow: hidden; }
     body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
   </style>
-  <script type="module" crossorigin src="/assets/index-COMs89qP.js"></script>
-  <link rel="stylesheet" crossorigin href="/assets/index-Cg9khDjC.css">
+  <script type="module" crossorigin src="/assets/index-C-_6BDvZ.js"></script>
+  <link rel="stylesheet" crossorigin href="/assets/index-Bu_yvNO8.css">
 </head>
 <body>
   <div id="app"></div>

+ 11 - 15
src/CustomerService.vue

@@ -401,9 +401,8 @@ watch(streamConversationId, (newId) => {
 // 监听 showChat 变化,开始对话时自动启动语音识别
 watch(showChat, async (newVal) => {
   if (newVal && !isRecording.value) {
-    // 尝试启动语音识别,最多重试 3 次
+    // 无限重试语音识别,重试间隔逐渐增加
     let retryCount = 0
-    const maxRetries = 3
 
     const tryStartRecording = async () => {
       try {
@@ -415,19 +414,16 @@ watch(showChat, async (newVal) => {
         return true
       } catch (error) {
         retryCount++
-        console.error(`语音识别启动失败 (尝试 ${retryCount}/${maxRetries}):`, error)
-
-        if (retryCount < maxRetries) {
-          ElMessage.warning(`语音识别启动失败,正在重试 (${retryCount}/${maxRetries})...`)
-          // 等待 1 秒后重试
-          await new Promise(resolve => setTimeout(resolve, 1000))
-          return tryStartRecording()
-        } else {
-          ElMessage.error('语音识别启动失败,已切换到文字输入模式')
-          // 多次重试都失败,切换到文字输入模式
-          isTextInput.value = true
-          return false
-        }
+        console.error(`语音识别启动失败 (尝试 ${retryCount} 次):`, error)
+
+        // 固定重试间隔:2秒
+        const retryDelay = 2000
+
+        ElMessage.warning(`语音识别启动失败,2秒后重试...`)
+
+        // 等待后重试
+        await new Promise(resolve => setTimeout(resolve, retryDelay))
+        return tryStartRecording()
       }
     }
 

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff