From e7f3f271041aa06d95989e878063d83aee3d8dd4 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Tue, 18 Jul 2023 18:38:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=90=9C=E7=B4=A2=E6=A1=86?= =?UTF-8?q?=E5=9C=A8=E6=9F=90=E4=BA=9B=E6=83=85=E5=86=B5=E4=B8=8B=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E5=86=85=E5=AE=B9=E5=90=8E=E6=90=9C=E7=B4=A2=E6=97=B6?= =?UTF-8?q?=E4=BC=9A=E8=87=AA=E5=8A=A8=E6=B8=85=E7=A9=BA=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=88#1472=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 1 + .../components/material/SearchInput.vue | 12 ++++++++++-- .../List/MusicList/components/SearchList.vue | 18 ++++++++++++------ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 884f862d..83785a69 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -11,6 +11,7 @@ - 修复搜索提示功能失效的问题(#1452, @Folltoshe) - 修复我的列表名右键菜单-排序歌曲按专辑名排序无效的问题(#1440) - 修复若路径存在 # 字符时,软件无法启动的问题 +- 修复搜索框在某些情况下输入内容后搜索时会自动清空的问题(#1472) ### 其他 diff --git a/src/renderer/components/material/SearchInput.vue b/src/renderer/components/material/SearchInput.vue index 76ce39d2..ba6ffc3e 100644 --- a/src/renderer/components/material/SearchInput.vue +++ b/src/renderer/components/material/SearchInput.vue @@ -162,10 +162,18 @@ export default { }) }, handleKeyDown() { - this.selectIndex = this.selectIndex + 1 < this.list.length ? this.selectIndex + 1 : 0 + if (this.list.length) { + this.selectIndex = this.selectIndex + 1 < this.list.length ? this.selectIndex + 1 : 0 + } else if (this.selectIndex > -1) { + this.selectIndex = -1 + } }, handleKeyUp() { - this.selectIndex = this.selectIndex - 1 < -1 ? this.list.length - 1 : this.selectIndex - 1 + if (this.list.length) { + this.selectIndex = this.selectIndex - 1 < -1 ? this.list.length - 1 : this.selectIndex - 1 + } else if (this.selectIndex > -1) { + this.selectIndex = -1 + } }, handleContextMenu() { let str = clipboardReadText() diff --git a/src/renderer/views/List/MusicList/components/SearchList.vue b/src/renderer/views/List/MusicList/components/SearchList.vue index c7489d90..1535fd6e 100644 --- a/src/renderer/views/List/MusicList/components/SearchList.vue +++ b/src/renderer/views/List/MusicList/components/SearchList.vue @@ -168,14 +168,20 @@ export default { }) }, handleKeyDown() { - if (!this.resultList.length) return - this.selectIndex = this.selectIndex + 1 < this.resultList.length ? this.selectIndex + 1 : 0 - this.handleScrollList() + if (this.resultList.length) { + this.selectIndex = this.selectIndex + 1 < this.resultList.length ? this.selectIndex + 1 : 0 + this.handleScrollList() + } else if (this.selectIndex > -1) { + this.selectIndex = -1 + } }, handleKeyUp() { - if (!this.resultList.length) return - this.selectIndex = this.selectIndex - 1 < -1 ? this.resultList.length - 1 : this.selectIndex - 1 - this.handleScrollList() + if (this.resultList.length) { + this.selectIndex = this.selectIndex - 1 < -1 ? this.resultList.length - 1 : this.selectIndex - 1 + this.handleScrollList() + } else if (this.selectIndex > -1) { + this.selectIndex = -1 + } }, handleScrollList() { if (this.selectIndex < 0) return