1
1
<template >
2
2
<div class =" text-center mb-20 mt-10" >
3
3
<div class =" text-5xl mb-3 text-fuchsia-500 dark:text-gray-50" >
4
- {{ word }}
4
+ {{ courseStore.currentStatement?.english }}
5
5
<svg
6
6
class =" w-7 h-7 inline-block ml-1 cursor-pointer"
7
7
viewBox =" 0 0 1024 1024"
15
15
></path >
16
16
</svg >
17
17
</div >
18
- <div class =" text-2xl text-slate-600" >{{ soundmark }}</div >
18
+ <div class =" text-2xl text-slate-600" >
19
+ {{ courseStore.currentStatement?.soundmark }}
20
+ </div >
19
21
<button
20
22
class =" border-solid border-2 border-slate-400 bg-slate-100 dark:bg-fuchsia-500 rounded-lg mt-8 mb-11 indent-1 h-10 text-2xl pl-10 pr-10 hover:bg-slate-200"
21
- @click =" handleToNextStatement "
23
+ @click =" goToNextQuestion "
22
24
>
23
25
next
24
26
</button >
@@ -31,53 +33,29 @@ import { registerShortcut, cancelShortcut } from "~/utils/keyboardShortcuts";
31
33
import { useMode } from " ./game" ;
32
34
import { useSummary } from " ./summary" ;
33
35
34
- const { showQuestion } = useMode ();
35
- const { showSummary } = useSummary ();
36
- const { sound } = useCurrentStatementEnglishSound ();
37
- const coursesStore = useCourseStore ();
38
-
39
- const { soundmark, word } = useShowInfo ();
40
- useShortcutToNext ();
41
- autoPlayEnglishSound ();
36
+ const courseStore = useCourseStore ();
37
+ registerShortcutKeyForNextQuestion ();
38
+ const { handlePlaySound } = usePlayEnglishSound ();
42
39
43
- function useShowInfo() {
44
- const soundmark = ref (" " );
45
- const word = ref (" " );
46
-
47
- watchEffect (() => {
48
- soundmark .value = coursesStore .currentStatement ?.soundmark ;
49
- word .value = coursesStore .currentStatement ?.english ;
50
- });
40
+ function usePlayEnglishSound() {
41
+ const { sound } = useCurrentStatementEnglishSound ();
51
42
52
- return {
53
- soundmark ,
54
- word ,
55
- };
56
- }
57
-
58
- function autoPlayEnglishSound() {
59
43
onMounted (() => {
60
44
sound .play ();
61
45
});
62
- }
63
46
64
- function handleToNextStatement() {
65
- if (coursesStore .isAllDone ()) {
66
- showSummary ();
67
- return ;
47
+ function handlePlaySound() {
48
+ sound .play ();
68
49
}
69
50
70
- coursesStore .toNextStatement ();
71
- showQuestion ();
72
- }
73
-
74
- function handlePlaySound() {
75
- sound .play ();
51
+ return {
52
+ handlePlaySound ,
53
+ };
76
54
}
77
55
78
- function useShortcutToNext () {
56
+ function registerShortcutKeyForNextQuestion () {
79
57
function handleKeydown() {
80
- handleToNextStatement ();
58
+ goToNextQuestion ();
81
59
}
82
60
onMounted (() => {
83
61
registerShortcut (" enter" , handleKeydown );
@@ -87,4 +65,18 @@ function useShortcutToNext() {
87
65
cancelShortcut (" enter" , handleKeydown );
88
66
});
89
67
}
90
- </script >~/store/course-new
68
+
69
+ function goToNextQuestion() {
70
+ const { showQuestion } = useMode ();
71
+ const { showSummary } = useSummary ();
72
+
73
+ if (courseStore .isAllDone ()) {
74
+ showSummary ();
75
+ return ;
76
+ }
77
+
78
+ courseStore .toNextStatement ();
79
+ showQuestion ();
80
+ }
81
+ </script >
82
+ ~/store/course-new
0 commit comments