From 8349fda25080b047cb743c70a4b4458f2f11dbd2 Mon Sep 17 00:00:00 2001 From: StanHustler Date: Sat, 23 Sep 2023 20:28:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dweb=E9=98=85=E8=AF=BB?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=B9=E5=90=91=E9=94=AE=E4=BA=8C=E6=AE=B5?= =?UTF-8?q?=E8=B7=B3=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/web/.eslintrc-auto-import.json | 3 ++- modules/web/src/auto-imports.d.ts | 3 ++- modules/web/src/components.d.ts | 4 +--- modules/web/src/views/BookChapter.vue | 11 +++++++++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/modules/web/.eslintrc-auto-import.json b/modules/web/.eslintrc-auto-import.json index 58475c155..051d6ac72 100644 --- a/modules/web/.eslintrc-auto-import.json +++ b/modules/web/.eslintrc-auto-import.json @@ -79,6 +79,7 @@ "watchEffect": true, "watchPostEffect": true, "watchSyncEffect": true, - "toValue": true + "toValue": true, + "WritableComputedRef": true } } diff --git a/modules/web/src/auto-imports.d.ts b/modules/web/src/auto-imports.d.ts index 5a17c2776..964ac4fd0 100644 --- a/modules/web/src/auto-imports.d.ts +++ b/modules/web/src/auto-imports.d.ts @@ -1,6 +1,7 @@ /* eslint-disable */ /* prettier-ignore */ // @ts-nocheck +// noinspection JSUnusedGlobalSymbols // Generated by unplugin-auto-import export {} declare global { @@ -81,5 +82,5 @@ declare global { // for type re-export declare global { // @ts-ignore - export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode } from 'vue' + export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue' } diff --git a/modules/web/src/components.d.ts b/modules/web/src/components.d.ts index e63bb697a..56374a699 100644 --- a/modules/web/src/components.d.ts +++ b/modules/web/src/components.d.ts @@ -3,11 +3,9 @@ // @ts-nocheck // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 -import '@vue/runtime-core' - export {} -declare module '@vue/runtime-core' { +declare module 'vue' { export interface GlobalComponents { BookItems: typeof import('./components/BookItems.vue')['default'] CatalogItem: typeof import('./components/CatalogItem.vue')['default'] diff --git a/modules/web/src/views/BookChapter.vue b/modules/web/src/views/BookChapter.vue index 4a74ce372..9ebf4feec 100644 --- a/modules/web/src/views/BookChapter.vue +++ b/modules/web/src/views/BookChapter.vue @@ -446,6 +446,15 @@ const handleKeyPress = (event) => { break; } }; + +// 阻止默认滚动事件 +const ignoreKeyPress = (event) => { + if (event.key === "ArrowUp" || event.key === "ArrowDown") { + event.preventDefault(); + event.stopPropagation(); + } +}; + onMounted(() => { //获取书籍数据 let bookUrl = sessionStorage.getItem("bookUrl"); @@ -484,6 +493,7 @@ onMounted(() => { getContent(chapterIndex, true, chapterPos); window.addEventListener("keyup", handleKeyPress); + window.addEventListener("keydown", ignoreKeyPress); // 兼容Safari < 14 document.addEventListener("visibilitychange", onVisibilityChange); //监听底部加载 @@ -505,6 +515,7 @@ onMounted(() => { onUnmounted(() => { window.removeEventListener("keyup", handleKeyPress); + window.removeEventListener("keydown", ignoreKeyPress); window.removeEventListener("resize", onResize); // 兼容Safari < 14 document.removeEventListener("visibilitychange", onVisibilityChange);