丸子 3 ヶ月 前
コミット
6739aa7566

+ 7 - 0
package-lock.json

@@ -15,6 +15,7 @@
         "@vue-office/excel": "^1.7.14",
         "@vue-office/pptx": "^1.0.1",
         "axios": "^1.10.0",
+        "crypto-js": "^4.2.0",
         "element-plus": "^2.10.2",
         "highlight.js": "^11.11.1",
         "hls.js": "^1.6.7",
@@ -3730,6 +3731,12 @@
         "node": ">= 8"
       }
     },
+    "node_modules/crypto-js": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
+      "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==",
+      "license": "MIT"
+    },
     "node_modules/cssesc": {
       "version": "3.0.0",
       "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz",

+ 1 - 0
package.json

@@ -16,6 +16,7 @@
     "@vue-office/excel": "^1.7.14",
     "@vue-office/pptx": "^1.0.1",
     "axios": "^1.10.0",
+    "crypto-js": "^4.2.0",
     "element-plus": "^2.10.2",
     "highlight.js": "^11.11.1",
     "hls.js": "^1.6.7",

+ 3 - 1
src/components/ai/text/TextToText.vue

@@ -635,8 +635,10 @@ onUnmounted(() => {
 // 暴露方法给父组件
 defineExpose({
   stopStream,
-  clearMessageList
+  clearMessageList,
+  stopPlayback
 });
+
 </script>
 
 <style scoped lang="scss">

+ 5 - 14
src/views/laboratory/ExperimentalInterface.vue

@@ -140,8 +140,6 @@ import ImageToVideo from "@/components/ai/video/ImageToVideo.vue";
 import MapGame from "@/components/blockly/MapGame.vue";
 // 根据ID获取课程列表
 import { getBlocklyByTypeId } from '@/api/programming/index.js'
-// 导入音频播放器
-import { useAudioPlayer } from '@/api/tts/useAudioPlayer';
 
 // 定义常量
 const CONSTANTS = {
@@ -156,8 +154,6 @@ const router = useRouter() // 获取当前路由对象
 const boxIconTitle = ref('')
 // AI组件refs
 const aiTextToText = ref(null)
-// 音频播放器实例
-const { stopPlayback } = useAudioPlayer();
 // 定义组件的props
 const props = defineProps({
   courseData: {
@@ -221,12 +217,11 @@ const playPreviousVideo = () => {
   if (props.courseList && props.courseList.length > 0) {
     const currentIndex = currentCourseIndex.value
     if (currentIndex > 0) {
-      // 停止音频播放并清理资源
-      stopPlayback();
-      // 终止AI问答流并清空消息列表
+      // 终止AI问答流并清空消息列表,同时清理语音资源
       if (aiTextToText.value) {
         aiTextToText.value.stopStream();
         aiTextToText.value.clearMessageList();
+        aiTextToText.value.stopPlayback();
       }
       const previousCourse = props.courseList[currentIndex - 1]
       // 更新当前课程数据
@@ -243,12 +238,11 @@ const playNextVideo = () => {
   if (props.courseList && props.courseList.length > 0) {
     const currentIndex = currentCourseIndex.value
     if (currentIndex !== -1 && currentIndex < props.courseList.length - 1) {
-      // 停止音频播放并清理资源
-      stopPlayback();
-      // 终止AI问答流并清空消息列表
+      // 终止AI问答流并清空消息列表,同时清理语音资源
       if (aiTextToText.value) {
         aiTextToText.value.stopStream();
         aiTextToText.value.clearMessageList();
+        aiTextToText.value.stopPlayback();
       }
       const nextCourse = props.courseList[currentIndex + 1]
       // 更新当前课程数据
@@ -427,10 +421,7 @@ onMounted(async () => {
 })
 
 // 清理函数
-onUnmounted(() => {
-  // 组件卸载时清理音频资源
-  stopPlayback();
-})
+onUnmounted(() => {})
 
 // 保存视频/bockly进度接口
 const handleSaveProgress = async (type, progress) => {