|
@@ -221,11 +221,11 @@ interface WorkerMessageEditResult {
|
|
|
|
|
|
|
|
type LocalMusicWorkerMessage =
|
|
type LocalMusicWorkerMessage =
|
|
|
WorkerMessageScanDone
|
|
WorkerMessageScanDone
|
|
|
- | WorkerMessageMediaList
|
|
|
|
|
- | WorkerMessageArtistList
|
|
|
|
|
- | WorkerMessageAlbumList
|
|
|
|
|
- | WorkerMessageMetadata
|
|
|
|
|
- | WorkerMessageEditResult;
|
|
|
|
|
|
|
+ | WorkerMessageMediaList
|
|
|
|
|
+ | WorkerMessageArtistList
|
|
|
|
|
+ | WorkerMessageAlbumList
|
|
|
|
|
+ | WorkerMessageMetadata
|
|
|
|
|
+ | WorkerMessageEditResult;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 歌单播放事件数据
|
|
* 歌单播放事件数据
|
|
@@ -442,7 +442,7 @@ export struct LocalMusic {
|
|
|
private playListScroller: Scroller = new Scroller()
|
|
private playListScroller: Scroller = new Scroller()
|
|
|
@State isOneKeyTags:boolean = false
|
|
@State isOneKeyTags:boolean = false
|
|
|
@State isFixMessy:boolean = false
|
|
@State isFixMessy:boolean = false
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 分页相关状态
|
|
// 分页相关状态
|
|
|
@State private currentPage: number = 0 // 当前页码
|
|
@State private currentPage: number = 0 // 当前页码
|
|
|
@State private pageSize: number = 50 // 每页数量
|
|
@State private pageSize: number = 50 // 每页数量
|
|
@@ -535,12 +535,12 @@ export struct LocalMusic {
|
|
|
async onModeChange(): Promise<void> {
|
|
async onModeChange(): Promise<void> {
|
|
|
this.isFavMusic = false
|
|
this.isFavMusic = false
|
|
|
this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, true)
|
|
this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, true)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Logger.info('heanup LocalMusic', `onModeChange: 切换模式 modeType=${this.modeType}`);
|
|
Logger.info('heanup LocalMusic', `onModeChange: 切换模式 modeType=${this.modeType}`);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 模式切换时重置分页状态并加载第一页
|
|
// 模式切换时重置分页状态并加载第一页
|
|
|
await this.resetAndLoadFirstPage();
|
|
await this.resetAndLoadFirstPage();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
switch (this.modeType) {
|
|
switch (this.modeType) {
|
|
|
case 0:
|
|
case 0:
|
|
|
// 首页模式已在 resetAndLoadFirstPage 中处理
|
|
// 首页模式已在 resetAndLoadFirstPage 中处理
|
|
@@ -1236,7 +1236,7 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
// 保存前100条艺术家列表
|
|
// 保存前100条艺术家列表
|
|
|
PreferencesUtil.putSync('artistList', JSON.stringify(this.artistList));
|
|
PreferencesUtil.putSync('artistList', JSON.stringify(this.artistList));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 保存前60条艺术家的歌曲Map
|
|
// 保存前60条艺术家的歌曲Map
|
|
|
const sortedEntries = Array.from(this.artistMap.entries());
|
|
const sortedEntries = Array.from(this.artistMap.entries());
|
|
|
PreferencesUtil.putSync('artistMap', JSON.stringify(sortedEntries));
|
|
PreferencesUtil.putSync('artistMap', JSON.stringify(sortedEntries));
|
|
@@ -1255,12 +1255,12 @@ export struct LocalMusic {
|
|
|
});
|
|
});
|
|
|
this.albumSongCountMap = nextAlbumCountMap;
|
|
this.albumSongCountMap = nextAlbumCountMap;
|
|
|
Logger.info(`heanup 查询专辑列表 缓存数=${this.albumList.length}, 总数=${albumTotalCount}`)
|
|
Logger.info(`heanup 查询专辑列表 缓存数=${this.albumList.length}, 总数=${albumTotalCount}`)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 专辑模式下重新加载第一页(分页查询)
|
|
// 专辑模式下重新加载第一页(分页查询)
|
|
|
if (this.modeType === 3) {
|
|
if (this.modeType === 3) {
|
|
|
this.resetAndLoadFirstPage();
|
|
this.resetAndLoadFirstPage();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
//查询完毕在启动是否自动播放
|
|
//查询完毕在启动是否自动播放
|
|
|
if (this.isStartAutoPlay&&this.isCanAuto) {
|
|
if (this.isStartAutoPlay&&this.isCanAuto) {
|
|
|
this.isCanAuto = false
|
|
this.isCanAuto = false
|
|
@@ -1270,7 +1270,7 @@ export struct LocalMusic {
|
|
|
PreferencesUtil.putSync('albumCount', albumTotalCount)
|
|
PreferencesUtil.putSync('albumCount', albumTotalCount)
|
|
|
// 保存前100条专辑列表(Worker已经只发送了100条)
|
|
// 保存前100条专辑列表(Worker已经只发送了100条)
|
|
|
PreferencesUtil.putSync('albumList', JSON.stringify(this.albumList));
|
|
PreferencesUtil.putSync('albumList', JSON.stringify(this.albumList));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 保存前60条专辑Map(Worker已经只发送了60条)
|
|
// 保存前60条专辑Map(Worker已经只发送了60条)
|
|
|
const mapArrayAlbum = Array.from(this.albumMap.entries());
|
|
const mapArrayAlbum = Array.from(this.albumMap.entries());
|
|
|
PreferencesUtil.putSync('albumMap', JSON.stringify(mapArrayAlbum));
|
|
PreferencesUtil.putSync('albumMap', JSON.stringify(mapArrayAlbum));
|
|
@@ -1991,7 +1991,7 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
updateListData(mList: Array<VideoItem>, noSort?: boolean) {
|
|
updateListData(mList: Array<VideoItem>, noSort?: boolean) {
|
|
|
this.isShowTitleBar = true
|
|
this.isShowTitleBar = true
|
|
|
- animateTo({ duration: 666 }, () => {
|
|
|
|
|
|
|
+ this.getUIContext().animateTo({ duration: 666 }, () => {
|
|
|
this.opacityItem = 0.5;
|
|
this.opacityItem = 0.5;
|
|
|
});
|
|
});
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
@@ -2003,7 +2003,7 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
this.dataSource.pushArrayData(this.videoLocalList)
|
|
this.dataSource.pushArrayData(this.videoLocalList)
|
|
|
- animateTo({ duration: 666 }, () => {
|
|
|
|
|
|
|
+ this.getUIContext().animateTo({ duration: 666 }, () => {
|
|
|
this.opacityItem = 1;
|
|
this.opacityItem = 1;
|
|
|
});
|
|
});
|
|
|
this.setButtonStatus()
|
|
this.setButtonStatus()
|
|
@@ -2221,10 +2221,10 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
async doSortType(index: number): Promise<void> {
|
|
async doSortType(index: number): Promise<void> {
|
|
|
Logger.info('heanup LocalMusic', `doSortType: 切换排序方式 sortType=${index}, mode=${this.modeType}`);
|
|
Logger.info('heanup LocalMusic', `doSortType: 切换排序方式 sortType=${index}, mode=${this.modeType}`);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
this.sortType = index;
|
|
this.sortType = index;
|
|
|
PreferencesUtil.putSync(SettingPage.SORT_TYPE, index);
|
|
PreferencesUtil.putSync(SettingPage.SORT_TYPE, index);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 分页模式下,排序需要重新从数据库查询
|
|
// 分页模式下,排序需要重新从数据库查询
|
|
|
await this.resetAndLoadFirstPage();
|
|
await this.resetAndLoadFirstPage();
|
|
|
}
|
|
}
|
|
@@ -2986,9 +2986,6 @@ export struct LocalMusic {
|
|
|
this.asyncCurrentPathOnlyFile()
|
|
this.asyncCurrentPathOnlyFile()
|
|
|
})
|
|
})
|
|
|
.position({ top: 200 })
|
|
.position({ top: 200 })
|
|
|
- .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 1.2, y: 1.2 })
|
|
|
|
|
- .animation({ duration: 500 }),
|
|
|
|
|
- TransitionEffect.scale({ x: 0, y: 0 })))
|
|
|
|
|
.justifyContent(FlexAlign.Center)
|
|
.justifyContent(FlexAlign.Center)
|
|
|
.opacity(this.isZero ? 1 : 0)
|
|
.opacity(this.isZero ? 1 : 0)
|
|
|
.visibility(this.isZero && !this.isFavMusic && !this.isHistory
|
|
.visibility(this.isZero && !this.isFavMusic && !this.isHistory
|
|
@@ -3081,7 +3078,7 @@ export struct LocalMusic {
|
|
|
})
|
|
})
|
|
|
.onClick(() => {
|
|
.onClick(() => {
|
|
|
// if(ArrayUtil.isNotEmpty(this.selectedFiles)&&Utility.isMerge(this.selectedFiles,this.packName)){
|
|
// if(ArrayUtil.isNotEmpty(this.selectedFiles)&&Utility.isMerge(this.selectedFiles,this.packName)){
|
|
|
- this.isOneKeyTags = !this.isOneKeyTags
|
|
|
|
|
|
|
+ this.isOneKeyTags = !this.isOneKeyTags
|
|
|
// }else{
|
|
// }else{
|
|
|
// ToastUtil.showToast('选中的文件包含了不是本应用的DownLoad文件下,其他路径音频无权限批量内嵌标签,导入的时候请勾选复制一份。')
|
|
// ToastUtil.showToast('选中的文件包含了不是本应用的DownLoad文件下,其他路径音频无权限批量内嵌标签,导入的时候请勾选复制一份。')
|
|
|
// }
|
|
// }
|
|
@@ -3328,7 +3325,7 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
async setAlphaBet(){
|
|
async setAlphaBet(){
|
|
|
if(!this.showZMIndex){
|
|
if(!this.showZMIndex){
|
|
|
- return
|
|
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
return new Promise<void>((resolve,reject) => {
|
|
return new Promise<void>((resolve,reject) => {
|
|
|
try {
|
|
try {
|
|
@@ -4895,9 +4892,9 @@ export struct LocalMusic {
|
|
|
// 实时搜索逻辑(带防抖)
|
|
// 实时搜索逻辑(带防抖)
|
|
|
private async onSearchInput(value: string): Promise<void> {
|
|
private async onSearchInput(value: string): Promise<void> {
|
|
|
this.searchText = value.trim();
|
|
this.searchText = value.trim();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Logger.info('heanup LocalMusic', `onSearchInput: keyword="${this.searchText}", mode=${this.modeType}`);
|
|
Logger.info('heanup LocalMusic', `onSearchInput: keyword="${this.searchText}", mode=${this.modeType}`);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 新增条件判断:空输入时退出搜索模式
|
|
// 新增条件判断:空输入时退出搜索模式
|
|
|
if (this.searchText === '') {
|
|
if (this.searchText === '') {
|
|
|
this.isSearchMode = false;
|
|
this.isSearchMode = false;
|
|
@@ -4905,12 +4902,12 @@ export struct LocalMusic {
|
|
|
await this.resetAndLoadFirstPage();
|
|
await this.resetAndLoadFirstPage();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 进入搜索模式
|
|
// 进入搜索模式
|
|
|
if (!this.isSearchMode) {
|
|
if (!this.isSearchMode) {
|
|
|
this.isSearchMode = true;
|
|
this.isSearchMode = true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 使用数据库分页查询(带搜索条件)
|
|
// 使用数据库分页查询(带搜索条件)
|
|
|
await this.resetAndLoadFirstPage();
|
|
await this.resetAndLoadFirstPage();
|
|
|
}
|
|
}
|
|
@@ -5493,7 +5490,7 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
return { offsetRemain: offset };
|
|
return { offsetRemain: offset };
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
@State targetFile: string = '';
|
|
@State targetFile: string = '';
|
|
@@ -6957,7 +6954,7 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
this.isLoadingPage = true;
|
|
this.isLoadingPage = true;
|
|
|
Logger.info('heanup LocalMusic', `loadPage: 开始加载 page=${pageIndex}, size=${this.pageSize}, mode=${this.modeType}`);
|
|
Logger.info('heanup LocalMusic', `loadPage: 开始加载 page=${pageIndex}, size=${this.pageSize}, mode=${this.modeType}`);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 2. 构造查询参数
|
|
// 2. 构造查询参数
|
|
|
const options: PageQueryOptions = {
|
|
const options: PageQueryOptions = {
|
|
|
pageIndex: pageIndex,
|
|
pageIndex: pageIndex,
|
|
@@ -7020,9 +7017,9 @@ export struct LocalMusic {
|
|
|
} else if (this.modeType === 3 && result.countMap) {
|
|
} else if (this.modeType === 3 && result.countMap) {
|
|
|
this.mergeAlbumCountMap(result.countMap);
|
|
this.mergeAlbumCountMap(result.countMap);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Logger.info('heanup LocalMusic', `loadPage: 查询完成 items=${result.items.length}, total=${result.totalCount}, hasMore=${result.hasMore}`);
|
|
Logger.info('heanup LocalMusic', `loadPage: 查询完成 items=${result.items.length}, total=${result.totalCount}, hasMore=${result.hasMore}`);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 缓存管理 - 只保留最近3页
|
|
// 缓存管理 - 只保留最近3页
|
|
|
this.pageCache.set(pageIndex, result.items);
|
|
this.pageCache.set(pageIndex, result.items);
|
|
|
this.cleanOldCache(pageIndex);
|
|
this.cleanOldCache(pageIndex);
|
|
@@ -7033,7 +7030,7 @@ export struct LocalMusic {
|
|
|
} else {
|
|
} else {
|
|
|
this.videoLocalList = result.items;
|
|
this.videoLocalList = result.items;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
this.dataSource.pushArrayData(this.videoLocalList);
|
|
this.dataSource.pushArrayData(this.videoLocalList);
|
|
|
this.setButtonStatus();
|
|
this.setButtonStatus();
|
|
|
this.setAlphaBet();
|
|
this.setAlphaBet();
|
|
@@ -7054,15 +7051,15 @@ export struct LocalMusic {
|
|
|
private cleanOldCache(currentPage: number): void {
|
|
private cleanOldCache(currentPage: number): void {
|
|
|
const pagesToKeep = new Set([currentPage - 1, currentPage, currentPage + 1]);
|
|
const pagesToKeep = new Set([currentPage - 1, currentPage, currentPage + 1]);
|
|
|
const keysToDelete: number[] = [];
|
|
const keysToDelete: number[] = [];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
this.pageCache.forEach((_, page) => {
|
|
this.pageCache.forEach((_, page) => {
|
|
|
if (!pagesToKeep.has(page)) {
|
|
if (!pagesToKeep.has(page)) {
|
|
|
keysToDelete.push(page);
|
|
keysToDelete.push(page);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
keysToDelete.forEach(page => this.pageCache.delete(page));
|
|
keysToDelete.forEach(page => this.pageCache.delete(page));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (keysToDelete.length > 0) {
|
|
if (keysToDelete.length > 0) {
|
|
|
Logger.info('heanup LocalMusic', `cleanOldCache: 清理了 ${keysToDelete.length} 页缓存`);
|
|
Logger.info('heanup LocalMusic', `cleanOldCache: 清理了 ${keysToDelete.length} 页缓存`);
|
|
|
}
|
|
}
|
|
@@ -7140,7 +7137,7 @@ export struct LocalMusic {
|
|
|
private async loadDirectories(curPath: string): Promise<VideoItem[]> {
|
|
private async loadDirectories(curPath: string): Promise<VideoItem[]> {
|
|
|
try {
|
|
try {
|
|
|
Logger.info('heanup LocalMusic', `loadDirectories: 开始加载文件夹 path=${curPath}`);
|
|
Logger.info('heanup LocalMusic', `loadDirectories: 开始加载文件夹 path=${curPath}`);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查缓存
|
|
// 检查缓存
|
|
|
const cacheKey = curPath + "_dirList";
|
|
const cacheKey = curPath + "_dirList";
|
|
|
const cachedDirList = this.findCache(cacheKey);
|
|
const cachedDirList = this.findCache(cacheKey);
|
|
@@ -7148,20 +7145,20 @@ export struct LocalMusic {
|
|
|
Logger.info('heanup LocalMusic', `loadDirectories: 从缓存加载 count=${cachedDirList.length}`);
|
|
Logger.info('heanup LocalMusic', `loadDirectories: 从缓存加载 count=${cachedDirList.length}`);
|
|
|
return cachedDirList as VideoItem[];
|
|
return cachedDirList as VideoItem[];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 从文件系统读取
|
|
// 从文件系统读取
|
|
|
const fileList = FileUtil.listFileSync(curPath);
|
|
const fileList = FileUtil.listFileSync(curPath);
|
|
|
const directories: VideoItem[] = [];
|
|
const directories: VideoItem[] = [];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for (let i = 0; i < fileList.length; i++) {
|
|
for (let i = 0; i < fileList.length; i++) {
|
|
|
const path = curPath + '/' + fileList[i];
|
|
const path = curPath + '/' + fileList[i];
|
|
|
if (FileUtil.isDirectory(path)) {
|
|
if (FileUtil.isDirectory(path)) {
|
|
|
const item: VideoItem = new VideoItem(
|
|
const item: VideoItem = new VideoItem(
|
|
|
- fileList[i].toString(),
|
|
|
|
|
- fileList[i].toString(),
|
|
|
|
|
- path,
|
|
|
|
|
- CommonConstants.TYPE_IS_DIR,
|
|
|
|
|
- 0,
|
|
|
|
|
|
|
+ fileList[i].toString(),
|
|
|
|
|
+ fileList[i].toString(),
|
|
|
|
|
+ path,
|
|
|
|
|
+ CommonConstants.TYPE_IS_DIR,
|
|
|
|
|
+ 0,
|
|
|
''
|
|
''
|
|
|
);
|
|
);
|
|
|
if (this.isShowDir(item.name)) {
|
|
if (this.isShowDir(item.name)) {
|
|
@@ -7169,16 +7166,16 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 排序
|
|
// 排序
|
|
|
Utility.doSortListAscending(directories);
|
|
Utility.doSortListAscending(directories);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 缓存文件夹列表
|
|
// 缓存文件夹列表
|
|
|
if (curPath === this.rootPath) {
|
|
if (curPath === this.rootPath) {
|
|
|
this.dirList = directories;
|
|
this.dirList = directories;
|
|
|
this.addCache(cacheKey, directories);
|
|
this.addCache(cacheKey, directories);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Logger.info('heanup LocalMusic', `loadDirectories: 加载完成 count=${directories.length}`);
|
|
Logger.info('heanup LocalMusic', `loadDirectories: 加载完成 count=${directories.length}`);
|
|
|
return directories;
|
|
return directories;
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
@@ -13861,7 +13858,7 @@ export struct LocalMusic {
|
|
|
} else {
|
|
} else {
|
|
|
if (StrUtil.isNotEmpty(this.videoUrl) &&
|
|
if (StrUtil.isNotEmpty(this.videoUrl) &&
|
|
|
!this.videoUrl.startsWith('http') &&
|
|
!this.videoUrl.startsWith('http') &&
|
|
|
- this.currentSong &&this.currentSong.type==CommonConstants.TYPE_LOCAL&&
|
|
|
|
|
|
|
+ this.currentSong &&this.currentSong.type==CommonConstants.TYPE_LOCAL&&
|
|
|
!FileUtil.accessSync(this.videoUrl)) {
|
|
!FileUtil.accessSync(this.videoUrl)) {
|
|
|
console.info('heanup 播放.文件不存在');
|
|
console.info('heanup 播放.文件不存在');
|
|
|
ToastUtil.showToast(Utility.resourceToString(this.context, $r('app.string.file_not_exist')))
|
|
ToastUtil.showToast(Utility.resourceToString(this.context, $r('app.string.file_not_exist')))
|