|
|
@@ -1,6 +1,6 @@
|
|
|
import { DialogHelper } from '@pura/harmony-dialog';
|
|
|
import { Playlist } from '../viewmodel/Playlist';
|
|
|
-import { ToastUtil, LogUtil, StrUtil } from '@pura/harmony-utils';
|
|
|
+import { ToastUtil, LogUtil, StrUtil, FileUtil, PreferencesUtil } from '@pura/harmony-utils';
|
|
|
import { VideoItem } from '../viewmodel/VideoItem';
|
|
|
import MediaTable from '../common/util/MediaTable';
|
|
|
import PlaylistTable from '../common/util/PlaylistTable';
|
|
|
@@ -9,6 +9,7 @@ import { ConfigurationConstant, common } from '@kit.AbilityKit';
|
|
|
import { CommonConstants } from '../common/constants/CommonConstants';
|
|
|
import { SegmentButton } from '@kit.ArkUI';
|
|
|
import { SegmentButtonOptions, SegmentButtonItemTuple } from '@kit.ArkUI';
|
|
|
+import { Utility } from '../common/util/Utility';
|
|
|
|
|
|
// 工具函数:将 #RRGGBB 字符串和透明度转为 'rgba(r,g,b,a)' 字符串,深色模式下可返回深色变体
|
|
|
function themeColorWithAlpha(themeColor: string, alpha: number, isDarkMode: boolean = false): string {
|
|
|
@@ -68,6 +69,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
@State folderItems: VideoItem[] = [];
|
|
|
@State selectedFolders: Set<string> = new Set();
|
|
|
@State isFolderLoading: boolean = false;
|
|
|
+ private table: MediaTable = new MediaTable(getContext(this))
|
|
|
// SegmentButton选项配置
|
|
|
@State viewModeOptions: SegmentButtonOptions = SegmentButtonOptions.capsule({
|
|
|
buttons: viewModeButtons,
|
|
|
@@ -89,6 +91,8 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
this.allSongs = [...this.mediaKuList]
|
|
|
this.filteredSongs = [...this.mediaKuList]
|
|
|
this.loadInitialData()
|
|
|
+ this.currentPath = PreferencesUtil.getStringSync('download_path','/storage/Users/currentUser');
|
|
|
+ this.loadFile(this.currentPath)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -99,6 +103,33 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
this.hasMoreData = true
|
|
|
this.updateListData(false)
|
|
|
}
|
|
|
+ @State fileList: Array<string> = []
|
|
|
+
|
|
|
+ loadFile(curPath: string,){
|
|
|
+ this.fileList = FileUtil.listFileSync(curPath);
|
|
|
+
|
|
|
+ let directories: Array<VideoItem> = [];
|
|
|
+ let files: Array<VideoItem> = [];
|
|
|
+
|
|
|
+
|
|
|
+ for (let i = 0; i < this.fileList.length; i++) {
|
|
|
+ console.info(`The name of file: ${this.fileList[i]}`);
|
|
|
+ let path = curPath + '/' + this.fileList[i]
|
|
|
+ if (FileUtil.isDirectory(path)) {
|
|
|
+ let item: VideoItem =
|
|
|
+ new VideoItem(this.fileList[i].toString(), this.fileList[i].toString(), path, CommonConstants.TYPE_IS_DIR, 0,
|
|
|
+ '')
|
|
|
+ directories.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.table.queryByParentPath(curPath, async (result: VideoItem[]) => {
|
|
|
+
|
|
|
+ files = result;
|
|
|
+ this.folderItems = directories.concat(files);
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 搜索过滤歌曲
|