From f72438c9892f444c5728ef71132285051e0d8db6 Mon Sep 17 00:00:00 2001 From: zyronon Date: Fri, 25 Aug 2023 18:07:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 3 - .../{Modal => Toolbar}/DictModal.vue | 45 ++- src/components/Toolbar/Toolbar.vue | 6 +- src/components/Type.vue | 20 +- src/stores/base.ts | 324 +++++++++--------- src/types.ts | 1 - 6 files changed, 208 insertions(+), 191 deletions(-) rename src/components/{Modal => Toolbar}/DictModal.vue (91%) 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() {