diff --git a/.env.development b/.env.development index 57cec9ff..1ef36d92 100644 --- a/.env.development +++ b/.env.development @@ -24,12 +24,12 @@ VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' # 线上 # VITE_APP_BASE_H5_API_Url = 'https://aitstest.jlbank.com.cn:7001' -VITE_APP_BASE_H5_API_Url = 'https://aitstest.jlbank.com.cn:7001' +VITE_APP_BASE_H5_API_Url = 'http://25.18.122.66:9786' # VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://25.64.16.130:9601' -VITE_APP_BASE_H5_API_Url_TRASTUDY = 'http://25.64.16.130:9602' -VITE_APP_BASE_H5_API_Url_TRAASK = 'http://25.64.16.144:9605' +#VITE_APP_BASE_H5_API_Url_TRASTUDY = 'http://25.64.16.130:9602' +#VITE_APP_BASE_H5_API_Url_TRAASK = 'http://25.64.16.144:9605' # 王洋洋 diff --git a/src/api/preview.js b/src/api/preview.js new file mode 100644 index 00000000..cbf1e63e --- /dev/null +++ b/src/api/preview.js @@ -0,0 +1,12 @@ +import request from '@/api/request' +const base_url = '/trastudy' + + +export const queryTraStdyInfoPreviewPaging = (data) => { + return request({ + url: base_url + '/traStdyInfoPreview/queryTraStdyInfoPreviewPaging', + method: 'post', + toastErrors: true, + data + }); +}; diff --git a/src/components/examination/question.vue b/src/components/examination/question.vue index 2dfc9466..e2657e7c 100644 --- a/src/components/examination/question.vue +++ b/src/components/examination/question.vue @@ -102,6 +102,7 @@ type: String } }); + const audioStore = useAudioStore(); const { dataInfo } = toRefs(props); const status = computed(() => props.status); @@ -146,11 +147,15 @@ }; const playVoice = () => { - console.log('播放音频', props.dataInfo.voicePath); - isPlaying.value = true; - audioStore.playAudio(props.dataInfo.voicePath); + // isPlaying.value = true; + console.log('点击播放'); + audioStore.playAudio(); }; onMounted(() => { + // 2. 监听 Store 中 isPlaying 的变化,实时同步 + const unsubscribe = audioStore.$subscribe((mutation, state) => { + isPlaying.value = state.isPlaying; + }); // 注册播放完成回调 audioStore.onAudioEnded(() => { console.log('播放完成(通过回调)'); @@ -158,17 +163,29 @@ isPlaying.value = false; }, 60); }); - // 注册播放错误回调 audioStore.onAudioError((error) => { console.error('播放错误(通过回调):', error); }); + // 声音加载完毕 + audioStore.onAudioLoaded((e) => { + voiceTime.value = (Math.ceil(e.duration) || 1) + 's'; + }); + + watch( + () => props.dataInfo.voicePath, + (newVal) => { + audioStore.setAudioSrc(newVal); + }, + { deep: true, immediate: true } + ); }); onUnload(() => { // 1. 停止当前播放(优先处理,避免音频继续播放) audioStore.stopAudio(); // 2. 移除当前组件注册的回调(避免内存泄漏) audioStore.removeCallbacks(); + unsubscribe(); }); diff --git a/src/components/examination/subject.vue b/src/components/examination/subject.vue index d0ad0a47..a6c3f186 100644 --- a/src/components/examination/subject.vue +++ b/src/components/examination/subject.vue @@ -25,7 +25,7 @@ {{ subject_data.qnsContent }} - + \ No newline at end of file + diff --git a/src/pages/preview/index.vue b/src/pages/preview/index.vue index 0e8e0d65..4d2f6926 100644 --- a/src/pages/preview/index.vue +++ b/src/pages/preview/index.vue @@ -31,8 +31,8 @@