Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import applicationApi from '@/api/application'
import { datetimeFormat } from '@/utils/time'
import { MsgError } from '@/utils/message'
import { t } from '@/locales'
import bus from '@/bus'
const route = useRoute()
const {
params: { id }
Expand Down Expand Up @@ -277,6 +278,11 @@ const pausePlayAnswerText = () => {
}

onMounted(() => {
bus.on('pause-autoplay', () => {
pausePlayAnswerText()
// console.log(1234)
})
bus.emit('pause-autoplay')
// 第一次回答后自动播放, 打开历史记录不自动播放
if (props.tts && props.tts_autoplay && buttonData.value.write_ed && !buttonData.value.update_time) {
playAnswerText(buttonData.value.answer_text)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no irregularities in the provided code, but there is one potential issue related to the handling of onMounted:

if (props.tts && props.tts_autoplay && buttonData.value.write_ed && !buttonData.value.update_time) {

This line checks conditions that might lead to unexpected behavior when used with asynchronous functions or if buttonData changes later on. It would be more robust to place this logic inside an effect (watch, computed, etc.) instead.

Additionally, ensure that bus.emit('pause-autoplay') doesn't cause issues with event listeners already attached. If multiple components are listening for the same event, it's important to make sure you're not overwriting existing listeners unintentionally.

Optimization suggestions could include avoiding unnecessary operations within lifecycle hooks like onMounted.

Expand Down