From ec9c2fec08a125c9c9b93e450912e1238eb92c37 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Wed, 10 May 2023 12:41:31 +0800 Subject: [PATCH] =?UTF-8?q?web:=20=E4=BF=AE=E5=A4=8D=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E9=94=AE=E8=AE=BE=E7=BD=AEbug=E5=92=8Cesc=E9=94=AE=E9=80=BB?= =?UTF-8?q?=E8=BE=91;=20=E4=BF=AE=E5=A4=8D=E8=B6=85=E5=A4=A7=E7=AB=A0?= =?UTF-8?q?=E8=8A=82=E5=88=97=E8=A1=A8=E9=80=A0=E6=88=90=E7=9A=84=E5=8D=A1?= =?UTF-8?q?=E9=A1=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bug: 第一点击目录时没有跳转到合适位置 --- modules/web/src/components.d.ts | 1 + modules/web/src/components/ChapterContent.vue | 3 +- modules/web/src/components/PopCatalog.vue | 105 +++++++----------- modules/web/src/components/ToolBar.vue | 34 ++++-- modules/web/src/views/BookChapter.vue | 5 +- 5 files changed, 64 insertions(+), 84 deletions(-) diff --git a/modules/web/src/components.d.ts b/modules/web/src/components.d.ts index 9a0df73d7..e63bb697a 100644 --- a/modules/web/src/components.d.ts +++ b/modules/web/src/components.d.ts @@ -10,6 +10,7 @@ export {} declare module '@vue/runtime-core' { export interface GlobalComponents { BookItems: typeof import('./components/BookItems.vue')['default'] + CatalogItem: typeof import('./components/CatalogItem.vue')['default'] ChapterContent: typeof import('./components/ChapterContent.vue')['default'] ElButton: typeof import('element-plus/es')['ElButton'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] diff --git a/modules/web/src/components/ChapterContent.vue b/modules/web/src/components/ChapterContent.vue index 04ff1697a..24f68c414 100644 --- a/modules/web/src/components/ChapterContent.vue +++ b/modules/web/src/components/ChapterContent.vue @@ -44,9 +44,8 @@ const calculateWordCount = (paragraph) => { return paragraph.replaceAll(imgPattern, imagePlaceHolder).length; }; const wordCounts = computed(() => { - return Array.from(props.contents, content => calculateWordCount(content)); + return Array.from(props.contents, (content) => calculateWordCount(content)); }); - diff --git a/modules/web/src/components/ToolBar.vue b/modules/web/src/components/ToolBar.vue index 79df8042d..5a742b9b4 100644 --- a/modules/web/src/components/ToolBar.vue +++ b/modules/web/src/components/ToolBar.vue @@ -221,21 +221,31 @@ const recordKeyDowning = ref(false); const recordKeyDownIndex = ref(-1); const stopRecordKeyDown = () => { + if (!recordKeyDowning.value) { + hotkeysDialogVisible.value = false; + } recordKeyDowning.value = false; }; -watch(hotkeysDialogVisible, (visibale) => { - if (!visibale) return hotkeys.unbind("*"); - hotkeys.unbind(); - /**监听按键 */ - hotkeys("*", (event) => { - event.preventDefault(); - if (recordKeyDowning.value && recordKeyDownIndex.value > -1) - buttons.value[recordKeyDownIndex.value].hotKeys = - // @ts-ignore - hotkeys.getPressedKeyString(); - }); -}); +watch( + hotkeysDialogVisible, + (visibale) => { + if (!visibale) return hotkeys.unbind("*"); + hotkeys.unbind(); + /**监听按键 */ + hotkeys("*", (event) => { + event.preventDefault(); + let pressedKeys = hotkeys.getPressedKeyString(); + if (pressedKeys.length == 1 && pressedKeys[0] == "esc") { + //单独按下esc 不录入 + return; + } + if (recordKeyDowning.value && recordKeyDownIndex.value > -1) + buttons.value[recordKeyDownIndex.value].hotKeys = pressedKeys; + }); + }, + { immediate: true } +); const recordKeyDown = (index) => { recordKeyDowning.value = true; diff --git a/modules/web/src/views/BookChapter.vue b/modules/web/src/views/BookChapter.vue index 3018bfb7e..9e3f0f7f3 100644 --- a/modules/web/src/views/BookChapter.vue +++ b/modules/web/src/views/BookChapter.vue @@ -148,7 +148,6 @@ const { config, readingBook, } = storeToRefs(store); - const chapterPos = computed({ get: () => readingBook.value.chapterPos, set: (value) => (readingBook.value.chapterPos = value), @@ -293,9 +292,9 @@ const toChapterPos = (pos) => { let wordCount = 0; if (chapter.value.length != 1) return; for (let element of chapter.value[0].children) { - wordCount += parseInt(element.getAttribute("wordCount")) + 1;//计算换行符 + wordCount += parseInt(element.getAttribute("wordCount")) + 1; //计算换行符 if (wordCount - 1 >= pos) { - //最后一段没有换行符 + //最后一段没有换行符 jump(element, { duration: 0, });