mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2025-03-14 12:10:18 +03:00
fix: allow native context menu in input elements (#428)
This commit is contained in:
parent
8d125db94c
commit
b8ad965763
2 changed files with 16 additions and 1 deletions
|
@ -9,7 +9,7 @@
|
|||
<link rel="icon" href="./favicon.ico?s=1">
|
||||
<title>qBittorrent</title>
|
||||
</head>
|
||||
<body oncontextmenu='return false'>
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
|
|
15
src/App.vue
15
src/App.vue
|
@ -37,6 +37,7 @@ export default {
|
|||
this.$store.commit('SET_APP_VERSION', process.env['APPLICATION_VERSION'])
|
||||
this.$store.commit('SET_LANGUAGE')
|
||||
this.checkAuthentication()
|
||||
this.blockContextMenu()
|
||||
},
|
||||
methods: {
|
||||
async checkAuthentication() {
|
||||
|
@ -50,6 +51,20 @@ export default {
|
|||
|
||||
this.$store.commit('LOGIN', false)
|
||||
if (!this.onLoginPage) return this.$router.push('login')
|
||||
},
|
||||
blockContextMenu() {
|
||||
document.addEventListener('contextmenu', event => {
|
||||
if (!event.target) return
|
||||
const nodeName = event.target.nodeName.toLowerCase()
|
||||
const nodeType = event.target.getAttribute('type')
|
||||
|
||||
if (nodeName === 'textarea') return
|
||||
if (nodeName === 'input' && ['text', 'password', 'email', 'number'].includes(nodeType)) return
|
||||
|
||||
event.preventDefault()
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue