diff --git a/src/App.vue b/src/App.vue index 4e81d08b..433f4655 100644 --- a/src/App.vue +++ b/src/App.vue @@ -15,6 +15,7 @@ import {isMobile, shakeCommonDict} from "@/utils"; import router, {routes} from "@/router.ts"; import {useRoute} from "vue-router"; + const store = useBaseStore() const runtimeStore = useRuntimeStore() const settingStore = useSettingStore() @@ -28,35 +29,6 @@ watch(settingStore.$state, (n) => { localStorage.setItem(SAVE_SETTING_KEY.key, JSON.stringify({val: n, version: SAVE_SETTING_KEY.version})) }) -//检测几个特定词典 -watch(store.collect.originWords, (n) => { - if (n.length === 0) { - store.collect.words = [] - store.collect.chapterWords = [] - } else { - store.collect.words = cloneDeep(n) - store.collect.chapterWords = [store.collect.words] - } -}) -watch(store.simple.originWords, (n) => { - if (n.length === 0) { - store.simple.words = [] - store.simple.chapterWords = [] - } else { - store.simple.words = cloneDeep(n) - store.simple.chapterWords = [store.simple.words] - } -}) -watch(store.wrong.originWords, (n) => { - if (n.length === 0) { - store.wrong.words = [] - store.wrong.chapterWords = [] - } else { - store.wrong.words = cloneDeep(n) - store.wrong.chapterWords = [store.wrong.words] - } -}) - async function init() { // console.time() store.init().then(() => { diff --git a/src/hooks/dict.ts b/src/hooks/dict.ts index c0fd46d8..b95c5412 100644 --- a/src/hooks/dict.ts +++ b/src/hooks/dict.ts @@ -1,9 +1,7 @@ -import {Article, Dict, DictType, Word} from "@/types.ts"; +import {Article, Dict, Word} from "@/types.ts"; import {useBaseStore} from "@/stores/base.ts"; -import {useRuntimeStore} from "@/stores/runtime.ts"; -import {chunk, cloneDeep, shuffle} from "lodash-es"; +import {cloneDeep, shuffle} from "lodash-es"; import {isArticle} from "@/hooks/article.ts"; -import {nanoid} from "nanoid"; export function useWordOptions() { diff --git a/src/pages/pc/components/Panel.vue b/src/pages/pc/components/Panel.vue index 6208902a..6557faa5 100644 --- a/src/pages/pc/components/Panel.vue +++ b/src/pages/pc/components/Panel.vue @@ -20,8 +20,14 @@ import {cloneDeep} from "lodash-es"; import WordList from "@/pages/pc/components/list/WordList.vue"; import ArticleList from "@/pages/pc/components/list/ArticleList.vue"; import Slide from "@/pages/pc/components/Slide.vue"; +import {useNav} from "@/utils"; + +const props = withDefaults(defineProps<{ + type: DictType +}>(), { + type: DictType.word +}) -const router = useRouter() const store = useBaseStore() const runtimeStore = useRuntimeStore() const settingStore = useSettingStore() @@ -60,33 +66,21 @@ const { toggleArticleCollect } = useArticleOptions() -function addCollect() { - runtimeStore.editDict = cloneDeep(store.collect) - router.push({path: '/dict', query: {type: 'addWordOrArticle'}}) -} - -function addSimple() { - runtimeStore.editDict = cloneDeep(store.simple) - router.push({path: '/dict', query: {type: 'addWordOrArticle'}}) -} +const {nav} = useNav() const showCollectToggleButton = $computed(() => { - if (store.currentDict.type === DictType.collect) { - if (store.current.practiceType !== practiceType) { - return (practiceType === DictType.word && store.collect.words.length) || - (practiceType === DictType.article && store.collect.articles.length) - } - } else { - return (practiceType === DictType.word && store.collect.words.length) || - (practiceType === DictType.article && store.collect.articles.length) - } - return false + if (props.type === DictType.word) return !store.collectWord.length + return !store.collectArticle.length }) +function changeCollect(){ + +} +