Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
yuzhilin
2024-05-28 17:16:24 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5f7672f7e691a0c0ae32b04e5fe45574684fcc08
5f7672f7
1 parent
44eedeb3
fix:频道缓存
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
19 deletions
sight_harmony/features/wdComponent/src/main/ets/components/page/ChannelSubscriptionLayout.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/TopNavigationComponentNew.ets
sight_harmony/products/phone/src/main/ets/pages/view/BottomNavigationComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/ChannelSubscriptionLayout.ets
View file @
5f7672f
...
...
@@ -20,12 +20,10 @@ struct ChannelSubscriptionLayout {
//当前选中的频道
@Link currentTopNavSelectedIndex: number;
@Prop homeChannelList: TopNavDTO []
@Prop indexSettingChannelId: number
@Link myChannelList: TopNavDTO []
@Link moreChannelList: TopNavDTO []
@Link localChannelList: TopNavDTO []
@Link channelIds: number []
@StorageLink('channelIds') storeChannelIds: string = ''
@State isShow: boolean = false
@State dragItem: number = -1
private dragRefOffsetX: number = 0
...
...
@@ -34,7 +32,7 @@ struct ChannelSubscriptionLayout {
@State offsetY: number = 0
private FIX_VP_X: number = 80
private FIX_VP_Y: number = 48
@State indexSetting
TabIndex: number = 0
@State indexSetting
ChannelId: number = AppStorage.get<number>('indexSettingChannelId') || 2002
@State isEditIng: boolean = false
@State currentTopNavSelectedItem: TopNavDTO = {} as TopNavDTO
changeTab: (index: number) => void = () => {
...
...
@@ -50,13 +48,13 @@ struct ChannelSubscriptionLayout {
let channelIdTmp = this.channelIds.splice(index1, 1)
this.myChannelList.splice(index2, 0, tmp[0])
this.channelIds.splice(index2, 0, channelIdTmp[0])
this.storeChannelIds = this.channelIds.join(','
)
AppStorage.setOrCreate('channelIds', this.channelIds.join(',')
)
}
//删除频道
delChannelItem(index: number){
let item = this.myChannelList.splice(index, 1)[0]
this.channelIds.splice(index, 1)
this.storeChannelIds = this.channelIds.join(','
)
AppStorage.setOrCreate('channelIds', this.channelIds.join(',')
)
if (item.moreChannel === '1') {
this.moreChannelList.unshift(item)
}
...
...
@@ -68,7 +66,7 @@ struct ChannelSubscriptionLayout {
addChannelItem(item: TopNavDTO){
this.channelIds.push(item.channelId)
this.myChannelList.push(item)
this.storeChannelIds = this.channelIds.join(','
)
AppStorage.setOrCreate('channelIds', this.channelIds.join(',')
)
}
itemMove(index: number, newIndex: number): void {
...
...
@@ -265,6 +263,7 @@ struct ChannelSubscriptionLayout {
.alignContent(Alignment.Start)
.height(36)
.onClick(() => {
this.indexSettingChannelId = item.channelId
AppStorage.set('indexSettingChannelId', item.channelId)
})
})
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/TopNavigationComponentNew.ets
View file @
5f7672f
...
...
@@ -13,9 +13,6 @@ import DailyPaperTopicModel from '../../model/DailyPaperTopicModel'
const TAG = 'TopNavigationComponent';
PersistentStorage.persistProp('channelIds', '');
PersistentStorage.persistProp('indexSettingChannelId', 2002);
const storage = LocalStorage.getShared();
/**
...
...
@@ -48,11 +45,11 @@ export struct TopNavigationComponentNew {
@State currentTopNavSelectedIndex: number = 0;
// 顶导数据
@State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = []
@St
orageProp('indexSettingChannelId') indexSettingChannelId: number =
2002
@St
ate indexSettingChannelId: number = AppStorage.get<number>('indexSettingChannelId') ||
2002
//我的频道id列表
@State channelIds: number[] = []
//本地缓存频道id列表
@St
orageProp('channelIds') storageChannelIds: string =
''
@St
ate storageChannelIds: string = AppStorage.get<string>('channelIds') ||
''
@State homeChannelList: TopNavDTO[] = []
// 我的频道列表
@State myChannelList: TopNavDTO[] = []
...
...
@@ -191,7 +188,6 @@ export struct TopNavigationComponentNew {
this.topBar()
ChannelSubscriptionLayout({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
indexSettingChannelId: this.indexSettingChannelId,
homeChannelList: this.homeChannelList,
myChannelList: $myChannelList,
moreChannelList: $moreChannelList,
...
...
@@ -406,18 +402,29 @@ export struct TopNavigationComponentNew {
//频道分类
if (item.name !== '播报') { //暂时隐藏播报
if (item.myChannel === '1') {
if (item.myChannel === '1'
&& !this.storageChannelIds
) {
_myChannelList.push(item)
_channelIds.push(item.channelId)
} else if (item.moreChannel === '1') {
}
if (item.moreChannel === '1') {
this.moreChannelList.push(item)
} else if (item.localChannel === '1' && item.myChannel !== '1') {
}
if (item.localChannel === '1' && item.myChannel !== '1') {
this.localChannelList.push(item)
}
}
})
if(this.storageChannelIds){
_storageChannelIds.forEach((_item:string)=>{
let index = defaultList.findIndex(ele => Number(_item) === ele.channelId)
if(index > -1){
_myChannelList.push(defaultList[index])
_channelIds.push(defaultList[index].channelId)
}
})
}
if (cityName) {
let index = _myChannelList.findIndex(ele => cityName.includes(ele.name))
const localChannelitem = _myChannelList.splice(index, 1)[0];
...
...
@@ -466,10 +473,6 @@ export struct TopNavigationComponentNew {
this.changePage(this.currentTopNavSelectedIndex)
}
aboutToDisappear() {
AppStorage.set('channelIds', this.channelIds.join(','))
}
onTopNavigationDataUpdated() {
Logger.info(TAG,
`onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`);
...
...
sight_harmony/products/phone/src/main/ets/pages/view/BottomNavigationComponent.ets
View file @
5f7672f
...
...
@@ -9,6 +9,9 @@ import { VideoChannelPage } from './VideoChannelPage';
import ChannelViewModel from 'wdComponent/src/main/ets/viewmodel/ChannelViewModel';
const TAG = 'BottomNavigationComponent';
PersistentStorage.persistProp('channelIds', '');
PersistentStorage.persistProp('indexSettingChannelId', 2002);
let storage = LocalStorage.getShared();
/**
...
...
Please
register
or
login
to post a comment