Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复部分快捷键和其他操作之间的冲突 #237

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 37 additions & 19 deletions src/components/ShowFile/ShowFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1352,34 +1352,30 @@ export default {
const { keyCode } = event
const isCmd = this.checkCmdKey(event)
console.log('keydown', 'keyCode', keyCode, 'isCmd', isCmd)

const checkPreviewVisible = this.checkPreviewVisible()
// space
if (keyCode === 32) {
if (!this.inputting && this.selectRowData.length > 0 && !this.drawer) {
this.drawer = true
this.drawerShowTime = Date.now()
event.preventDefault()
event.stopPropagation()
}
if (keyCode === 32 && this.selectRowData.length > 0 && !this.drawer && !checkPreviewVisible) {
this.drawer = true
this.drawerShowTime = Date.now()
event.preventDefault()
event.stopPropagation()
}
// F2
if (keyCode === 113) {
if (this.selectRowData.length > 0 && !this.drawer) {
this.renameFileName = this.rowContextData.name
this.editingIndex = this.rowContextData.index
}
if (keyCode === 113 && this.selectRowData.length > 0 && !checkPreviewVisible) {
this.renameFileName = this.rowContextData.name
this.editingIndex = this.rowContextData.index
event.preventDefault()
event.stopPropagation()
}
// Del
if (keyCode === 8) {
if (!this.inputting && this.selectRowData.length > 0) {
this.removeOperation()
event.preventDefault()
event.stopPropagation()
}
if (keyCode === 8 && !this.inputting && this.selectRowData.length > 0 && !checkPreviewVisible) {
this.removeOperation()
event.preventDefault()
event.stopPropagation()
}
// ctrl + A / cmd + A
if (isCmd && keyCode === 65) {
if (isCmd && keyCode === 65 && !checkPreviewVisible) {
if (this.inputting || this.editingIndex !== -1) {
event.target.select()
} else {
Expand Down Expand Up @@ -3406,6 +3402,7 @@ export default {
},
// 全局右键菜单操作
contextmenuClick(operation) {
this.$refs.fileListTable.clearSelection()
switch (operation) {
case 'vmode-list':
this.grid = true
Expand Down Expand Up @@ -4244,6 +4241,27 @@ export default {
this.notPreviewDialogVisible = true
}
},
checkPreviewVisible() {
if (this.iframePreviewVisible) {
return true
}
if (this.imagePreviewVisible) {
return true
}
if (this.textPreviewVisible) {
return true
}
if (this.videoPreviewVisible) {
return true
}
if (this.audioPreviewVisible) {
return true
}
if (this.openCompressionVisible) {
return true
}
return this.notPreviewDialogVisible;
},
hasIframePreview(suffix, fileHandlers) {
for (let key in fileHandlers) {
const extensions = key.split(',')
Expand Down