fix: wake lock error in safari etc (#12464)
This commit is contained in:
parent
d60f645d1d
commit
780b120c64
|
@ -204,13 +204,17 @@ export async function common(createVue: () => App<Element>) {
|
||||||
|
|
||||||
if (defaultStore.state.keepScreenOn) {
|
if (defaultStore.state.keepScreenOn) {
|
||||||
if ('wakeLock' in navigator) {
|
if ('wakeLock' in navigator) {
|
||||||
navigator.wakeLock.request('screen');
|
navigator.wakeLock.request('screen')
|
||||||
|
.then(() => {
|
||||||
document.addEventListener('visibilitychange', async () => {
|
document.addEventListener('visibilitychange', async () => {
|
||||||
if (document.visibilityState === 'visible') {
|
if (document.visibilityState === 'visible') {
|
||||||
navigator.wakeLock.request('screen');
|
navigator.wakeLock.request('screen');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
// If Permission fails on an AppleDevice such as Safari
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue