|
|
@@ -675,41 +675,65 @@ struct NewIndex {
|
|
|
.fontColor($r('app.color.text_color'))
|
|
|
.align(Alignment.Start)
|
|
|
}
|
|
|
-
|
|
|
+ @State ratioL: number = 1;
|
|
|
+ @State isRefreshing: boolean = false;
|
|
|
+ @State maxRefreshingHeight: number = 100.0;
|
|
|
+ private contentNode?: ComponentContent<Object> = undefined;
|
|
|
/**
|
|
|
* 动态生成抽屉菜单内容
|
|
|
* 根据 isShowSponsorship 展示不同菜单项
|
|
|
*/
|
|
|
@Builder
|
|
|
getDrawerView() {
|
|
|
+ Refresh({ refreshing: $$this.isRefreshing, refreshingContent: this.contentNode }) {
|
|
|
+ List({ space: 0, scroller: this.scroller }) {
|
|
|
+ ListItemGroup({ header: this.buildUserInfoCard() }) {
|
|
|
+ if(this.tabSelectedIndexes[0]==0){//分类
|
|
|
+ this.buildTabCate()
|
|
|
+ }else if(this.tabSelectedIndexes[0]==1){//歌单
|
|
|
+ this.buildPlaylistTab()
|
|
|
+ }else if(this.tabSelectedIndexes[0]==2){//网盘
|
|
|
+ this.buildCloudStorageTab()
|
|
|
+ }
|
|
|
|
|
|
- List({ space: 0, scroller: this.scroller }) {
|
|
|
- ListItemGroup({ header: this.buildUserInfoCard() }) {
|
|
|
- if(this.tabSelectedIndexes[0]==0){//分类
|
|
|
- this.buildTabCate()
|
|
|
- }else if(this.tabSelectedIndexes[0]==1){//歌单
|
|
|
- this.buildPlaylistTab()
|
|
|
- }else if(this.tabSelectedIndexes[0]==2){//网盘
|
|
|
- this.buildCloudStorageTab()
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
+ .width('86%')
|
|
|
+ .borderRadius(20)
|
|
|
+ .margin({
|
|
|
+ bottom: 20,
|
|
|
+ left: 10,
|
|
|
+ right: 10,
|
|
|
+ top: 10
|
|
|
+ })
|
|
|
+ .alignListItem(ListItemAlign.Center)
|
|
|
+ .layoutWeight(1)
|
|
|
+ .backgroundColor($r('app.color.left_draw_bg'))
|
|
|
|
|
|
+ .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
|
|
|
}
|
|
|
- .scrollBar(BarState.Off)
|
|
|
- .width('86%')
|
|
|
- .borderRadius(20)
|
|
|
- .margin({
|
|
|
- bottom: 20,
|
|
|
- left: 10,
|
|
|
- right: 10,
|
|
|
- top: 10
|
|
|
+ .pullDownRatio(this.ratioL)
|
|
|
+ .pullToRefresh(true)
|
|
|
+ .refreshOffset(0)
|
|
|
+ .onOffsetChange((offset: number) => {
|
|
|
+ // 越接近最大距离,下拉跟手系数越小。
|
|
|
+ this.ratioL = 1 - Math.pow((offset / this.maxRefreshingHeight), 3);
|
|
|
+ })
|
|
|
+ .onStateChange((refreshStatus: RefreshStatus) => {
|
|
|
+ console.info('onecold Refresh onStatueChange state is ' + refreshStatus);
|
|
|
+ })
|
|
|
+ .onRefreshing(async () => {
|
|
|
+ if(this.tabSelectedIndexes[0]==0){//分类
|
|
|
+ this.isRefreshing = false
|
|
|
+ }else if(this.tabSelectedIndexes[0]==1){//歌单
|
|
|
+ this.loadPlaylistList()
|
|
|
+ }else if(this.tabSelectedIndexes[0]==2){//网盘
|
|
|
+ this.loadWebDavAccounts()
|
|
|
+ }
|
|
|
})
|
|
|
- .alignListItem(ListItemAlign.Center)
|
|
|
- .layoutWeight(1)
|
|
|
- .backgroundColor($r('app.color.left_draw_bg'))
|
|
|
|
|
|
- .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1214,8 +1238,8 @@ struct NewIndex {
|
|
|
// 账户封面或默认图标
|
|
|
Stack() {
|
|
|
Image(account.coverPath?account.coverPath:$r('app.media.cloudDisk'))
|
|
|
- .width(20)
|
|
|
- .height(20)
|
|
|
+ .width(25)
|
|
|
+ .height(25)
|
|
|
.borderRadius(4)
|
|
|
.fillColor(this.themeColor)
|
|
|
.objectFit(ImageFit.Cover)
|
|
|
@@ -1500,8 +1524,10 @@ struct NewIndex {
|
|
|
} else {
|
|
|
LogUtil.warn('heanup NewIndex', '歌单表未初始化')
|
|
|
}
|
|
|
+ this.isRefreshing = false
|
|
|
} catch (error) {
|
|
|
LogUtil.error('heanup NewIndex', `加载歌单列表失败: ${(error as Error).message}`)
|
|
|
+ this.isRefreshing = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1542,8 +1568,10 @@ struct NewIndex {
|
|
|
await this.webdavManager.queryWebDavAccountsFromDB()
|
|
|
// 强制触发UI更新
|
|
|
this.webDavAccounts = this.webdavManager.getAllWebDavAccounts().slice()
|
|
|
+ this.isRefreshing = false
|
|
|
LogUtil.info('heanup NewIndex', `成功加载 ${this.webDavAccounts.length} 个WebDAV账户`)
|
|
|
} catch (error) {
|
|
|
+ this.isRefreshing = false
|
|
|
LogUtil.error('heanup NewIndex', `加载WebDAV账户列表失败: ${(error as Error).message}`)
|
|
|
}
|
|
|
}
|