|
@@ -11,6 +11,7 @@ import { display } from '@kit.ArkUI';
|
|
|
import { FileInfo } from '../viewmodel/FileInfo';
|
|
import { FileInfo } from '../viewmodel/FileInfo';
|
|
|
import { emitter } from '@kit.BasicServicesKit';
|
|
import { emitter } from '@kit.BasicServicesKit';
|
|
|
import { EventConstants } from '../common/constants/EventConstants';
|
|
import { EventConstants } from '../common/constants/EventConstants';
|
|
|
|
|
+import { LazyDataSource } from '../common/util/LazyDataSource';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 歌单播放事件数据
|
|
* 歌单播放事件数据
|
|
@@ -56,7 +57,10 @@ export struct WebDavMainPage {
|
|
|
@State accounts: WebDavAccount[] = [];
|
|
@State accounts: WebDavAccount[] = [];
|
|
|
@Prop @Watch('onSwitchAccount') selectedAccount: WebDavAccount;
|
|
@Prop @Watch('onSwitchAccount') selectedAccount: WebDavAccount;
|
|
|
@State songs: Song[] = [];
|
|
@State songs: Song[] = [];
|
|
|
|
|
+ @State dataSource:LazyDataSource<Song> = new LazyDataSource(this.songs)
|
|
|
@Link mType: number;
|
|
@Link mType: number;
|
|
|
|
|
+ @Link offsetX: number;
|
|
|
|
|
+ @Link isShowDrawer: boolean;
|
|
|
@State isLoading: boolean = false;
|
|
@State isLoading: boolean = false;
|
|
|
@State webDavFiles: FileInfo[] = []; // 直接在页面中保存文件列表副本
|
|
@State webDavFiles: FileInfo[] = []; // 直接在页面中保存文件列表副本
|
|
|
@StorageProp('themeColor') themeColor: string = CommonConstants.DEFAULT_THEME_COLOR;
|
|
@StorageProp('themeColor') themeColor: string = CommonConstants.DEFAULT_THEME_COLOR;
|
|
@@ -69,6 +73,7 @@ export struct WebDavMainPage {
|
|
|
onSwitchAccount(){
|
|
onSwitchAccount(){
|
|
|
console.log('onecold 切换账户:', this.selectedAccount.name);
|
|
console.log('onecold 切换账户:', this.selectedAccount.name);
|
|
|
this.songs = [];
|
|
this.songs = [];
|
|
|
|
|
+ this.updateListData(this.songs)
|
|
|
this.isLoading = true;
|
|
this.isLoading = true;
|
|
|
this.webdavManager.loadFilesInfoFromAccount(this.selectedAccount)
|
|
this.webdavManager.loadFilesInfoFromAccount(this.selectedAccount)
|
|
|
.catch((error: Error) => {
|
|
.catch((error: Error) => {
|
|
@@ -78,6 +83,10 @@ export struct WebDavMainPage {
|
|
|
this.breadcrumbs = this.webdavManager.getBreadcrumbs();
|
|
this.breadcrumbs = this.webdavManager.getBreadcrumbs();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ updateListData(mList:Array<Song>){
|
|
|
|
|
+ this.dataSource.pushArrayData(mList)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 更新可见文件夹列表
|
|
// 更新可见文件夹列表
|
|
|
private updateVisibleFolders(): void {
|
|
private updateVisibleFolders(): void {
|
|
|
try {
|
|
try {
|
|
@@ -157,6 +166,7 @@ export struct WebDavMainPage {
|
|
|
switch (event) {
|
|
switch (event) {
|
|
|
case WebdavManagerStates.LoadFilesInfoSucceed:
|
|
case WebdavManagerStates.LoadFilesInfoSucceed:
|
|
|
this.songs = this.webdavManager.webDavSongs;
|
|
this.songs = this.webdavManager.webDavSongs;
|
|
|
|
|
+ this.updateListData(this.songs)
|
|
|
// 直接引用webdavManager的数组,避免@Observed序列化问题
|
|
// 直接引用webdavManager的数组,避免@Observed序列化问题
|
|
|
this.webDavFiles = this.webdavManager.webDavFiles;
|
|
this.webDavFiles = this.webdavManager.webDavFiles;
|
|
|
this.isLoading = false;
|
|
this.isLoading = false;
|
|
@@ -252,6 +262,7 @@ export struct WebDavMainPage {
|
|
|
private switchAccount(account: WebDavAccount): void {
|
|
private switchAccount(account: WebDavAccount): void {
|
|
|
this.selectedAccount = account;
|
|
this.selectedAccount = account;
|
|
|
this.songs = [];
|
|
this.songs = [];
|
|
|
|
|
+ this.updateListData(this.songs)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -363,15 +374,15 @@ export struct WebDavMainPage {
|
|
|
emitter.emit(eventPlaylistPlay, eventData);
|
|
emitter.emit(eventPlaylistPlay, eventData);
|
|
|
|
|
|
|
|
// 跳转到首页播放器
|
|
// 跳转到首页播放器
|
|
|
- // router.pushUrl({
|
|
|
|
|
- // url: 'pages/NewIndex',
|
|
|
|
|
- // params: {
|
|
|
|
|
- // fromWebDAV: true
|
|
|
|
|
- // }
|
|
|
|
|
- // }).catch((error: Error) => {
|
|
|
|
|
- // Logger.error(TAG, '跳转首页失败: ' + error.message);
|
|
|
|
|
- // this.getUIContext().getPromptAction().showToast({ message: '跳转失败' });
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ router.pushUrl({
|
|
|
|
|
+ url: 'pages/NewIndex',
|
|
|
|
|
+ params: {
|
|
|
|
|
+ fromWebDAV: true
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch((error: Error) => {
|
|
|
|
|
+ Logger.error(TAG, '跳转首页失败: ' + error.message);
|
|
|
|
|
+ this.getUIContext().getPromptAction().showToast({ message: '跳转失败' });
|
|
|
|
|
+ });
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
const err = error as Error;
|
|
const err = error as Error;
|
|
|
Logger.error(TAG, '播放歌曲失败: ' + err.message);
|
|
Logger.error(TAG, '播放歌曲失败: ' + err.message);
|
|
@@ -408,13 +419,15 @@ export struct WebDavMainPage {
|
|
|
|
|
|
|
|
// 标题栏
|
|
// 标题栏
|
|
|
Row() {
|
|
Row() {
|
|
|
- Image($r('app.media.back'))
|
|
|
|
|
|
|
+ Image($r('app.media.menu'))
|
|
|
.width(24)
|
|
.width(24)
|
|
|
.height(24)
|
|
.height(24)
|
|
|
.margin({ left: 12, right: 8 })
|
|
.margin({ left: 12, right: 8 })
|
|
|
.onClick(() => {
|
|
.onClick(() => {
|
|
|
this.getUIContext()?.animateTo({ duration: 555 }, () => {
|
|
this.getUIContext()?.animateTo({ duration: 555 }, () => {
|
|
|
- this.mType =0
|
|
|
|
|
|
|
+ // this.mType =0
|
|
|
|
|
+ this.isShowDrawer = !this.isShowDrawer
|
|
|
|
|
+ this.offsetX = 0
|
|
|
})
|
|
})
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -567,7 +580,7 @@ export struct WebDavMainPage {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 显示歌曲
|
|
// 显示歌曲
|
|
|
- ForEach(this.songs, (song: Song, index: number) => {
|
|
|
|
|
|
|
+ LazyForEach(this.dataSource, (song: Song, index: number) => {
|
|
|
ListItem() {
|
|
ListItem() {
|
|
|
this.buildSongItem(song, index)
|
|
this.buildSongItem(song, index)
|
|
|
}
|
|
}
|
|
@@ -599,10 +612,10 @@ export struct WebDavMainPage {
|
|
|
@Builder
|
|
@Builder
|
|
|
buildFolderItem(folder: FileInfo) {
|
|
buildFolderItem(folder: FileInfo) {
|
|
|
Row({ space: 2 }) {
|
|
Row({ space: 2 }) {
|
|
|
- Image($r('app.media.dir'))
|
|
|
|
|
- .width(32)
|
|
|
|
|
- .height(32)
|
|
|
|
|
- .fillColor(this.themeColor)
|
|
|
|
|
|
|
+ SymbolGlyph($r('sys.symbol.folder'))
|
|
|
|
|
+ .fontSize(48)
|
|
|
|
|
+ .fontColor([this.themeColor])
|
|
|
|
|
+ .alignSelf(ItemAlign.Center)
|
|
|
.margin({ left: 8, right: 6 })
|
|
.margin({ left: 8, right: 6 })
|
|
|
|
|
|
|
|
// 文件夹信息
|
|
// 文件夹信息
|
|
@@ -635,18 +648,10 @@ export struct WebDavMainPage {
|
|
|
buildSongItem(song: Song, index: number) {
|
|
buildSongItem(song: Song, index: number) {
|
|
|
Row({ space: 12 }) {
|
|
Row({ space: 12 }) {
|
|
|
// 序号
|
|
// 序号
|
|
|
- // Text((index + 1).toString())
|
|
|
|
|
- // .fontSize(14)
|
|
|
|
|
- // .fontColor($r('app.color.index_tab_font_color'))
|
|
|
|
|
- // .opacity(0.6)
|
|
|
|
|
- // .width(30)
|
|
|
|
|
- // .textAlign(TextAlign.Center)
|
|
|
|
|
-
|
|
|
|
|
// 歌曲封面
|
|
// 歌曲封面
|
|
|
Image(song.img)
|
|
Image(song.img)
|
|
|
.width(48)
|
|
.width(48)
|
|
|
.height(48)
|
|
.height(48)
|
|
|
- .alt($r('app.media.new_music'))
|
|
|
|
|
.borderRadius(4)
|
|
.borderRadius(4)
|
|
|
.objectFit(ImageFit.Cover)
|
|
.objectFit(ImageFit.Cover)
|
|
|
|
|
|