diff --git a/components.d.ts b/components.d.ts index 70b389c6..c1a92da6 100644 --- a/components.d.ts +++ b/components.d.ts @@ -9,12 +9,10 @@ declare module 'vue' { export interface GlobalComponents { Add: typeof import('./src/components/Toolbar/Add.vue')['default'] AddDict: typeof import('./src/components/Add/AddDict.vue')['default'] - AddWordDialog: typeof import('./src/components/Modal/AddWordDialog.vue')['default'] ArticleList: typeof import('./src/components/Article/ArticleList.vue')['default'] Backgorund: typeof import('./src/components/Backgorund.vue')['default'] BaseButton: typeof import('./src/components/BaseButton.vue')['default'] BaseIcon: typeof import('./src/components/BaseIcon.vue')['default'] - ChapterDetail: typeof import('./src/components/ChapterDetail.vue')['default'] ChapterList: typeof import('./src/components/list/ChapterList.vue')['default'] ChapterName: typeof import('./src/components/Toolbar/ChapterName.vue')['default'] Close: typeof import('./src/components/icon/Close.vue')['default'] @@ -23,7 +21,6 @@ declare module 'vue' { DictGroup: typeof import('./src/components/Toolbar/DictGroup.vue')['default'] DictItem: typeof import('./src/components/list/DictItem.vue')['default'] DictList: typeof import('./src/components/list/DictList.vue')['default'] - DictModal: typeof import('./src/components/Modal/DictModal.vue')['default'] DictModal2: typeof import('./src/components/Modal/DictModal2.vue')['default'] EditAbleText: typeof import('./src/components/EditAbleText.vue')['default'] EditArticle: typeof import('./src/components/Article/EditArticle.vue')['default'] diff --git a/src/App.vue b/src/App.vue index c90f6951..6caf0449 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,6 +10,7 @@ import {cloneDeep} from "lodash-es"; import Backgorund from "@/components/Backgorund.vue"; import useTheme from "@/hooks/useTheme.ts"; import * as localforage from "localforage"; +import {useStartKeyboardEventListener} from "@/hooks/event.ts"; const store = useBaseStore() const runtimeStore = useRuntimeStore() @@ -33,6 +34,7 @@ watch(settingStore.$state, (n) => { //检测几个特定词典 watch(store.collect.originWords, (n) => { + console.log('watch(store.collect.originWords', n) store.collect.words = cloneDeep(n) store.collect.chapterWords = [store.collect.words] }) @@ -59,7 +61,7 @@ onMounted(() => { init() }) -// useStartKeyboardEventListener() +useStartKeyboardEventListener() diff --git a/src/components/ChapterDetail.vue b/src/components/ChapterDetail.vue deleted file mode 100644 index c25e2d5a..00000000 --- a/src/components/ChapterDetail.vue +++ /dev/null @@ -1,40 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/components/Modal/DictDialog/index.vue b/src/components/Modal/DictDialog/index.vue index a261263a..6d481b8c 100644 --- a/src/components/Modal/DictDialog/index.vue +++ b/src/components/Modal/DictDialog/index.vue @@ -36,12 +36,13 @@ let wordList = $ref([]) let step = $ref(1) let loading = $ref(false) +let show = $ref(false) -watch(() => runtimeStore.showDictModal, (n: boolean) => { - runtimeStore.editDict = cloneDeep(store.currentDict) -}) +function close() { + show = false +} -async function selectDict(val: { dict: DictResource, index: number }) { +async function selectDict(val: { dict: DictResource | Dict, index: number }) { let item = val.dict console.log('item', item) step = 1 @@ -49,7 +50,7 @@ async function selectDict(val: { dict: DictResource, index: number }) { detailListTabIndex = 0 wordFormMode = FormMode.None loading = true - let find: Dict = store.myDictList.find((v: Dict) => v.name === item.name) + let find: Dict = store.myDictList.find((v: Dict) => v.id === item.id) if (find) { runtimeStore.editDict = cloneDeep(find) } else { @@ -90,8 +91,6 @@ async function selectDict(val: { dict: DictResource, index: number }) { })) } } - - } loading = false } @@ -101,9 +100,6 @@ function changeDict() { close() } -function close() { - runtimeStore.showDictModal = false -} function groupByDictTags(dictList: DictResource[]) { return dictList.reduce>((result, dict) => { @@ -218,26 +214,6 @@ const dictRules = reactive({ watch(() => dictForm.language, () => isAddDict && (dictForm.category = '')) watch(() => dictForm.category, () => isAddDict && (dictForm.tags = [])) -onMounted(() => { - dictionaryResources.map(v => { - if (categoryList[v.language]) { - if (!categoryList[v.language].find(w => w === v.category)) { - categoryList[v.language].push(v.category) - } - } else { - categoryList[v.language] = [v.category] - } - if (tagList[v.category]) { - tagList[v.category] = Array.from(new Set(tagList[v.category].concat(v.tags))) - } else { - tagList[v.category] = v.tags - } - }) - - // console.log('categoryList', categoryList) - // console.log('tagList', tagList) -}) - function editDict() { // dictForm.id = store.editDict.id // dictForm.name = store.editDict.name @@ -292,6 +268,10 @@ async function onSubmit() { }) } +/**/ +/*词典相关*/ +/**/ + /**/ /* 单词修改相关*/ @@ -440,6 +420,10 @@ function addWord() { wordForm = cloneDeep(DefaultFormWord) } +/**/ +/* 单词修改相关*/ +/**/ + watch(() => step, v => { if (v === 0) { closeWordForm() @@ -447,12 +431,58 @@ watch(() => step, v => { } }) + +onMounted(() => { + dictionaryResources.map(v => { + if (categoryList[v.language]) { + if (!categoryList[v.language].find(w => w === v.category)) { + categoryList[v.language].push(v.category) + } + } else { + categoryList[v.language] = [v.category] + } + if (tagList[v.category]) { + tagList[v.category] = Array.from(new Set(tagList[v.category].concat(v.tags))) + } else { + tagList[v.category] = v.tags + } + }) + + emitter.on(EventKey.openDictModal, (type: 'detail' | 'list' | 'my' | 'collect' | 'simple') => { + if (type === "detail") { + selectDict({dict: store.currentDict, index: 0}) + } + if (type === "list") { + currentLanguage = 'en' + step = 0 + } + if (type === "my") { + currentLanguage = 'my' + step = 0 + } + if (type === "collect") { + selectDict({dict: store.collect, index: 0}) + wordFormMode = FormMode.Add + addWord() + } + if (type === "simple") { + selectDict({dict: store.simple, index: 0}) + addWord() + } + + show = true + }) + + // console.log('categoryList', categoryList) + // console.log('tagList', tagList) +}) +