feat: 内容页左右箭头键盘监听

This commit is contained in:
xiongxiaoyang 2022-05-16 14:45:56 +08:00
parent 364c4fd489
commit f8fe50654c

View File

@ -13,7 +13,8 @@
<ul>
<li>
<a
class="ico_catalog" @click="chapterList(data.chapterInfo.bookId)"
class="ico_catalog"
@click="chapterList(data.chapterInfo.bookId)"
href="javascript:void(0)"
title="目录"
>
@ -298,7 +299,8 @@ export default {
imgBaseUrl: process.env.VUE_APP_BASE_IMG_URL,
});
onMounted(() => {
init(route.params.chapterId);
init(route.params.chapterId)
keyDown()
});
const bookDetail = (bookId) => {
@ -335,6 +337,25 @@ export default {
state.data = data;
};
//
const keyDown = () => {
document.onkeydown = (e) => {
//
let e1 = e || event || window.event || arguments.callee.caller.arguments[0]
//:-37;-38-39;-40
const bookId = state.data.chapterInfo.bookId;
//
if (e1 && e1.keyCode == 37) {
//
preChapter(bookId);
} else if (e1 && e1.keyCode == 39) {
//
nextChapter(bookId)
}
}
}
return {
...toRefs(state),
bookDetail,