fix: NIT 合并——开场朗读 onEnd 驱动自动进入(防 3s 截断)/continuePlay 空守卫/gotoResult 防双跳/计时器卸载清理

This commit is contained in:
2026-08-13 17:43:35 +08:00
parent d571e8974d
commit 8c19e826b3
3 changed files with 35 additions and 6 deletions
+24 -3
View File
@@ -79,11 +79,32 @@ export default {
},
mounted() {
this.speaking = true
speak(this.content, this.audio)
// v2.1:朗读结束自动进入决策幕(「跳过」仍可手动跳过)
setTimeout(() => { this.speaking = false; this.$emit('done') }, Math.min(3000, this.content.length * 300))
// v2.1:朗读结束自动进入决策幕——最短展示 1.2s,之后 speak onEnd 即进入;
// 无 TTS/onEnd 缺失最迟 15s 兜底(「跳过」仍可手动跳过)
this.speechDone = false
this.ready = false
let done = false
const finishAuto = () => {
if (done) return
done = true
this.speaking = false
this.$emit('done')
}
this.minTimer = setTimeout(() => { this.ready = true; if (this.speechDone) finishAuto() }, 1200)
this.autoTimer = setTimeout(finishAuto, 15000)
const onSpeechEnd = () => {
this.speechDone = true
if (this.ready) finishAuto()
}
if (!this.content) {
finishAuto()
return
}
speak(this.content, this.audio, onSpeechEnd)
},
beforeUnmount() {
clearTimeout(this.minTimer)
clearTimeout(this.autoTimer)
stopSpeak()
},
methods: {
+6 -1
View File
@@ -178,7 +178,8 @@ export default {
branchTimer: null,
replyTimer: null,
playingFinal: false,
finalNode: null
finalNode: null,
doneJumped: false
}
},
onLoad(options) {
@@ -298,6 +299,7 @@ export default {
if (data.final.final_node && parseScript(data.final.final_node.script)) {
this.finalNode = data.final.final_node
this.playingFinal = true
this.doneJumped = false
} else {
playSound('finish')
uni.redirectTo({ url: '/pages/result/result' })
@@ -313,11 +315,14 @@ export default {
if (this.reply && !this.choosing) this.continuePlay()
},
gotoResult() {
if (this.doneJumped) return // 防重复跳转(done 与跳过双触发)
this.doneJumped = true
playSound('finish')
uni.redirectTo({ url: '/pages/result/result' })
},
continuePlay() {
if (this.replyTimer) { clearTimeout(this.replyTimer); this.replyTimer = null }
if (!this.reply && !this.feedback) return // 空守卫:点击与 3s 自动同帧时防 TypeError
if (this.isStoryNode) {
this.curNode = this.reply.next
this.reply = null