@@ -30,21 +30,20 @@ import { useAnswerTip } from "~/composables/main/answerTip";
30
30
import { useCurrentStatementEnglishSound } from " ~/composables/main/englishSound" ;
31
31
import { useGameMode } from " ~/composables/main/game" ;
32
32
import { useSummary } from " ~/composables/main/summary" ;
33
+ import { useMastered } from " ~/composables/main/useMastered" ;
33
34
import { useShortcutKeyMode } from " ~/composables/user/shortcutKey" ;
34
35
import { isAuthenticated } from " ~/services/auth" ;
35
- import { useCourseStore } from " ~/store/course" ;
36
- import { useMasteredElementsStore } from " ~/store/masteredElements" ;
37
36
import { cancelShortcut , parseShortcutKeys , registerShortcut } from " ~/utils/keyboardShortcuts" ;
38
37
import { useAnswer } from " ./QuestionInput/useAnswer" ;
39
38
import { useWrapperQuestionInput } from " ./QuestionInput/useWrapperQuestionInput" ;
40
39
41
40
const { toggleAnswerTip, isAnswerTip } = useAnswerTip ();
42
41
const { shortcutKeys } = useShortcutKeyMode ();
43
42
const { playSound } = usePlaySound (shortcutKeys .value .sound );
44
- const { handleMastered } = useMastered ();
45
43
const { goToNextQuestion } = useAnswer ();
46
44
const { showQuestion, isQuestion } = useGameMode ();
47
45
const { submitAnswer } = useWrapperQuestionInput ();
46
+ const { handleMastered } = useMasteredShortcut ();
48
47
useShowAnswer (shortcutKeys .value .answer );
49
48
50
49
const keybindings = computed (() => {
@@ -90,7 +89,7 @@ const keybindings = computed(() => {
90
89
},
91
90
{
92
91
keys: shortcutKeys .value .mastered ,
93
- text: " 掌握啦 " ,
92
+ text: " 掌握 " ,
94
93
eventFn: handleMastered ,
95
94
},
96
95
];
@@ -106,45 +105,16 @@ const keybindings = computed(() => {
106
105
return resultItems ;
107
106
});
108
107
109
- function useMastered() {
110
- const { shortcutKeys } = useShortcutKeyMode ();
111
- const courseStore = useCourseStore ();
112
- const masteredElements = useMasteredElementsStore ();
113
- const { showQuestion } = useGameMode ();
114
- const { showSummary } = useSummary ();
108
+ function useMasteredShortcut() {
109
+ const { markStatementAsMastered } = useMastered ();
115
110
116
- const addLoading = ref (false );
117
- async function handleMastered() {
111
+ function handleMastered() {
118
112
if (! isAuthenticated ()) {
119
113
Message .warning (" 需要登录哦" );
120
114
return ;
121
115
}
122
116
123
- // updateMarketedStatements 会影响 isLastStatement 返回的结果
124
- // 所以我们提前调用 isLastStatement 来记录好值
125
- if (addLoading .value ) return ;
126
- const isLastStatement = courseStore .isLastStatement ();
127
- addLoading .value = true ;
128
- await masteredElements .addElement ({
129
- english: courseStore .currentStatement ?.english ! ,
130
- });
131
- addLoading .value = false ;
132
-
133
- courseStore .updateMarketedStatements ();
134
-
135
- if (isLastStatement ) {
136
- showSummary ();
137
- } else {
138
- // 看看消完之后 是否全部都没有了
139
- // 这个是在 updatemarketedStatements 之后
140
- // 处理的 case 比如只剩下2个 good ,那么消除一个 good 之后 那么列表就应该为0了
141
- if (courseStore .isAllMastered ()) {
142
- showSummary ();
143
- return ;
144
- }
145
- courseStore .toNextStatement ();
146
- showQuestion ();
147
- }
117
+ markStatementAsMastered ();
148
118
}
149
119
150
120
onMounted (() => {
0 commit comments