Skip to content

Commit

Permalink
Fix KeepAlive
Browse files Browse the repository at this point in the history
  • Loading branch information
OuOu2021 committed Nov 14, 2023
1 parent 19a324f commit 01ce42b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
6 changes: 2 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@
<router-view v-slot="{ Component }">
<transition name="globalAnimation" appear mode="out-in">
<keep-alive
:include="['QwertyMode', 'Learn', 'Review']"
:exclude="excludeCache"
>
:include="includeCache">
<component :is="Component" :key="$route.name" />
</keep-alive>
</transition>
Expand All @@ -99,7 +97,7 @@ import { useI18n } from "vue-i18n";
import { useLoginStore } from "./store/loginStore";
import { useOptionsStore } from "./store/optionsStore";
import { Task, useTaskStore } from "./store/taskStore";
import { excludeCache } from "./components/Dicts/common";
import { includeCache } from "./components/Dicts/common";
import router from "./router";
const { t } = useI18n();
Expand Down
4 changes: 2 additions & 2 deletions src/components/Dicts/Dicts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</template>

<script setup lang="ts">
import { DictVo, excludeCache, Lang, sortWithIntersection } from "./common";
import { DictVo, includeCache, Lang, sortWithIntersection } from "./common";
import { Ref, ref, onMounted, computed } from "vue";
import { i18n } from "../../main";
import { useI18n } from "vue-i18n";
Expand Down Expand Up @@ -149,7 +149,7 @@ function startNewTask(dict: DictVo, task: Task): void {
router.push("Login");
return;
}
excludeCache.value = Task[taskStore.type];
includeCache.value = Task[taskStore.type];
const wordsPerRound = ref(0);
switch (task) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dicts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export enum Rating {
Easy,
}

export const excludeCache = ref("");
export const includeCache = ref("");

export function sortWithIntersection(
a: DictVo[],
Expand Down
5 changes: 3 additions & 2 deletions src/components/Learn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { onKeyStroke } from "@vueuse/core";
import { isKatakana, toKana, toRomaji, toHiragana, toKatakana } from "wanakana";
import { Lang, WordVo, excludeCache } from "./Dicts/common";
import { Lang, WordVo, includeCache } from "./Dicts/common";
import { getWordMain } from "./WordCard";
import { Task, useTaskStore } from "../store/taskStore";
import { correctSound, wrongSound, typingSound } from "./SoundEffects";
Expand Down Expand Up @@ -196,7 +196,7 @@ const currWordSound = computed(() => {
});
const initData = async () => {
excludeCache.value = "";
includeCache.value = Task[Task.Learn];
await axios
.get(`/api/dicts/${props.dictId}/learn`, {
Expand Down Expand Up @@ -329,6 +329,7 @@ function inputDone(isCorrect: boolean): void {
}
function goBack(): void {
includeCache.value = "";
taskStore.type = Task.None;
router.push("/dicts");
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/QwertyMode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ import { useOptionsStore } from "../store/optionsStore";
import { Task, useTaskStore } from "../store/taskStore";
import { useI18n } from "vue-i18n";
import { isKatakana, toHiragana, toKatakana } from "wanakana";
import { Lang, WordVo, excludeCache } from "./Dicts/common";
import { Lang, WordVo, includeCache } from "./Dicts/common";
import { correctSound, wrongSound, typingSound } from "./SoundEffects";
import { getWordMain } from "./WordCard";
import { throwError } from "./Error";
Expand Down Expand Up @@ -176,7 +176,7 @@ const currWordSound = computed(() => {
});
const initData = async () => {
excludeCache.value = "";
includeCache.value = Task[Task.QwertyMode];
await axios
.get(`/api/dicts/${props.dictId}/learn`, {
Expand Down Expand Up @@ -292,7 +292,7 @@ function finish(): void {
}
function goBack(): void {
excludeCache.value = Task[taskStore.type];
includeCache.value = "";
taskStore.type = Task.None;
router.push("/dicts");
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/Review.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

<script setup lang="ts">
import { Task, useTaskStore } from "../store/taskStore";
import { Lang, Rating, WordToReviewVo, excludeCache } from "./Dicts/common";
import { Lang, Rating, WordToReviewVo, includeCache } from "./Dicts/common";
import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { onKeyStroke } from "@vueuse/core";
Expand Down Expand Up @@ -187,7 +187,7 @@ const currWordSound = computed(() => {
});
const initData = async () => {
excludeCache.value = "";
includeCache.value = Task[Task.Review];
await axios
.get(`/api/dicts/${props.dictId}/review`, {
Expand Down Expand Up @@ -311,6 +311,7 @@ function inputDone(isCorrect: boolean): void {
}
function goBack(): void {
includeCache.value = "";
taskStore.type = Task.None;
router.push("/dicts");
}
Expand Down

0 comments on commit 01ce42b

Please sign in to comment.