Showing
2 changed files
with
137 additions
and
24 deletions
| 1 | { | 1 | { |
| 2 | - "lockfileVersion": 1, | 2 | + "meta": { |
| 3 | + "stableOrder": true | ||
| 4 | + }, | ||
| 5 | + "lockfileVersion": 3, | ||
| 3 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", | 6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", |
| 4 | - "specifiers": {}, | ||
| 5 | - "packages": {} | 7 | + "specifiers": { |
| 8 | + "@ohos/axios@^2.1.1": "@ohos/axios@2.2.0", | ||
| 9 | + "wdBean@../wdBean": "wdBean@../wdBean", | ||
| 10 | + "wdConstant@../../commons/wdConstant": "wdConstant@../../commons/wdConstant", | ||
| 11 | + "wdJsBridge@../../commons/wdJsBridge": "wdJsBridge@../../commons/wdJsBridge", | ||
| 12 | + "wdKit@../../commons/wdKit": "wdKit@../../commons/wdKit", | ||
| 13 | + "wdLogin@../wdLogin": "wdLogin@../wdLogin", | ||
| 14 | + "wdNetwork@../../commons/wdNetwork": "wdNetwork@../../commons/wdNetwork", | ||
| 15 | + "wdPlayer@../wdPlayer": "wdPlayer@../wdPlayer", | ||
| 16 | + "wdRouter@../../commons/wdRouter": "wdRouter@../../commons/wdRouter", | ||
| 17 | + "wdWebComponent@../../commons/wdWebComponent": "wdWebComponent@../../commons/wdWebComponent" | ||
| 18 | + }, | ||
| 19 | + "packages": { | ||
| 20 | + "@ohos/axios@2.2.0": { | ||
| 21 | + "name": "@ohos/axios", | ||
| 22 | + "integrity": "sha512-v1QBWk6DfcN8wUW3D0ieFbHTR1taSI5cOgxp5l6B5cegXuNYhSc8ggKlAIXe6h/14LsfM+NW0ZGfSXcNEIM5yA==", | ||
| 23 | + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/axios/-/axios-2.2.0.har", | ||
| 24 | + "registryType": "ohpm" | ||
| 25 | + }, | ||
| 26 | + "wdBean@../wdBean": { | ||
| 27 | + "name": "wdbean", | ||
| 28 | + "resolved": "../wdBean", | ||
| 29 | + "registryType": "local" | ||
| 30 | + }, | ||
| 31 | + "wdConstant@../../commons/wdConstant": { | ||
| 32 | + "name": "wdconstant", | ||
| 33 | + "resolved": "../../commons/wdConstant", | ||
| 34 | + "registryType": "local" | ||
| 35 | + }, | ||
| 36 | + "wdJsBridge@../../commons/wdJsBridge": { | ||
| 37 | + "name": "wdjsbridge", | ||
| 38 | + "resolved": "../../commons/wdJsBridge", | ||
| 39 | + "registryType": "local" | ||
| 40 | + }, | ||
| 41 | + "wdKit@../../commons/wdKit": { | ||
| 42 | + "name": "wdkit", | ||
| 43 | + "resolved": "../../commons/wdKit", | ||
| 44 | + "registryType": "local" | ||
| 45 | + }, | ||
| 46 | + "wdLogin@../wdLogin": { | ||
| 47 | + "name": "wdlogin", | ||
| 48 | + "resolved": "../wdLogin", | ||
| 49 | + "registryType": "local", | ||
| 50 | + "dependencies": { | ||
| 51 | + "wdConstant": "file:../../commons/wdConstant", | ||
| 52 | + "wdKit": "file:../../commons/wdKit", | ||
| 53 | + "wdWebComponent": "file:../../commons/wdWebComponent", | ||
| 54 | + "wdBean": "file:../../features/wdBean", | ||
| 55 | + "wdRouter": "file:../../commons/wdRouter", | ||
| 56 | + "wdNetwork": "file:../../commons/wdNetwork" | ||
| 57 | + } | ||
| 58 | + }, | ||
| 59 | + "wdNetwork@../../commons/wdNetwork": { | ||
| 60 | + "name": "wdnetwork", | ||
| 61 | + "resolved": "../../commons/wdNetwork", | ||
| 62 | + "registryType": "local", | ||
| 63 | + "dependencies": { | ||
| 64 | + "wdConstant": "file:../wdConstant", | ||
| 65 | + "wdKit": "file:../wdKit", | ||
| 66 | + "@ohos/axios": "^2.1.1" | ||
| 67 | + } | ||
| 68 | + }, | ||
| 69 | + "wdPlayer@../wdPlayer": { | ||
| 70 | + "name": "wdplayer", | ||
| 71 | + "resolved": "../wdPlayer", | ||
| 72 | + "registryType": "local", | ||
| 73 | + "dependencies": { | ||
| 74 | + "wdKit": "file:../../commons/wdKit" | ||
| 75 | + } | ||
| 76 | + }, | ||
| 77 | + "wdRouter@../../commons/wdRouter": { | ||
| 78 | + "name": "wdrouter", | ||
| 79 | + "resolved": "../../commons/wdRouter", | ||
| 80 | + "registryType": "local", | ||
| 81 | + "dependencies": { | ||
| 82 | + "wdKit": "file:../wdKit", | ||
| 83 | + "wdBean": "file:../../features/wdBean" | ||
| 84 | + } | ||
| 85 | + }, | ||
| 86 | + "wdWebComponent@../../commons/wdWebComponent": { | ||
| 87 | + "name": "wdwebcomponent", | ||
| 88 | + "resolved": "../../commons/wdWebComponent", | ||
| 89 | + "registryType": "local", | ||
| 90 | + "dependencies": { | ||
| 91 | + "wdConstant": "file:../wdConstant", | ||
| 92 | + "wdKit": "file:../wdKit", | ||
| 93 | + "wdJsBridge": "file:../wdJsBridge", | ||
| 94 | + "wdBean": "file:../../features/wdBean", | ||
| 95 | + "wdRouter": "file:../wdRouter" | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + } | ||
| 6 | } | 99 | } |
| @@ -6,6 +6,7 @@ import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout' | @@ -6,6 +6,7 @@ import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout' | ||
| 6 | 6 | ||
| 7 | const TAG = 'TopNavigationComponent'; | 7 | const TAG = 'TopNavigationComponent'; |
| 8 | 8 | ||
| 9 | +PersistentStorage.persistProp('channelIds', ''); | ||
| 9 | /** | 10 | /** |
| 10 | * 顶部页签导航栏/顶导 | 11 | * 顶部页签导航栏/顶导 |
| 11 | */ | 12 | */ |
| @@ -18,8 +19,10 @@ export struct TopNavigationComponent { | @@ -18,8 +19,10 @@ export struct TopNavigationComponent { | ||
| 18 | // 顶导数据 | 19 | // 顶导数据 |
| 19 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] | 20 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] |
| 20 | @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); | 21 | @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); |
| 21 | - //我的频道id缓存列表 | ||
| 22 | - @State channelIds: number[] = [] | 22 | + //我的频道id列表 |
| 23 | + @State @Watch('onChannelIdsUpdate') channelIds: number[] = [] | ||
| 24 | + //本地缓存频道id列表 | ||
| 25 | + @StorageProp('channelIds') storageChannelIds: string = '' | ||
| 23 | // 我的频道列表 | 26 | // 我的频道列表 |
| 24 | @State myChannelList: TopNavDTO[] = [] | 27 | @State myChannelList: TopNavDTO[] = [] |
| 25 | // 更多频道列表 | 28 | // 更多频道列表 |
| @@ -30,6 +33,8 @@ export struct TopNavigationComponent { | @@ -30,6 +33,8 @@ export struct TopNavigationComponent { | ||
| 30 | 33 | ||
| 31 | //处理接口顶导数据 | 34 | //处理接口顶导数据 |
| 32 | topNavListHandle() { | 35 | topNavListHandle() { |
| 36 | + let _channelIds: number [] = [] | ||
| 37 | + let _myChannelList : TopNavDTO [] = [] | ||
| 33 | let defaultMyChannelList: TopNavDTO[] = [] | 38 | let defaultMyChannelList: TopNavDTO[] = [] |
| 34 | let handledTopNavList = [...this.topNavList] | 39 | let handledTopNavList = [...this.topNavList] |
| 35 | handledTopNavList.sort((a, b) => { | 40 | handledTopNavList.sort((a, b) => { |
| @@ -40,6 +45,7 @@ export struct TopNavigationComponent { | @@ -40,6 +45,7 @@ export struct TopNavigationComponent { | ||
| 40 | defaultMyChannelList.push(item); | 45 | defaultMyChannelList.push(item); |
| 41 | } | 46 | } |
| 42 | }) | 47 | }) |
| 48 | + | ||
| 43 | defaultMyChannelList.forEach(item => { | 49 | defaultMyChannelList.forEach(item => { |
| 44 | item.myChannel = '1' | 50 | item.myChannel = '1' |
| 45 | if (item.defaultPermitted === 1) { | 51 | if (item.defaultPermitted === 1) { |
| @@ -50,7 +56,6 @@ export struct TopNavigationComponent { | @@ -50,7 +56,6 @@ export struct TopNavigationComponent { | ||
| 50 | handledTopNavList.splice(index, 1) | 56 | handledTopNavList.splice(index, 1) |
| 51 | } | 57 | } |
| 52 | }) | 58 | }) |
| 53 | - | ||
| 54 | handledTopNavList.unshift(...defaultMyChannelList) | 59 | handledTopNavList.unshift(...defaultMyChannelList) |
| 55 | handledTopNavList.forEach((item, index) => { | 60 | handledTopNavList.forEach((item, index) => { |
| 56 | if (item.channelType === 2) { | 61 | if (item.channelType === 2) { |
| @@ -66,9 +71,10 @@ export struct TopNavigationComponent { | @@ -66,9 +71,10 @@ export struct TopNavigationComponent { | ||
| 66 | } | 71 | } |
| 67 | } | 72 | } |
| 68 | 73 | ||
| 74 | + //频道分类 | ||
| 69 | if (item.myChannel === '1') { | 75 | if (item.myChannel === '1') { |
| 70 | - this.myChannelList.push(item) | ||
| 71 | - this.channelIds.push(item.channelId) | 76 | + _myChannelList.push(item) |
| 77 | + _channelIds.push(item.channelId) | ||
| 72 | } | 78 | } |
| 73 | if (item.moreChannel === '1') { | 79 | if (item.moreChannel === '1') { |
| 74 | this.moreChannelList.push(item) | 80 | this.moreChannelList.push(item) |
| @@ -76,10 +82,13 @@ export struct TopNavigationComponent { | @@ -76,10 +82,13 @@ export struct TopNavigationComponent { | ||
| 76 | if (item.localChannel === '1') { | 82 | if (item.localChannel === '1') { |
| 77 | this.localChannelList.push(item) | 83 | this.localChannelList.push(item) |
| 78 | } | 84 | } |
| 85 | + | ||
| 79 | }) | 86 | }) |
| 87 | + this.channelIds = _channelIds | ||
| 88 | + this.myChannelList = _myChannelList | ||
| 80 | } | 89 | } |
| 81 | 90 | ||
| 82 | - isBroadcast (item: TopNavDTO) { | 91 | + isBroadcast(item: TopNavDTO) { |
| 83 | return item.name === '播报' | 92 | return item.name === '播报' |
| 84 | } | 93 | } |
| 85 | 94 | ||
| @@ -170,13 +179,14 @@ export struct TopNavigationComponent { | @@ -170,13 +179,14 @@ export struct TopNavigationComponent { | ||
| 170 | .width('100%') | 179 | .width('100%') |
| 171 | .height(40) | 180 | .height(40) |
| 172 | .visibility(this._currentNavIndex == 0 ? Visibility.Visible : Visibility.None) | 181 | .visibility(this._currentNavIndex == 0 ? Visibility.Visible : Visibility.None) |
| 182 | + | ||
| 173 | // 频道分类list | 183 | // 频道分类list |
| 174 | Stack({ alignContent: Alignment.TopEnd }) { | 184 | Stack({ alignContent: Alignment.TopEnd }) { |
| 175 | 185 | ||
| 176 | Tabs({ controller: this.tabsController }) { | 186 | Tabs({ controller: this.tabsController }) { |
| 177 | - ForEach(this.myChannelList, (navItem: TopNavDTO, index: number) => { | 187 | + ForEach(this._currentNavIndex === 0 ? this.myChannelList : this.topNavList, (navItem: TopNavDTO, index: number) => { |
| 178 | TabContent() { | 188 | TabContent() { |
| 179 | - if(!this.isBroadcast(navItem)) { | 189 | + if (!this.isBroadcast(navItem)) { |
| 180 | PageComponent({ | 190 | PageComponent({ |
| 181 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | 191 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, |
| 182 | navIndex: index, | 192 | navIndex: index, |
| @@ -193,7 +203,7 @@ export struct TopNavigationComponent { | @@ -193,7 +203,7 @@ export struct TopNavigationComponent { | ||
| 193 | .vertical(false) | 203 | .vertical(false) |
| 194 | .onChange((index: number) => { | 204 | .onChange((index: number) => { |
| 195 | Logger.info(TAG, `onChange index : ${index}`); | 205 | Logger.info(TAG, `onChange index : ${index}`); |
| 196 | - if(!this.isBroadcast(this.myChannelList[index])) { | 206 | + if (!this.isBroadcast(this.myChannelList[index])) { |
| 197 | this.currentTopNavSelectedIndex = index; | 207 | this.currentTopNavSelectedIndex = index; |
| 198 | } else { | 208 | } else { |
| 199 | // 跳转到播报页面 | 209 | // 跳转到播报页面 |
| @@ -208,17 +218,20 @@ export struct TopNavigationComponent { | @@ -208,17 +218,20 @@ export struct TopNavigationComponent { | ||
| 208 | this.tabsController.changeIndex(this.currentTopNavSelectedIndex) | 218 | this.tabsController.changeIndex(this.currentTopNavSelectedIndex) |
| 209 | } | 219 | } |
| 210 | }) | 220 | }) |
| 221 | + | ||
| 211 | // 分类列表最右侧频道设置 | 222 | // 分类列表最右侧频道设置 |
| 212 | - ChannelSubscriptionLayout({ | ||
| 213 | - currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | ||
| 214 | - myChannelList: $myChannelList, | ||
| 215 | - moreChannelList: $moreChannelList, | ||
| 216 | - localChannelList: $localChannelList, | ||
| 217 | - channelIds: $channelIds, | ||
| 218 | - changeTab: (index) => { | ||
| 219 | - this.tabsController.changeIndex(index) | ||
| 220 | - } | ||
| 221 | - }) | 223 | + if(this._currentNavIndex === 0){ |
| 224 | + ChannelSubscriptionLayout({ | ||
| 225 | + currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | ||
| 226 | + myChannelList: $myChannelList, | ||
| 227 | + moreChannelList: $moreChannelList, | ||
| 228 | + localChannelList: $localChannelList, | ||
| 229 | + channelIds: $channelIds, | ||
| 230 | + changeTab: (index) => { | ||
| 231 | + this.tabsController.changeIndex(index) | ||
| 232 | + } | ||
| 233 | + }) | ||
| 234 | + } | ||
| 222 | } | 235 | } |
| 223 | 236 | ||
| 224 | } | 237 | } |
| @@ -257,8 +270,15 @@ export struct TopNavigationComponent { | @@ -257,8 +270,15 @@ export struct TopNavigationComponent { | ||
| 257 | } | 270 | } |
| 258 | 271 | ||
| 259 | aboutToAppear() { | 272 | aboutToAppear() { |
| 260 | - this.topNavListHandle() | ||
| 261 | - Logger.info(TAG, `aboutToAppear this.topNavList : ${JSON.stringify(this.topNavList)}`); | 273 | + if(this._currentNavIndex === 0){ |
| 274 | + this.topNavListHandle() | ||
| 275 | + } | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + onChannelIdsUpdate() { | ||
| 279 | + AppStorage.set('channelIds', this.channelIds.join(',')) | ||
| 280 | + console.log(`PersistentStorage channelIds: ${this.channelIds}`) | ||
| 281 | + console.log(`PersistentStorage aboutToAppear: ${this.storageChannelIds}`) | ||
| 262 | } | 282 | } |
| 263 | 283 | ||
| 264 | onTopNavigationDataUpdated() { | 284 | onTopNavigationDataUpdated() { |
-
Please register or login to post a comment