|
@@ -313,6 +313,7 @@ export struct LocalMusic {
|
|
|
@State alphabetHeight: number = 0
|
|
@State alphabetHeight: number = 0
|
|
|
public enableShowAlphabet: boolean = true // 是否显示字母表
|
|
public enableShowAlphabet: boolean = true // 是否显示字母表
|
|
|
private alphaBetHideTimer: number = 0
|
|
private alphaBetHideTimer: number = 0
|
|
|
|
|
+ private alphaBetCacheKey: string = ''
|
|
|
@State isShowPrecious: boolean = false //播控条显示上一首按钮
|
|
@State isShowPrecious: boolean = false //播控条显示上一首按钮
|
|
|
//背景两侧流光控制器
|
|
//背景两侧流光控制器
|
|
|
@State sceneBgController: HdsSceneController|undefined = deviceInfo.sdkApiVersion>=20
|
|
@State sceneBgController: HdsSceneController|undefined = deviceInfo.sdkApiVersion>=20
|
|
@@ -3411,6 +3412,10 @@ export struct LocalMusic {
|
|
|
if(!this.showZMIndex){
|
|
if(!this.showZMIndex){
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+ if (this.modeType === 1 && this.totalCount > this.videoLocalList.length) {
|
|
|
|
|
+ await this.refreshAlphaBetFromMediaLibrary()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
return new Promise<void>((resolve,reject) => {
|
|
return new Promise<void>((resolve,reject) => {
|
|
|
try {
|
|
try {
|
|
|
let songs = this.videoLocalList
|
|
let songs = this.videoLocalList
|
|
@@ -3461,6 +3466,51 @@ export struct LocalMusic {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private async refreshAlphaBetFromMediaLibrary(): Promise<void> {
|
|
|
|
|
+ if (this.totalCount <= 0) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.totalCount > 40000) {
|
|
|
|
|
+ this.alphaBet = []
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ const keyword = this.isSearchMode ? this.searchText : ''
|
|
|
|
|
+ const cacheKey = `${this.modeType}-${this.sortType}-${this.isShowFileName}-${keyword}-${this.totalCount}`
|
|
|
|
|
+ if (this.alphaBetCacheKey === cacheKey && this.alphaBet.length > 0) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ const result = await this.table.queryMediaLibraryPaged({
|
|
|
|
|
+ pageIndex: 0,
|
|
|
|
|
+ pageSize: this.totalCount,
|
|
|
|
|
+ sortType: this.sortType,
|
|
|
|
|
+ searchKeyword: this.isSearchMode ? this.searchText : undefined
|
|
|
|
|
+ })
|
|
|
|
|
+ let alphabetSet = new Set<string>()
|
|
|
|
|
+ for (let song of result.items) {
|
|
|
|
|
+ let text = this.isShowFileName ? song.fileName :
|
|
|
|
|
+ (song.type != CommonConstants.TYPE_IS_DIR && song.pyStr) ? song.pyStr : song.name
|
|
|
|
|
+ if (this.sortType === 0 || this.sortType == 1) {
|
|
|
|
|
+ text = song.artist
|
|
|
|
|
+ } else if (this.sortType === 2 || this.sortType == 3) {
|
|
|
|
|
+ text = song.album
|
|
|
|
|
+ }
|
|
|
|
|
+ if (text) {
|
|
|
|
|
+ let firstPinyin = getFirstLetter(text)
|
|
|
|
|
+ if (!alphabetSet.has(firstPinyin)) {
|
|
|
|
|
+ alphabetSet.add(firstPinyin)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ this.alphaBet = Array.from(alphabetSet).sort((a, b) => {
|
|
|
|
|
+ if (this.sortType === 4 || this.sortType == 0 || this.sortType == 2 || this.sortType == 6) {
|
|
|
|
|
+ return a.localeCompare(b)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return b.localeCompare(a)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ this.alphaBetCacheKey = cacheKey
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Builder
|
|
@Builder
|
|
|
topTitleBar(){
|
|
topTitleBar(){
|