fix: add null checks for refs before invoking methods to prevent potential errors

This commit is contained in:
jmal 2025-08-07 11:07:02 +08:00
parent a745ff70be
commit 246b262a76
3 changed files with 8 additions and 4 deletions

View File

@ -313,7 +313,9 @@ export default {
this.fileList.map((item, index) => {
item.index = index
})
if (this.$refs.fileListTable) {
this.$refs.fileListTable.reloadData(this.fileList)
}
setTimeout(() => {
if (this.$refs.fileListTable) {
this.$refs.fileListTable.reloadData(this.fileList)

View File

@ -282,7 +282,7 @@ export default {
item.searchOverall = false
}
this.debounceSearch(this.searchFileName, false)
this.$refs.searchOption.setFilterOption(item)
this.$refs.searchOption && this.$refs.searchOption.setFilterOption(item)
this.$nextTick(() => {
this._isSuggestionHandledBySelect = false
})

View File

@ -50,7 +50,7 @@ export default {
event.stopPropagation()
}
// Del
if (keyCode === 8 && !this.inputting && this.selectRowData.length > 0 && !checkPreviewVisible) {
if (keyCode === 46 && !this.inputting && this.selectRowData.length > 0 && !checkPreviewVisible) {
this.removeOperation()
event.preventDefault()
event.stopPropagation()
@ -91,7 +91,9 @@ export default {
}
// ctrl + P / cmd + P
if (isCmd && keyCode === 80 && !checkPreviewVisible) {
if (this.$refs.searchInput) {
this.$refs.searchInput.focus()
}
event.preventDefault()
event.stopPropagation()
}