Преглед изворни кода

feat(speaking): show real audioDuration on student voice bubble

Replaces hardcoded '0:04' on the student bubble with a formatted
audioDuration value (falls back to '--:--' when null). Removes the AI
bubble duration span entirely — TTS audio has no persisted duration
and the visual was misleading.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jimmylee пре 2 месеци
родитељ
комит
d26e258bfc
1 измењених фајлова са 9 додато и 5 уклоњено
  1. 9 5
      src/views/Editor/EnglishSpeaking/preview/DialogueChatView.vue

+ 9 - 5
src/views/Editor/EnglishSpeaking/preview/DialogueChatView.vue

@@ -95,10 +95,6 @@
                 v-if="player.errorId.value === message.id"
                 class="play-error-hint"
               >点击重试</span>
-              <span
-                v-else
-                class="voice-duration voice-duration-ai"
-              >0:04</span>
             </div>
 
             <!-- 英文文本 -->
@@ -137,7 +133,7 @@
             <span
               v-else
               class="voice-duration voice-duration-student"
-            >0:04</span>
+            >{{ formatDuration(message.audioDuration) }}</span>
             <div class="wave-bar-group">
               <div
                 v-for="i in 14"
@@ -701,6 +697,14 @@ function formatSeconds(s: number): string {
   return `${m}:${sec.toString().padStart(2, '0')}`
 }
 
+function formatDuration(seconds: number | null | undefined): string {
+  if (seconds == null || !Number.isFinite(seconds)) return '--:--'
+  const total = Math.round(seconds)
+  const mins = Math.floor(total / 60)
+  const secs = total % 60
+  return `${mins}:${String(secs).padStart(2, '0')}`
+}
+
 function getWordAnalysis(message: PreviewChatMessage, word: string) {
   const clean = word.replace(/[.,!?]/g, '')
   return message.evaluation?.wordAnalysis?.find(w => w.word === clean)