diff --git a/src/App.vue b/src/App.vue index cb00e40b..16c24f23 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,7 +4,6 @@ import Toolbar from "@/components/Toolbar/Toolbar.vue"; import Type from "@/components/Type.vue"; import Side from "@/components/Side.vue"; import Statistics from "@/components/Modal/Statistics.vue"; -import DictModal from "@/components/Modal/DictModal.vue"; @@ -19,7 +18,6 @@ import DictModal from "@/components/Modal/DictModal.vue"; - @@ -56,5 +54,4 @@ import DictModal from "@/components/Modal/DictModal.vue"; } } } - diff --git a/src/components/Modal/DictModal.vue b/src/components/Toolbar/DictModal.vue similarity index 91% rename from src/components/Modal/DictModal.vue rename to src/components/Toolbar/DictModal.vue index 1af42afa..f93face4 100644 --- a/src/components/Modal/DictModal.vue +++ b/src/components/Toolbar/DictModal.vue @@ -12,26 +12,35 @@ import Modal from "@/components/Modal/Modal.vue"; import BaseButton from "@/components/BaseButton.vue"; const store = useBaseStore() -let currentSelectDict: Dict = $ref({ - name: '新概念英语-2', - chapterList: [], - chapterIndex: -1, -} as any) + +interface IProps { + modelValue: boolean, +} + +const props = withDefaults(defineProps(), { + modelValue: true, +}) + +const emit = defineEmits([ + 'update:modelValue', +]) + +let currentSelectDict: Dict = $ref(store.currentDict) let step = $ref(0) const currentSelectChapter: Word[] = $computed(() => { return currentSelectDict.chapterList?.[currentSelectDict.chapterIndex] ?? [] }) -watch(store.currentDict, (n: Dict) => { - currentSelectDict = n +watch(() => props.modelValue, (n: Dict) => { + currentSelectDict = store.currentDict }) async function selectDict(item: Dict) { currentSelectDict = { + ...item, type: DictType.inner, sort: Sort.normal, - ...item, wordList: [], chapterList: [], chapterIndex: 0, @@ -48,6 +57,12 @@ async function selectDict(item: Dict) { function changeDict() { store.changeDict(currentSelectDict) + this.close() +} + +function close() { + console.log('close') + emit('update:modelValue', false) } function resetChapterList() { @@ -56,10 +71,11 @@ function resetChapterList() {