Showing
3 changed files
with
24 additions
and
19 deletions
| @@ -20,12 +20,10 @@ struct ChannelSubscriptionLayout { | @@ -20,12 +20,10 @@ struct ChannelSubscriptionLayout { | ||
| 20 | //当前选中的频道 | 20 | //当前选中的频道 |
| 21 | @Link currentTopNavSelectedIndex: number; | 21 | @Link currentTopNavSelectedIndex: number; |
| 22 | @Prop homeChannelList: TopNavDTO [] | 22 | @Prop homeChannelList: TopNavDTO [] |
| 23 | - @Prop indexSettingChannelId: number | ||
| 24 | @Link myChannelList: TopNavDTO [] | 23 | @Link myChannelList: TopNavDTO [] |
| 25 | @Link moreChannelList: TopNavDTO [] | 24 | @Link moreChannelList: TopNavDTO [] |
| 26 | @Link localChannelList: TopNavDTO [] | 25 | @Link localChannelList: TopNavDTO [] |
| 27 | @Link channelIds: number [] | 26 | @Link channelIds: number [] |
| 28 | - @StorageLink('channelIds') storeChannelIds: string = '' | ||
| 29 | @State isShow: boolean = false | 27 | @State isShow: boolean = false |
| 30 | @State dragItem: number = -1 | 28 | @State dragItem: number = -1 |
| 31 | private dragRefOffsetX: number = 0 | 29 | private dragRefOffsetX: number = 0 |
| @@ -34,7 +32,7 @@ struct ChannelSubscriptionLayout { | @@ -34,7 +32,7 @@ struct ChannelSubscriptionLayout { | ||
| 34 | @State offsetY: number = 0 | 32 | @State offsetY: number = 0 |
| 35 | private FIX_VP_X: number = 80 | 33 | private FIX_VP_X: number = 80 |
| 36 | private FIX_VP_Y: number = 48 | 34 | private FIX_VP_Y: number = 48 |
| 37 | - @State indexSettingTabIndex: number = 0 | 35 | + @State indexSettingChannelId: number = AppStorage.get<number>('indexSettingChannelId') || 2002 |
| 38 | @State isEditIng: boolean = false | 36 | @State isEditIng: boolean = false |
| 39 | @State currentTopNavSelectedItem: TopNavDTO = {} as TopNavDTO | 37 | @State currentTopNavSelectedItem: TopNavDTO = {} as TopNavDTO |
| 40 | changeTab: (index: number) => void = () => { | 38 | changeTab: (index: number) => void = () => { |
| @@ -50,13 +48,13 @@ struct ChannelSubscriptionLayout { | @@ -50,13 +48,13 @@ struct ChannelSubscriptionLayout { | ||
| 50 | let channelIdTmp = this.channelIds.splice(index1, 1) | 48 | let channelIdTmp = this.channelIds.splice(index1, 1) |
| 51 | this.myChannelList.splice(index2, 0, tmp[0]) | 49 | this.myChannelList.splice(index2, 0, tmp[0]) |
| 52 | this.channelIds.splice(index2, 0, channelIdTmp[0]) | 50 | this.channelIds.splice(index2, 0, channelIdTmp[0]) |
| 53 | - this.storeChannelIds = this.channelIds.join(',') | 51 | + AppStorage.setOrCreate('channelIds', this.channelIds.join(',')) |
| 54 | } | 52 | } |
| 55 | //删除频道 | 53 | //删除频道 |
| 56 | delChannelItem(index: number){ | 54 | delChannelItem(index: number){ |
| 57 | let item = this.myChannelList.splice(index, 1)[0] | 55 | let item = this.myChannelList.splice(index, 1)[0] |
| 58 | this.channelIds.splice(index, 1) | 56 | this.channelIds.splice(index, 1) |
| 59 | - this.storeChannelIds = this.channelIds.join(',') | 57 | + AppStorage.setOrCreate('channelIds', this.channelIds.join(',')) |
| 60 | if (item.moreChannel === '1') { | 58 | if (item.moreChannel === '1') { |
| 61 | this.moreChannelList.unshift(item) | 59 | this.moreChannelList.unshift(item) |
| 62 | } | 60 | } |
| @@ -68,7 +66,7 @@ struct ChannelSubscriptionLayout { | @@ -68,7 +66,7 @@ struct ChannelSubscriptionLayout { | ||
| 68 | addChannelItem(item: TopNavDTO){ | 66 | addChannelItem(item: TopNavDTO){ |
| 69 | this.channelIds.push(item.channelId) | 67 | this.channelIds.push(item.channelId) |
| 70 | this.myChannelList.push(item) | 68 | this.myChannelList.push(item) |
| 71 | - this.storeChannelIds = this.channelIds.join(',') | 69 | + AppStorage.setOrCreate('channelIds', this.channelIds.join(',')) |
| 72 | } | 70 | } |
| 73 | 71 | ||
| 74 | itemMove(index: number, newIndex: number): void { | 72 | itemMove(index: number, newIndex: number): void { |
| @@ -265,6 +263,7 @@ struct ChannelSubscriptionLayout { | @@ -265,6 +263,7 @@ struct ChannelSubscriptionLayout { | ||
| 265 | .alignContent(Alignment.Start) | 263 | .alignContent(Alignment.Start) |
| 266 | .height(36) | 264 | .height(36) |
| 267 | .onClick(() => { | 265 | .onClick(() => { |
| 266 | + this.indexSettingChannelId = item.channelId | ||
| 268 | AppStorage.set('indexSettingChannelId', item.channelId) | 267 | AppStorage.set('indexSettingChannelId', item.channelId) |
| 269 | }) | 268 | }) |
| 270 | }) | 269 | }) |
| @@ -13,9 +13,6 @@ import DailyPaperTopicModel from '../../model/DailyPaperTopicModel' | @@ -13,9 +13,6 @@ import DailyPaperTopicModel from '../../model/DailyPaperTopicModel' | ||
| 13 | 13 | ||
| 14 | const TAG = 'TopNavigationComponent'; | 14 | const TAG = 'TopNavigationComponent'; |
| 15 | 15 | ||
| 16 | -PersistentStorage.persistProp('channelIds', ''); | ||
| 17 | -PersistentStorage.persistProp('indexSettingChannelId', 2002); | ||
| 18 | - | ||
| 19 | const storage = LocalStorage.getShared(); | 16 | const storage = LocalStorage.getShared(); |
| 20 | 17 | ||
| 21 | /** | 18 | /** |
| @@ -48,11 +45,11 @@ export struct TopNavigationComponentNew { | @@ -48,11 +45,11 @@ export struct TopNavigationComponentNew { | ||
| 48 | @State currentTopNavSelectedIndex: number = 0; | 45 | @State currentTopNavSelectedIndex: number = 0; |
| 49 | // 顶导数据 | 46 | // 顶导数据 |
| 50 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] | 47 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] |
| 51 | - @StorageProp('indexSettingChannelId') indexSettingChannelId: number = 2002 | 48 | + @State indexSettingChannelId: number = AppStorage.get<number>('indexSettingChannelId') || 2002 |
| 52 | //我的频道id列表 | 49 | //我的频道id列表 |
| 53 | @State channelIds: number[] = [] | 50 | @State channelIds: number[] = [] |
| 54 | //本地缓存频道id列表 | 51 | //本地缓存频道id列表 |
| 55 | - @StorageProp('channelIds') storageChannelIds: string = '' | 52 | + @State storageChannelIds: string = AppStorage.get<string>('channelIds') || '' |
| 56 | @State homeChannelList: TopNavDTO[] = [] | 53 | @State homeChannelList: TopNavDTO[] = [] |
| 57 | // 我的频道列表 | 54 | // 我的频道列表 |
| 58 | @State myChannelList: TopNavDTO[] = [] | 55 | @State myChannelList: TopNavDTO[] = [] |
| @@ -191,7 +188,6 @@ export struct TopNavigationComponentNew { | @@ -191,7 +188,6 @@ export struct TopNavigationComponentNew { | ||
| 191 | this.topBar() | 188 | this.topBar() |
| 192 | ChannelSubscriptionLayout({ | 189 | ChannelSubscriptionLayout({ |
| 193 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | 190 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, |
| 194 | - indexSettingChannelId: this.indexSettingChannelId, | ||
| 195 | homeChannelList: this.homeChannelList, | 191 | homeChannelList: this.homeChannelList, |
| 196 | myChannelList: $myChannelList, | 192 | myChannelList: $myChannelList, |
| 197 | moreChannelList: $moreChannelList, | 193 | moreChannelList: $moreChannelList, |
| @@ -406,18 +402,29 @@ export struct TopNavigationComponentNew { | @@ -406,18 +402,29 @@ export struct TopNavigationComponentNew { | ||
| 406 | 402 | ||
| 407 | //频道分类 | 403 | //频道分类 |
| 408 | if (item.name !== '播报') { //暂时隐藏播报 | 404 | if (item.name !== '播报') { //暂时隐藏播报 |
| 409 | - if (item.myChannel === '1') { | 405 | + if (item.myChannel === '1' && !this.storageChannelIds) { |
| 410 | _myChannelList.push(item) | 406 | _myChannelList.push(item) |
| 411 | _channelIds.push(item.channelId) | 407 | _channelIds.push(item.channelId) |
| 412 | - } else if (item.moreChannel === '1') { | 408 | + } |
| 409 | + if (item.moreChannel === '1') { | ||
| 413 | this.moreChannelList.push(item) | 410 | this.moreChannelList.push(item) |
| 414 | - } else if (item.localChannel === '1' && item.myChannel !== '1') { | 411 | + } |
| 412 | + if (item.localChannel === '1' && item.myChannel !== '1') { | ||
| 415 | this.localChannelList.push(item) | 413 | this.localChannelList.push(item) |
| 416 | } | 414 | } |
| 417 | } | 415 | } |
| 418 | 416 | ||
| 419 | }) | 417 | }) |
| 420 | 418 | ||
| 419 | + if(this.storageChannelIds){ | ||
| 420 | + _storageChannelIds.forEach((_item:string)=>{ | ||
| 421 | + let index = defaultList.findIndex(ele => Number(_item) === ele.channelId) | ||
| 422 | + if(index > -1){ | ||
| 423 | + _myChannelList.push(defaultList[index]) | ||
| 424 | + _channelIds.push(defaultList[index].channelId) | ||
| 425 | + } | ||
| 426 | + }) | ||
| 427 | + } | ||
| 421 | if (cityName) { | 428 | if (cityName) { |
| 422 | let index = _myChannelList.findIndex(ele => cityName.includes(ele.name)) | 429 | let index = _myChannelList.findIndex(ele => cityName.includes(ele.name)) |
| 423 | const localChannelitem = _myChannelList.splice(index, 1)[0]; | 430 | const localChannelitem = _myChannelList.splice(index, 1)[0]; |
| @@ -466,10 +473,6 @@ export struct TopNavigationComponentNew { | @@ -466,10 +473,6 @@ export struct TopNavigationComponentNew { | ||
| 466 | this.changePage(this.currentTopNavSelectedIndex) | 473 | this.changePage(this.currentTopNavSelectedIndex) |
| 467 | } | 474 | } |
| 468 | 475 | ||
| 469 | - aboutToDisappear() { | ||
| 470 | - AppStorage.set('channelIds', this.channelIds.join(',')) | ||
| 471 | - } | ||
| 472 | - | ||
| 473 | onTopNavigationDataUpdated() { | 476 | onTopNavigationDataUpdated() { |
| 474 | Logger.info(TAG, | 477 | Logger.info(TAG, |
| 475 | `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`); | 478 | `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`); |
| @@ -9,6 +9,9 @@ import { VideoChannelPage } from './VideoChannelPage'; | @@ -9,6 +9,9 @@ import { VideoChannelPage } from './VideoChannelPage'; | ||
| 9 | import ChannelViewModel from 'wdComponent/src/main/ets/viewmodel/ChannelViewModel'; | 9 | import ChannelViewModel from 'wdComponent/src/main/ets/viewmodel/ChannelViewModel'; |
| 10 | 10 | ||
| 11 | const TAG = 'BottomNavigationComponent'; | 11 | const TAG = 'BottomNavigationComponent'; |
| 12 | +PersistentStorage.persistProp('channelIds', ''); | ||
| 13 | +PersistentStorage.persistProp('indexSettingChannelId', 2002); | ||
| 14 | + | ||
| 12 | let storage = LocalStorage.getShared(); | 15 | let storage = LocalStorage.getShared(); |
| 13 | 16 | ||
| 14 | /** | 17 | /** |
-
Please register or login to post a comment