Skip to content

Commit

Permalink
游戏时阻止熄屏
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-soragoto committed Oct 29, 2024
1 parent 58fd416 commit a5ed9eb
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/views/game/GameView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@

<t-dialog v-model:visible="finalState.on" title="终局结果" confirm-btn="确定" @confirm="onFinalConfirm">
<p v-for="(playerName, index) of finalState.result" :key="index" class="text" style="margin-bottom: 2dvmin">
<strong>{{ playerName }} : {{ gameStore.getPlayer(playerName).point }}</strong></p>
<strong>{{ playerName }} : {{ gameStore.getPlayer(playerName).point }}</strong>
</p>
</t-dialog>

<t-dialog v-model:visible="leave.showAlert" close-on-overlay-click content="现在退出不保存任何数据,确定吗?" cancel-btn="取消"
Expand All @@ -177,6 +178,34 @@ import { onBeforeRouteLeave, type RouteLocationNormalized } from 'vue-router';
import { Toast } from 'tdesign-mobile-vue';
import type { Player } from '@/ts/common';
let wakeLock = null;

Check failure on line 181 in src/views/game/GameView.vue

View workflow job for this annotation

GitHub Actions / build-pages

Variable 'wakeLock' implicitly has type 'any' in some locations where its type cannot be determined.
const setWakeLock = function () {
if (wakeLock) {

Check failure on line 184 in src/views/game/GameView.vue

View workflow job for this annotation

GitHub Actions / build-pages

Variable 'wakeLock' implicitly has an 'any' type.
return;
}
navigator.wakeLock.request('screen').then(result => {
wakeLock = result;
wakeLock.addEventListener('release', () => {
wakeLock = null;
});
})
};
onMounted(() => {
setWakeLock()
window.addEventListener('focus', focus);
})
onUnmounted(() => {
window.removeEventListener('focus', focus);
})
function focus() {
setWakeLock()
}
const gameStore = useGameStore()
// 局内逻辑
Expand Down

0 comments on commit a5ed9eb

Please sign in to comment.