diff --git a/apps/client/components/main/Contents/Contents.vue b/apps/client/components/main/Contents/Contents.vue deleted file mode 100644 index a22233bd0..000000000 --- a/apps/client/components/main/Contents/Contents.vue +++ /dev/null @@ -1,106 +0,0 @@ - - - - - diff --git a/apps/client/components/main/Contents/useContents.ts b/apps/client/components/main/Contents/useContents.ts deleted file mode 100644 index ca92a587f..000000000 --- a/apps/client/components/main/Contents/useContents.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { onClickOutside } from "@vueuse/core"; -import { ref } from "vue"; - -const contentsVisible = ref(false); -let isOnClickOutside = false; - -export function useContent() { - function isShowContents() { - return contentsVisible.value === true; - } - - function toggleContents(e: MouseEvent) { - if (!isOnClickOutside) { - contentsVisible.value = !contentsVisible.value; - } - } - - function hideContents() { - contentsVisible.value = false; - } - - function watchClickOutside(contentsEl: HTMLElement) { - onClickOutside(contentsEl, () => { - if (contentsVisible.value) { - isOnClickOutside = true; - contentsVisible.value = false; - // 隐藏时防止和 toggleContents 冲突 - setTimeout(() => { - isOnClickOutside = false; - }); - } - }); - } - - return { - isShowContents, - toggleContents, - hideContents, - watchClickOutside, - }; -} diff --git a/apps/client/components/main/CourseContents.vue b/apps/client/components/main/CourseContents.vue new file mode 100644 index 000000000..6c7942852 --- /dev/null +++ b/apps/client/components/main/CourseContents.vue @@ -0,0 +1,147 @@ + + + + + diff --git a/apps/client/components/main/Tool.vue b/apps/client/components/main/Tool.vue index 89f1fc985..6de824553 100644 --- a/apps/client/components/main/Tool.vue +++ b/apps/client/components/main/Tool.vue @@ -14,7 +14,7 @@
{{ currentCourseInfo }} @@ -58,7 +58,7 @@
- + import { useModal } from "#imports"; -import { computed } from "vue"; +import { computed, ref } from "vue"; import Dialog from "~/components/common/Dialog.vue"; import { useQuestionInput } from "~/components/main/QuestionInput/questionInputHelper"; import { courseTimer } from "~/composables/courses/courseTimer"; import { useGameMode } from "~/composables/main/game"; import { clearQuestionInput } from "~/composables/main/question"; +import { useCourseContents } from "~/composables/main/useCourseContents"; import { useGamePause } from "~/composables/main/useGamePause"; import { useRanking } from "~/composables/rank/rankingList"; import { parseShortcut, useShortcutKeyMode } from "~/composables/user/shortcutKey"; import { isAuthenticated } from "~/services/auth"; import { useCourseStore } from "~/store/course"; -import { useContent } from "./Contents/useContents"; const { shortcutKeys } = useShortcutKeyMode(); const rankingStore = useRanking(); const courseStore = useCourseStore(); const { focusInput } = useQuestionInput(); -const { toggleContents } = useContent(); +const { openCourseContents } = useCourseContents(); const { handleDoAgain } = useDoAgain(); const { pauseGame } = useGamePause(); const modal = useModal(); @@ -110,6 +110,8 @@ const currentPercentage = computed(() => { ); }); +const isOpenCourseContents = ref(false); + function useDoAgain() { const { showQuestion } = useGameMode(); diff --git a/apps/client/composables/main/englishSound/index.ts b/apps/client/composables/main/englishSound/index.ts index e9f0570a0..ad6e67eda 100644 --- a/apps/client/composables/main/englishSound/index.ts +++ b/apps/client/composables/main/englishSound/index.ts @@ -33,3 +33,9 @@ export function readOneSentencePerDayAloud(str: string) { updateSource(pronunciationUrl); play(); } + +export function playEnglish(english: string) { + const pronunciationUrl = getPronunciationUrl(english); + updateSource(pronunciationUrl); + play(); +} diff --git a/apps/client/composables/main/useCourseContents.ts b/apps/client/composables/main/useCourseContents.ts new file mode 100644 index 000000000..fef0c19dc --- /dev/null +++ b/apps/client/composables/main/useCourseContents.ts @@ -0,0 +1,19 @@ +import { ref } from "vue"; + +const contentsVisible = ref(false); + +export function useCourseContents() { + function openCourseContents() { + contentsVisible.value = true; + } + + function hideCourseContents() { + contentsVisible.value = false; + } + + return { + contentsVisible, + openCourseContents, + hideCourseContents, + }; +}