chore(js): avoid lots of Wake Lock is not supported.

This commit is contained in:
bluelovers 2024-10-25 09:59:45 +08:00 committed by GitHub
parent 984b952eb3
commit ee0ad5cceb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,11 +79,12 @@ function requestProgress(id_task, progressbarContainer, gallery, atEnd, onProgre
var wakeLock = null;
var requestWakeLock = async function() {
if (!opts.prevent_screen_sleep_during_generation || wakeLock) return;
if (!opts.prevent_screen_sleep_during_generation || wakeLock !== null) return;
try {
wakeLock = await navigator.wakeLock.request('screen');
} catch (err) {
console.error('Wake Lock is not supported.');
wakeLock = false;
}
};