Skip to content

Commit

Permalink
fix: dictation mode unable to open the game on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Jul 23, 2024
1 parent a4a5f25 commit 005f334
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions apps/client/components/mode/dictation/DictationMode.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
<template>
<div class="relative flex h-full items-center justify-center">
<div v-if="!isStart">
<p>准备好了吗?(按任意键开启游戏)</p>
<button
class="btn"
v-if="isMobile"
@click="startGame"
>
准备好了吗? 点我开始
</button>
<p v-else>准备好了吗?(按任意键开启游戏)</p>
</div>
<div v-else>
<ModeDictationToolbar />
Expand All @@ -21,27 +28,34 @@ import { onMounted, ref } from "vue";
import { useAnswerTip } from "~/composables/main/answerTip";
import { useGameMode } from "~/composables/main/game";
import { useDevice } from "~/utils/detectDevice";
import { cancelShortcut, registerShortcut } from "~/utils/keyboardShortcuts";
const { isMobile } = useDevice();
const { isAnswer, isQuestion } = useGameMode();
const { isAnswerTip } = useAnswerTip();
const { isStart } = useStartGame();
const { isStart, startGame } = useStartGame();
function useStartGame() {
const isStart = ref(false);
function handleKeyup(e: KeyboardEvent) {
e.preventDefault();
isStart.value = true;
startGame();
cancelShortcut("*", handleKeyup);
}
onMounted(() => {
registerShortcut("*", handleKeyup);
});
function startGame() {
isStart.value = true;
}
return {
isStart,
startGame,
};
}
</script>
Expand Down

0 comments on commit 005f334

Please sign in to comment.