mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-09 20:27:30 +08:00
添加快捷键
+ 不是手机的情况下不启用快捷键
This commit is contained in:
@@ -59,6 +59,7 @@ export default {
|
|||||||
},
|
},
|
||||||
components: { LoginOverlay },
|
components: { LoginOverlay },
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
|
const isMobile = useIsMobile()
|
||||||
const vditorInstance = ref(null)
|
const vditorInstance = ref(null)
|
||||||
const text = ref('')
|
const text = ref('')
|
||||||
const editorId = ref(props.editorId)
|
const editorId = ref(props.editorId)
|
||||||
@@ -112,23 +113,27 @@ export default {
|
|||||||
applyTheme()
|
applyTheme()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
// 不是手机的情况下不添加快捷键
|
||||||
|
if(!isMobile.value){
|
||||||
|
// 添加快捷键监听 (Ctrl+Enter 或 Cmd+Enter)
|
||||||
|
const handleKeydown = (e) => {
|
||||||
|
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
|
||||||
|
e.preventDefault()
|
||||||
|
submit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 添加快捷键监听 (Ctrl+Enter 或 Cmd+Enter)
|
const el = document.getElementById(editorId.value)
|
||||||
const handleKeydown = (e) => {
|
|
||||||
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
|
|
||||||
e.preventDefault()
|
|
||||||
submit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const el = document.getElementById(editorId.value)
|
|
||||||
if (el) {
|
|
||||||
el.addEventListener('keydown', handleKeydown)
|
|
||||||
}
|
|
||||||
onUnmounted(() => {
|
|
||||||
if (el) {
|
if (el) {
|
||||||
el.removeEventListener('keydown', handleKeydown)
|
el.addEventListener('keydown', handleKeydown)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (el) {
|
||||||
|
el.removeEventListener('keydown', handleKeydown)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user