|
@@ -62,6 +62,7 @@ export struct WebDavMainPage {
|
|
|
@StorageProp('themeColor') themeColor: string = CommonConstants.DEFAULT_THEME_COLOR;
|
|
@StorageProp('themeColor') themeColor: string = CommonConstants.DEFAULT_THEME_COLOR;
|
|
|
@StorageProp('isDarkMode') isDarkMode: boolean = false;
|
|
@StorageProp('isDarkMode') isDarkMode: boolean = false;
|
|
|
@State topRectHeight: number = 0; // 顶部安全区高度
|
|
@State topRectHeight: number = 0; // 顶部安全区高度
|
|
|
|
|
+ @State breadcrumbs:string[] = []//面包屑导航
|
|
|
|
|
|
|
|
@State visibleFoldersState: FileInfo[] = []; // 改为普通状态变量
|
|
@State visibleFoldersState: FileInfo[] = []; // 改为普通状态变量
|
|
|
|
|
|
|
@@ -115,6 +116,8 @@ export struct WebDavMainPage {
|
|
|
|
|
|
|
|
this.loadFiles()
|
|
this.loadFiles()
|
|
|
|
|
|
|
|
|
|
+ this.breadcrumbs = this.webdavManager.getBreadcrumbs();
|
|
|
|
|
+
|
|
|
// 订阅WebDAV状态变化
|
|
// 订阅WebDAV状态变化
|
|
|
this.webdavManager.subscribe(this.eventHandler);
|
|
this.webdavManager.subscribe(this.eventHandler);
|
|
|
}
|
|
}
|
|
@@ -223,12 +226,16 @@ export struct WebDavMainPage {
|
|
|
|
|
|
|
|
// 返回上级目录
|
|
// 返回上级目录
|
|
|
private goBack(): void {
|
|
private goBack(): void {
|
|
|
- this.isLoading = true;
|
|
|
|
|
- this.webdavManager.goBack()
|
|
|
|
|
- .catch((error: Error) => {
|
|
|
|
|
- Logger.error(TAG, '返回失败: ' + error.message);
|
|
|
|
|
- this.isLoading = false;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if(this.webdavManager.canGoBack()){
|
|
|
|
|
+ this.isLoading = true;
|
|
|
|
|
+ this.webdavManager.goBack()
|
|
|
|
|
+ .catch((error: Error) => {
|
|
|
|
|
+ Logger.error(TAG, '返回失败: ' + error.message);
|
|
|
|
|
+ this.isLoading = false;
|
|
|
|
|
+ });
|
|
|
|
|
+ this.breadcrumbs = this.webdavManager.getBreadcrumbs();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 切换账户
|
|
// 切换账户
|
|
@@ -361,6 +368,24 @@ export struct WebDavMainPage {
|
|
|
promptAction.showToast({ message: '播放失败' });
|
|
promptAction.showToast({ message: '播放失败' });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // 在 WebDavMainPage 类中添加以下方法
|
|
|
|
|
+ // 导航到指定层级的面包屑路径
|
|
|
|
|
+ private navigateToBreadcrumb(breadcrumbIndex: number): void {
|
|
|
|
|
+ try {
|
|
|
|
|
+ this.isLoading = true;
|
|
|
|
|
+ this.webdavManager.navigateToBreadcrumb(breadcrumbIndex).then((path: string) => {
|
|
|
|
|
+ this.webdavManager.enterFolderFromPath(path)
|
|
|
|
|
+ this.breadcrumbs = this.webdavManager.getBreadcrumbs();
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((error: Error) => {
|
|
|
|
|
+ Logger.error(TAG, '导航到面包屑路径失败: ' + error.message);
|
|
|
|
|
+ this.isLoading = false;
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ Logger.error(TAG, '导航到面包屑路径异常: ' + (error as Error).message);
|
|
|
|
|
+ this.isLoading = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
build() {
|
|
build() {
|
|
|
Column() {
|
|
Column() {
|
|
@@ -424,10 +449,6 @@ export struct WebDavMainPage {
|
|
|
.fontColor($r('app.color.index_tab_font_color'))
|
|
.fontColor($r('app.color.index_tab_font_color'))
|
|
|
.opacity(0.6)
|
|
.opacity(0.6)
|
|
|
|
|
|
|
|
- Text('点击右上角 + 添加账户')
|
|
|
|
|
- .fontSize(14)
|
|
|
|
|
- .fontColor($r('app.color.index_tab_font_color'))
|
|
|
|
|
- .opacity(0.4)
|
|
|
|
|
}
|
|
}
|
|
|
.justifyContent(FlexAlign.Center)
|
|
.justifyContent(FlexAlign.Center)
|
|
|
.width('100%')
|
|
.width('100%')
|
|
@@ -442,39 +463,45 @@ export struct WebDavMainPage {
|
|
|
|
|
|
|
|
// 加载按钮和面包屑导航
|
|
// 加载按钮和面包屑导航
|
|
|
Column({ space: 8 }) {
|
|
Column({ space: 8 }) {
|
|
|
- Row({ space: 12 }) {
|
|
|
|
|
|
|
|
|
|
- // 返回上级按钮
|
|
|
|
|
- if (this.webdavManager.canGoBack()) {
|
|
|
|
|
|
|
+ // 面包屑导航
|
|
|
|
|
+ if (this.webdavManager.currentPath !== '') {
|
|
|
|
|
+ Row({ space: 8 }) {
|
|
|
Button({ type: ButtonType.Circle }) {
|
|
Button({ type: ButtonType.Circle }) {
|
|
|
- Image($r('app.media.back'))
|
|
|
|
|
- .width(20)
|
|
|
|
|
- .height(20)
|
|
|
|
|
|
|
+ Image(this.webdavManager.canGoBack()?$r('app.media.back'):$r('app.media.cloudDisk'))
|
|
|
|
|
+ .width(15)
|
|
|
|
|
+ .height(15)
|
|
|
.fillColor(Color.White)
|
|
.fillColor(Color.White)
|
|
|
}
|
|
}
|
|
|
- .width(40)
|
|
|
|
|
- .height(40)
|
|
|
|
|
|
|
+ .width(20)
|
|
|
|
|
+ .height(20)
|
|
|
.backgroundColor(this.themeColor)
|
|
.backgroundColor(this.themeColor)
|
|
|
.onClick(() => this.goBack())
|
|
.onClick(() => this.goBack())
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- .width('100%')
|
|
|
|
|
|
|
|
|
|
- // 面包屑导航
|
|
|
|
|
- if (this.webdavManager.currentPath !== '') {
|
|
|
|
|
- Row({ space: 8 }) {
|
|
|
|
|
- Image($r('app.media.cloudDisk'))
|
|
|
|
|
- .width(16)
|
|
|
|
|
- .height(16)
|
|
|
|
|
- .fillColor($r('app.color.index_tab_font_color'))
|
|
|
|
|
- .opacity(0.6)
|
|
|
|
|
|
|
+ Row({ space: 4 }) {
|
|
|
|
|
+ ForEach(this.breadcrumbs, (crumb: string, index: number) => {
|
|
|
|
|
+ Row() {
|
|
|
|
|
+ Text(crumb)
|
|
|
|
|
+ .fontSize(15)
|
|
|
|
|
+ .fontColor(this.themeColor)
|
|
|
|
|
+ .maxLines(1)
|
|
|
|
|
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
|
|
|
+ }
|
|
|
|
|
+ .onClick(() => {
|
|
|
|
|
+ this.navigateToBreadcrumb(index);
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 添加分隔符(除了最后一个元素)
|
|
|
|
|
+ if (index < this.breadcrumbs.length - 1) {
|
|
|
|
|
+ Text('/')
|
|
|
|
|
+ .fontSize(15)
|
|
|
|
|
+ .fontColor($r('app.color.index_tab_font_color'))
|
|
|
|
|
+ .opacity(0.6)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ .layoutWeight(1)
|
|
|
|
|
|
|
|
- Text(this.webdavManager.getBreadcrumbs().join(' / '))
|
|
|
|
|
- .fontSize(13)
|
|
|
|
|
- .fontColor($r('app.color.index_tab_font_color'))
|
|
|
|
|
- .opacity(0.6)
|
|
|
|
|
- .maxLines(1)
|
|
|
|
|
- .textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
|
|
|
}
|
|
}
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
.padding({ left: 4, right: 4 })
|
|
.padding({ left: 4, right: 4 })
|
|
@@ -482,10 +509,16 @@ export struct WebDavMainPage {
|
|
|
|
|
|
|
|
// 统计信息
|
|
// 统计信息
|
|
|
if (this.webDavFiles.length > 0) {
|
|
if (this.webDavFiles.length > 0) {
|
|
|
- Text(this.visibleFoldersState.length + ' 个文件夹, ' + this.songs.length + ' 首歌曲')
|
|
|
|
|
- .fontSize(13)
|
|
|
|
|
- .fontColor($r('app.color.index_tab_font_color'))
|
|
|
|
|
- .opacity(0.6)
|
|
|
|
|
|
|
+ Row() {
|
|
|
|
|
+ Text(this.visibleFoldersState.length + ' 个文件夹, ' + this.songs.length + ' 首歌曲')
|
|
|
|
|
+ .fontSize(13)
|
|
|
|
|
+ .fontColor($r('app.color.index_tab_font_color'))
|
|
|
|
|
+ .opacity(0.6)
|
|
|
|
|
+ .layoutWeight(1)
|
|
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
|
|
+ Blank()
|
|
|
|
|
+ }
|
|
|
|
|
+ .padding({ left: 4, right: 4 })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
.width('100%')
|
|
.width('100%')
|
|
@@ -526,7 +559,7 @@ export struct WebDavMainPage {
|
|
|
}
|
|
}
|
|
|
.layoutWeight(1)
|
|
.layoutWeight(1)
|
|
|
.divider({ strokeWidth: 1, color: '#EEEEEE' })
|
|
.divider({ strokeWidth: 1, color: '#EEEEEE' })
|
|
|
- .margin({ top: 8 })
|
|
|
|
|
|
|
+ .margin({ top: 4 })
|
|
|
} else if (!this.isLoading) {
|
|
} else if (!this.isLoading) {
|
|
|
Column() {
|
|
Column() {
|
|
|
Text('暂无内容')
|
|
Text('暂无内容')
|
|
@@ -577,6 +610,7 @@ export struct WebDavMainPage {
|
|
|
.backgroundColor($r('app.color.start_window_background'))
|
|
.backgroundColor($r('app.color.start_window_background'))
|
|
|
.onClick(() => {
|
|
.onClick(() => {
|
|
|
this.enterFolder(folder);
|
|
this.enterFolder(folder);
|
|
|
|
|
+ this.breadcrumbs = this.webdavManager.getBreadcrumbs();
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|