Merge branch 'v1.4.4'

This commit is contained in:
ZiuChen
2022-10-10 18:19:01 +08:00
4 changed files with 118 additions and 94 deletions

View File

@@ -1,5 +1,5 @@
{ {
"version": "1.4.3", "version": "1.4.4",
"pluginName": "超级剪贴板", "pluginName": "超级剪贴板",
"description": "强大的剪贴板管理工具", "description": "强大的剪贴板管理工具",
"author": "ZiuChen", "author": "ZiuChen",

View File

@@ -30,7 +30,7 @@
<script setup> <script setup>
import FileList from './FileList.vue' import FileList from './FileList.vue'
import ClipOperate from './ClipOperate.vue' import ClipOperate from './ClipOperate.vue'
import { onMounted } from 'vue' import { onMounted, onUnmounted } from 'vue'
const props = defineProps({ const props = defineProps({
isShow: { isShow: {
@@ -49,15 +49,21 @@ const onOverlayClick = () => {
emit('onOverlayClick') emit('onOverlayClick')
} }
onMounted(() => { const keyDownCallBack = (e) => {
document.addEventListener('keydown', (e) => {
const { key } = e const { key } = e
if (key === 'Escape' && props.fullData.data) { if (key === 'Escape' && props.fullData.data) {
// 有值时执行退出 Overlay // 有值时执行退出 Overlay
emit('onOverlayClick') emit('onOverlayClick')
e.stopPropagation() e.stopPropagation()
} }
}) }
onMounted(() => {
document.addEventListener('keydown', keyDownCallBack)
})
onUnmounted(() => {
document.removeEventListener('keydown', keyDownCallBack)
}) })
</script> </script>

View File

@@ -59,7 +59,7 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted, watch } from 'vue' import { ref, onMounted, onUnmounted, watch } from 'vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import FileList from './FileList.vue' import FileList from './FileList.vue'
import ClipOperate from './ClipOperate.vue' import ClipOperate from './ClipOperate.vue'
@@ -196,9 +196,8 @@ watch(
() => props.showList, () => props.showList,
() => (activeIndex.value = 0) () => (activeIndex.value = 0)
) )
onMounted(() => {
// 监听键盘事件 const keyDownCallBack = (e) => {
document.addEventListener('keydown', (e) => {
const { key, ctrlKey, metaKey, altKey } = e const { key, ctrlKey, metaKey, altKey } = e
const isArrowUp = key === 'ArrowUp' const isArrowUp = key === 'ArrowUp'
const isArrowDown = key === 'ArrowDown' const isArrowDown = key === 'ArrowDown'
@@ -239,6 +238,7 @@ onMounted(() => {
} }
} else if (isEnter) { } else if (isEnter) {
if (!props.isMultiple) { if (!props.isMultiple) {
console.log('isEnter')
window.copy(props.showList[activeIndex.value]) window.copy(props.showList[activeIndex.value])
window.paste() window.paste()
ElMessage({ ElMessage({
@@ -276,8 +276,8 @@ onMounted(() => {
.scrollIntoView({ block: 'nearest', inline: 'nearest' }) .scrollIntoView({ block: 'nearest', inline: 'nearest' })
} }
} }
}) }
document.addEventListener('keyup', (e) => { const keyUpCallBack = (e) => {
const { key } = e const { key } = e
const isShift = key === 'Shift' const isShift = key === 'Shift'
if (isShift) { if (isShift) {
@@ -285,7 +285,17 @@ onMounted(() => {
isShiftDown.value = false isShiftDown.value = false
} }
} }
}) }
onMounted(() => {
// 监听键盘事件
document.addEventListener('keydown', keyDownCallBack)
document.addEventListener('keyup', keyUpCallBack)
})
onUnmounted(() => {
document.removeEventListener('keydown', keyDownCallBack)
document.removeEventListener('keyup', keyUpCallBack)
}) })
</script> </script>

View File

@@ -58,7 +58,7 @@
</template> </template>
<script setup> <script setup>
import { ref, watch, onMounted, computed, nextTick } from 'vue' import { ref, watch, onMounted, onUnmounted, computed, nextTick } from 'vue'
import { ElMessageBox, ElMessage } from 'element-plus' import { ElMessageBox, ElMessage } from 'element-plus'
import ClipItemList from '../cpns/ClipItemList.vue' import ClipItemList from '../cpns/ClipItemList.vue'
import ClipFullData from '../cpns/ClipFullData.vue' import ClipFullData from '../cpns/ClipFullData.vue'
@@ -263,7 +263,7 @@ onMounted(() => {
} }
// 列表懒加载 // 列表懒加载
document.addEventListener('scroll', (e) => { const scrollCallBack = (e) => {
const { scrollTop, clientHeight, scrollHeight } = e.target.scrollingElement const { scrollTop, clientHeight, scrollHeight } = e.target.scrollingElement
if (scrollTop + clientHeight + 5 >= scrollHeight) { if (scrollTop + clientHeight + 5 >= scrollHeight) {
offset.value += GAP offset.value += GAP
@@ -280,10 +280,10 @@ onMounted(() => {
showList.value.push(...addition) showList.value.push(...addition)
} }
} }
}) }
// 监听键盘事件 // 监听键盘事件
document.addEventListener('keydown', (e) => { const keyDownCallBack = (e) => {
const { key, ctrlKey, metaKey } = e const { key, ctrlKey, metaKey } = e
const isTab = key === 'Tab' const isTab = key === 'Tab'
const isSearch = const isSearch =
@@ -336,6 +336,14 @@ onMounted(() => {
} else { } else {
window.focus() // 其他键盘事件 直接聚焦搜索框 window.focus() // 其他键盘事件 直接聚焦搜索框
} }
}
document.addEventListener('scroll', scrollCallBack)
document.addEventListener('keydown', keyDownCallBack)
onUnmounted(() => {
document.removeEventListener('scroll', scrollCallBack)
document.removeEventListener('keydown', keyDownCallBack)
}) })
}) })
</script> </script>