Browse Source

无障碍feat:离开页面后停止朗读 逻辑完善

任一存 3 years ago
parent
commit
c3610347db
1 changed files with 6 additions and 2 deletions
  1. 6 2
      web/src/views/accessibility.vue

+ 6 - 2
web/src/views/accessibility.vue

@@ -756,7 +756,11 @@ export default {
           that.audioPlayer.muted = that.ariaSettings.isMuted
           that.audioPlayer.playbackRate = speechRateFactors[that.ariaSettings.speechRateLevel]
           that.audioPlayer.oncanplaythrough = () => {
-            that.audioPlayer.play()
+            if (document.visibilityState === 'visible') {
+              that.audioPlayer.play()
+            } else {
+              that.$emit('audio-abort', taskId)
+            }
           }
           that.audioPlayer.onended = () => {
             that.$emit('audio-end', taskId)
@@ -956,7 +960,7 @@ export default {
               })
               this.$once('audio-abort', (taskId) => {
                 if (taskId === continueReadTaskId) {
-                  resolve()
+                  reject('audio-abort')
                 }
               })
             })