Showing
1 changed file
with
11 additions
and
8 deletions
| @@ -35,6 +35,9 @@ export struct TopNavigationComponent { | @@ -35,6 +35,9 @@ export struct TopNavigationComponent { | ||
| 35 | @Link _currentNavIndex?: number; | 35 | @Link _currentNavIndex?: number; |
| 36 | // 顶导当前选中/焦点下标 | 36 | // 顶导当前选中/焦点下标 |
| 37 | @State currentTopNavSelectedIndex: number = 0; | 37 | @State currentTopNavSelectedIndex: number = 0; |
| 38 | + /** | ||
| 39 | + * @deprecated TODO,没地方用到,是否弃用 | ||
| 40 | + */ | ||
| 38 | @State currentTopNavName: string = ''; | 41 | @State currentTopNavName: string = ''; |
| 39 | @State currentTopNavItem: TopNavDTO = {} as TopNavDTO | 42 | @State currentTopNavItem: TopNavDTO = {} as TopNavDTO |
| 40 | // 顶导数据 | 43 | // 顶导数据 |
| @@ -154,7 +157,7 @@ export struct TopNavigationComponent { | @@ -154,7 +157,7 @@ export struct TopNavigationComponent { | ||
| 154 | 157 | ||
| 155 | // 崩溃 | 158 | // 崩溃 |
| 156 | // this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[0].name : this.topNavList[0].name | 159 | // this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[0].name : this.topNavList[0].name |
| 157 | - if (this._currentNavIndex === 0 && this.myChannelList && this.myChannelList.length > 0 && | 160 | + if (this._currentNavIndex === 0 && this.myChannelList && this.myChannelList.length > 0 && this.myChannelList[0] && |
| 158 | this.myChannelList[0].name) { | 161 | this.myChannelList[0].name) { |
| 159 | this.currentTopNavName = this.myChannelList[0].name | 162 | this.currentTopNavName = this.myChannelList[0].name |
| 160 | } else if (this._currentNavIndex != 0 && this.topNavList && this.topNavList.length > 0 && this.topNavList[0].name) { | 163 | } else if (this._currentNavIndex != 0 && this.topNavList && this.topNavList.length > 0 && this.topNavList[0].name) { |
| @@ -170,19 +173,19 @@ export struct TopNavigationComponent { | @@ -170,19 +173,19 @@ export struct TopNavigationComponent { | ||
| 170 | this.currentTopNavItem = this.myChannelList[this.currentTopNavSelectedIndex] | 173 | this.currentTopNavItem = this.myChannelList[this.currentTopNavSelectedIndex] |
| 171 | } | 174 | } |
| 172 | 175 | ||
| 173 | - isBroadcast(item: TopNavDTO) { | 176 | + isBroadcast(item?: TopNavDTO) { |
| 174 | // TODO 用id channelId = '2066' | 177 | // TODO 用id channelId = '2066' |
| 175 | - return item.name === '播报' | 178 | + return item?.name === '播报' |
| 176 | } | 179 | } |
| 177 | 180 | ||
| 178 | - isLayout(item: TopNavDTO) { | 181 | + isLayout(item?: TopNavDTO) { |
| 179 | // TODO 用id channelId = '2006' | 182 | // TODO 用id channelId = '2006' |
| 180 | - return item.name === '版面' | 183 | + return item?.name === '版面' |
| 181 | } | 184 | } |
| 182 | 185 | ||
| 183 | - isSpecialChannel(item: TopNavDTO) { | 186 | + isSpecialChannel(item?: TopNavDTO) { |
| 184 | // 版面、播报,可以用这个判断 | 187 | // 版面、播报,可以用这个判断 |
| 185 | - return item.channelType === 3 | 188 | + return item?.channelType === 3 |
| 186 | } | 189 | } |
| 187 | 190 | ||
| 188 | 191 | ||
| @@ -374,7 +377,7 @@ export struct TopNavigationComponent { | @@ -374,7 +377,7 @@ export struct TopNavigationComponent { | ||
| 374 | @Builder | 377 | @Builder |
| 375 | tabBarBuilder(item: TopNavDTO, index: number) { | 378 | tabBarBuilder(item: TopNavDTO, index: number) { |
| 376 | Column() { | 379 | Column() { |
| 377 | - Text(item.name) | 380 | + Text(item?.name) |
| 378 | .fontSize($r('app.float.selected_text_size')) | 381 | .fontSize($r('app.float.selected_text_size')) |
| 379 | .fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal) | 382 | .fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal) |
| 380 | .fontColor(this.currentTopNavSelectedIndex === index ? Color.Black : "#999999") | 383 | .fontColor(this.currentTopNavSelectedIndex === index ? Color.Black : "#999999") |
-
Please register or login to post a comment