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, });