|
|
@@ -51,6 +51,7 @@ import { CommonConstants } from '../common/constants/CommonConstants';
|
|
|
import { BaiduConstants } from '../common/constants/BaiduConstants';
|
|
|
import { EventConstants } from '../common/constants/EventConstants';
|
|
|
import Logger from '../common/util/Logger';
|
|
|
+import { filterPlaylistSongsByKeyword, findSongIndexByFilePath } from '../common/util/PlaylistSearchHelper';
|
|
|
import { http } from '@kit.NetworkKit';
|
|
|
import { photoAccessHelper } from '@kit.MediaLibraryKit';
|
|
|
import { BusinessError, emitter } from '@kit.BasicServicesKit';
|
|
|
@@ -6309,6 +6310,27 @@ export struct LocalMusic {
|
|
|
|
|
|
Logger.info('heanup LocalMusic', `onSearchInput: keyword="${this.searchText}", mode=${this.modeType}`);
|
|
|
|
|
|
+ // 歌单模式不走媒体库分页查询,直接在当前歌单中筛选,避免混入非歌单歌曲并打乱顺序。
|
|
|
+ if (this.modeType === 4) {
|
|
|
+ if (this.searchText === '') {
|
|
|
+ this.loadSearchHistory()
|
|
|
+ this.filteredList = []
|
|
|
+ this.updateListData(this.currentSongList, true, true)
|
|
|
+ Logger.info('heanup LocalMusic', `onSearchInput: restore playlist list, count=${this.currentSongList.length}`)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!this.isSearchMode) {
|
|
|
+ this.isSearchMode = true
|
|
|
+ }
|
|
|
+
|
|
|
+ const filteredSongs = filterPlaylistSongsByKeyword(this.currentSongList, this.searchText)
|
|
|
+ this.filteredList = filteredSongs
|
|
|
+ this.updateListData(filteredSongs, true, true)
|
|
|
+ Logger.info('heanup LocalMusic', `onSearchInput: playlist filter applied, keyword="${this.searchText}", count=${filteredSongs.length}`)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
// 清空搜索文本时保持搜索态,只重置为不带关键词的结果列表
|
|
|
if (this.searchText === '') {
|
|
|
this.loadSearchHistory()
|
|
|
@@ -8113,7 +8135,7 @@ export struct LocalMusic {
|
|
|
}
|
|
|
}else {
|
|
|
const globalVideoList = this.buildPlayQueueFromView();
|
|
|
- this.curIndex = Utility.getCurIndexFromGlobalList(globalVideoList, item.filePath)
|
|
|
+ this.curIndex = findSongIndexByFilePath(globalVideoList, item.filePath)
|
|
|
if (this.curIndex < 0) {
|
|
|
globalVideoList.push(item);
|
|
|
this.curIndex = globalVideoList.length - 1;
|