Skip to content

Commit

Permalink
feat: add go to course list btn on summary
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Jul 22, 2024
1 parent b7cfeea commit 4a558d5
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions apps/client/components/main/Summary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,19 @@
再来一次
</button>

<button
class="btn"
@click="handleGoToCourseList"
>
课程列表
</button>

<button
class="btn"
@click="goToNextCourse"
v-if="haveNextCourse"
>
{{ haveNextCourse || !isAuthenticated() ? "开始下一课" : "返回课程列表" }}
下一课
<kbd class="kbd"> ↵ </kbd>
</button>
</div>
Expand All @@ -82,6 +90,7 @@ import { readOneSentencePerDayAloud } from "~/composables/main/englishSound";
import { useGameMode } from "~/composables/main/game";
import { useShareModal } from "~/composables/main/shareImage/share";
import { useDailySentence, useSummary } from "~/composables/main/summary";
import { useNavigation } from "~/composables/useNavigation";
import { isAuthenticated } from "~/services/auth";
import { useCourseStore } from "~/store/course";
import { useCoursePackStore } from "~/store/coursePack";
Expand All @@ -91,7 +100,8 @@ import { cancelShortcut, registerShortcut } from "~/utils/keyboardShortcuts";
const courseStore = useCourseStore();
const coursePackStore = useCoursePackStore();
const { goToNextCourse, completeCourse, haveNextCourse } = useCourse();
const { gotoCourseList, gotoGame } = useNavigation();
const { handleGoToCourseList, goToNextCourse, completeCourse, haveNextCourse } = useCourse();
const { handleDoAgain } = useDoAgain();
const { showModal, hideSummary } = useSummary();
const { zhSentence, enSentence } = useDailySentence();
Expand Down Expand Up @@ -163,10 +173,15 @@ function useCourse() {
return;
}
if (nextCourseId.value) {
navigateTo(`/game/${courseStore.currentCourse?.coursePackId}/${nextCourseId.value}`);
} else {
navigateTo(`/course-pack/${courseStore.currentCourse?.coursePackId}`);
if (courseStore.currentCourse) {
gotoGame(courseStore.currentCourse.coursePackId, nextCourseId.value);
}
}
function handleGoToCourseList() {
hideSummary();
if (courseStore.currentCourse) {
gotoCourseList(courseStore.currentCourse.coursePackId);
}
}
Expand All @@ -190,6 +205,7 @@ function useCourse() {
completeCourse,
goToNextCourse,
haveNextCourse,
handleGoToCourseList,
};
}
Expand Down

0 comments on commit 4a558d5

Please sign in to comment.