feat: 支持通过Alt+数字键Ctrl+数字键快捷复制粘贴前9条记录

This commit is contained in:
ZiuChen 2022-08-26 22:03:09 +08:00
parent 7a41dcc0ed
commit ed8185052c
2 changed files with 5 additions and 6 deletions

View File

@ -94,7 +94,7 @@ onMounted(() => {
const isArrowDown = key === 'ArrowDown' const isArrowDown = key === 'ArrowDown'
const isEnter = key === 'Enter' const isEnter = key === 'Enter'
const isCopy = (ctrlKey || metaKey) && (key === 'C' || key === 'c') const isCopy = (ctrlKey || metaKey) && (key === 'C' || key === 'c')
const isNumber = key === '1' || '2' || '3' || '4' || '5' || '6' || '7' || '8' || '9' const isNumber = parseInt(key) <= 9 && parseInt(key) >= 0
if (isArrowUp) { if (isArrowUp) {
if (activeIndex.value > 0) { if (activeIndex.value > 0) {
activeIndex.value-- activeIndex.value--
@ -117,13 +117,14 @@ onMounted(() => {
} }
} else if (isCopy) { } else if (isCopy) {
if (props.fullData.data === '') { if (props.fullData.data === '') {
//
window.copy(props.showList[activeIndex.value]) window.copy(props.showList[activeIndex.value])
} }
} else if (isEnter) { } else if (isEnter) {
window.copy(props.showList[activeIndex.value]) window.copy(props.showList[activeIndex.value])
window.paste() window.paste()
} else if (altKey && isNumber) { } else if ((ctrlKey || metaKey || altKey) && isNumber) {
window.copy(props.showList[parseInt(key)]) window.copy(props.showList[parseInt(key) - 1])
window.paste() window.paste()
} }
}) })

View File

@ -126,9 +126,7 @@ onMounted(() => {
const { key, ctrlKey, metaKey } = e const { key, ctrlKey, metaKey } = e
const isTab = key === 'Tab' const isTab = key === 'Tab'
const isSearch = const isSearch =
key === '/' || (ctrlKey && (key === 'F' || key === 'f')) || (ctrlKey && (key === 'L' || key === 'l'))
(ctrlKey && (key === 'F' || key === 'f')) ||
(ctrlKey && (key === 'L' || key === 'l'))
const isExit = key === 'Escape' const isExit = key === 'Escape'
if (isTab) { if (isTab) {
const list = ['all', 'text', 'image', 'file'] const list = ['all', 'text', 'image', 'file']