Skip to content
Snippets Groups Projects
Unverified Commit d5deef56 authored by zyoshoka's avatar zyoshoka Committed by GitHub
Browse files

fix(frontend): WebKitブラウザー上でも「デバイスの画面を常にオンにする」機能が効くように (#12484)

* fix(frontend): WebKitブラウザー上でもkeepScreenOnが効くように

* chore: add comment
parent 4e882414
No related branches found
No related tags found
Loading
......@@ -202,20 +202,24 @@ export async function common(createVue: () => App<Element>) {
}
}, { immediate: true });
if (defaultStore.state.keepScreenOn) {
if ('wakeLock' in navigator) {
navigator.wakeLock.request('screen')
.then(() => {
document.addEventListener('visibilitychange', async () => {
if (document.visibilityState === 'visible') {
navigator.wakeLock.request('screen');
}
});
})
// Keep screen on
const onVisibilityChange = () => document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
navigator.wakeLock.request('screen');
}
});
if (defaultStore.state.keepScreenOn && 'wakeLock' in navigator) {
navigator.wakeLock.request('screen')
.then(onVisibilityChange)
.catch(() => {
// If Permission fails on an AppleDevice such as Safari
// On WebKit-based browsers, user activation is required to send wake lock request
// https://webkit.org/blog/13862/the-user-activation-api/
document.addEventListener(
'click',
() => navigator.wakeLock.request('screen').then(onVisibilityChange),
{ once: true },
);
});
}
}
//#region Fetch user
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment