Skip to content

Commit

Permalink
fix: 修复按键失灵的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
simply-none committed Jan 9, 2024
1 parent 63ea2a6 commit ccb5435
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"dev": "vite --force",
"build": "vite build",
"preview": "vite build && vite preview"
},
Expand Down
19 changes: 13 additions & 6 deletions src/views/wordMainPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ import { setNotify } from "../utils/element-plus";
import { isPC } from '../utils/common'
import { useRouter } from "vue-router";
// mounted函数必须在异步调用之前,不然不生效
onMounted(() => {
console.log(new Date())
window.addEventListener("keyup", arrowRightGetData);
});
onUnmounted(() => {
window.removeEventListener("keyup", arrowRightGetData);
});
// 今日学习数据
let useBook = useBookStore();
Expand All @@ -76,6 +86,8 @@ let {
let router = useRouter()
if (router && router.currentRoute.value.query && router.currentRoute.value.query.reload) {
location.href = './'
}
Expand Down Expand Up @@ -107,6 +119,7 @@ function getWordItem(e) {
}
function arrowRightGetData(e) {
console.log(e, 'e')
if (bookItemBeforeSearch.value && ['ArrowRight', 'ArrowLeft'].includes(e.code)) {
setNotify('点击单词还原按钮后,再去切换单词')
return false
Expand All @@ -119,13 +132,7 @@ function arrowRightGetData(e) {
}
}
onMounted(() => {
window.addEventListener("keyup", arrowRightGetData);
});
onUnmounted(() => {
window.removeEventListener("keyup", arrowRightGetData);
});
</script>

<style scoped lang="scss">
Expand Down

0 comments on commit ccb5435

Please sign in to comment.