|
@@ -476,11 +476,12 @@ export default {
|
|
|
viewportAreaNum: null,
|
|
|
interactionAreaNum: null,
|
|
|
|
|
|
- // 为了避免朗读竞争
|
|
|
+ // 为了避免多余的朗读行为
|
|
|
isJustMouseDown: false,
|
|
|
domChangeLastTime: null,
|
|
|
mutationObserver: null,
|
|
|
requestReadLastTime: null,
|
|
|
+ isJustWindowFocus: false,
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -623,6 +624,9 @@ export default {
|
|
|
window.addEventListener('storage', this.loadStoredSettings, {
|
|
|
passive: true,
|
|
|
})
|
|
|
+ window.addEventListener('focus', this.onWindowFocus, {
|
|
|
+ passive: true,
|
|
|
+ })
|
|
|
document.addEventListener('keydown', this.keyEventHandler, {
|
|
|
passive: true,
|
|
|
})
|
|
@@ -693,6 +697,9 @@ export default {
|
|
|
window.removeEventListener('storage', this.loadStoredSettings, {
|
|
|
passive: true,
|
|
|
}),
|
|
|
+ window.removeEventListener('focus', this.onWindowFocus, {
|
|
|
+ passive: true,
|
|
|
+ }),
|
|
|
document.removeEventListener('keydown', this.keyEventHandler, {
|
|
|
passive: true,
|
|
|
})
|
|
@@ -720,6 +727,12 @@ export default {
|
|
|
this.mutationObserver.disconnect();
|
|
|
},
|
|
|
methods: {
|
|
|
+ onWindowFocus() {
|
|
|
+ this.isJustWindowFocus = true
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isJustWindowFocus = false
|
|
|
+ }, 0);
|
|
|
+ },
|
|
|
onPageVisibilityChange() {
|
|
|
if (document.visibilityState === 'hidden') {
|
|
|
if (this.audioPlayer && !this.audioPlayer.ended) {
|
|
@@ -958,6 +971,11 @@ export default {
|
|
|
if (!this.ariaSettings.isCompActive) {
|
|
|
return
|
|
|
}
|
|
|
+ // 如果刚刚切换到此浏览器此页面,虽然会导致上次离开前focus到的元素的再次focus,但不能重复朗读。
|
|
|
+ if (this.isJustWindowFocus) {
|
|
|
+ console.log('刚刚切换到此浏览器此页面,导致上次离开前focus到的元素的再次focus,忽略之。')
|
|
|
+ return
|
|
|
+ }
|
|
|
// 如果是点击鼠标引起的focus
|
|
|
if (this.isJustMouseDown) {
|
|
|
if (
|