prevent phones from turning off display when the game's running

This commit is contained in:
2023-06-26 16:03:39 +02:00
parent 5fa8f2cf15
commit acdd8f6964
+10
View File
@@ -80,6 +80,7 @@ export default defineComponent({
name: "GuildView", name: "GuildView",
data: () => ({ data: () => ({
loading: true as boolean, loading: true as boolean,
screenWakeLock: null as null | WakeLockSentinel,
guild: new Guild(1, 500), guild: new Guild(1, 500),
gameTickTask: null as null | number, gameTickTask: null as null | number,
gameSaveTask: null as null | number, gameSaveTask: null as null | number,
@@ -266,6 +267,15 @@ export default defineComponent({
} }
}, },
async mounted() { async mounted() {
setInterval(async () => {
if (this.screenWakeLock) return;
try {
this.screenWakeLock = await navigator.wakeLock.request("screen");
console.debug("Screen wake lock acquired");
} catch (e) {}
}, 1000);
console.debug("Loading game data") console.debug("Loading game data")
const promises = await Promise.all([ const promises = await Promise.all([
loadAvailableQuests(), loadAvailableQuests(),