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-29 15:21:07 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
292cb3666b112ee9d491feac445f28759714740b
292cb366
1 parent
652b6403
fix:频道订阅缓存问题修复
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
32 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/features/wdComponent/src/main/ets/components/page/ChannelSubscriptionLayout.ets
View file @
292cb36
...
...
@@ -23,7 +23,7 @@ struct ChannelSubscriptionLayout {
@Link myChannelList: TopNavDTO []
@Link moreChannelList: TopNavDTO []
@Link localChannelList: TopNavDTO []
@
Link channelIds: number
[]
@
State channelIds: number [] =
[]
@State isShow: boolean = false
@State dragItem: number = -1
private dragRefOffsetX: number = 0
...
...
@@ -40,6 +40,9 @@ struct ChannelSubscriptionLayout {
aboutToAppear() {
this.currentTopNavSelectedItem = this.myChannelList[this.currentTopNavSelectedIndex]
this.myChannelList.forEach(item=>{
this.channelIds.push(item.channelId)
})
}
//交换我的频道数组中的位置
...
...
@@ -54,7 +57,8 @@ struct ChannelSubscriptionLayout {
delChannelItem(index: number){
let item = this.myChannelList.splice(index, 1)[0]
this.channelIds.splice(index, 1)
AppStorage.setOrCreate('channelIds', this.channelIds.join(','))
AppStorage.setOrCreate('channelIds', JSON.stringify(this.channelIds))
console.log('delChannelItem',JSON.stringify(item),AppStorage.get('channelIds'))
if (item.moreChannel === '1') {
this.moreChannelList.unshift(item)
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/TopNavigationComponentNew.ets
View file @
292cb36
...
...
@@ -46,8 +46,6 @@ export struct TopNavigationComponentNew {
// 顶导数据
@State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = []
@State indexSettingChannelId: number = AppStorage.get<number>('indexSettingChannelId') || 2002
//我的频道id列表
@State channelIds: number[] = []
//本地缓存频道id列表
@State storageChannelIds: string = AppStorage.get<string>('channelIds') || ''
@State homeChannelList: TopNavDTO[] = []
...
...
@@ -192,7 +190,7 @@ export struct TopNavigationComponentNew {
myChannelList: $myChannelList,
moreChannelList: $moreChannelList,
localChannelList: $localChannelList,
channelIds: $channelIds,
//
channelIds: $channelIds,
changeTab: (index) => {
this.changePage(index)
}
...
...
@@ -260,7 +258,7 @@ export struct TopNavigationComponentNew {
.edgeEffect(EdgeEffect.None)
.height($r('app.float.top_tab_bar_height_common'))
.backgroundColor(this.barBackgroundColor)
.margin({
top:10
})
.margin({
top: 10
})
.onAreaChange((oldValue: Area, newValue: Area) => {
let width = Number.parseFloat(newValue.width.toString())
this.tabsWidth = Number.isNaN(width) ? 0 : width
...
...
@@ -342,8 +340,6 @@ export struct TopNavigationComponentNew {
//处理新闻tab顶导频道数据
topNavListHandle() {
let cityName = SPHelper.default.getSync(SpConstants.LOCATION_CITY_NAME, '') as string
let _channelIds: number [] = []
let _myChannelList: TopNavDTO [] = []
let _storageChannelIds: string [] = [] //list1
let defaultMyChannelList: TopNavDTO[] = []
...
...
@@ -379,11 +375,7 @@ export struct TopNavigationComponentNew {
}
})
defaultList.unshift(...defaultMyChannelList)
defaultList.forEach((item, index) => {
if (this.storageChannelIds && _storageChannelIds.includes(String(item.channelId))) {
item.myChannel = '1'
}
if (item.channelType === 2) {
if (cityName.includes(item.name)) {
item.myChannel = '1'
...
...
@@ -399,32 +391,34 @@ export struct TopNavigationComponentNew {
item.moreChannel = '1'
}
}
if (this.storageChannelIds && _storageChannelIds.includes(String(item.channelId))) {
item.myChannel = '1'
}
//频道分类
if (item.name !== '播报') { //暂时隐藏播报
if (item.myChannel === '1'
&& !this.storageChannelIds
) {
if (item.myChannel === '1') {
_myChannelList.push(item)
_channelIds.push(item.channelId)
}
if (item.moreChannel === '1') {
if (item.moreChannel === '1'
&& item.myChannel !== '1'
) {
this.moreChannelList.push(item)
}
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 (this.storageChannelIds) {
let sortedyChannelList = _myChannelList.sort((item1, item2) => {
let index1 = this.storageChannelIds.indexOf(String(item1.channelId));
let index2 = this.storageChannelIds.indexOf(String(item2.channelId));
return index1 - index2;
});
_myChannelList = sortedyChannelList
}
if (cityName) {
let index = _myChannelList.findIndex(ele => cityName.includes(ele.name))
const localChannelitem = _myChannelList.splice(index, 1)[0];
...
...
@@ -432,7 +426,6 @@ export struct TopNavigationComponentNew {
_myChannelList.splice(3, 0, localChannelitem);
}
this.channelIds = _channelIds
this.myChannelList = _myChannelList
//缓存首页频道
...
...
@@ -620,22 +613,22 @@ export struct TopNavigationComponentNew {
})
}
clickMorningEveningPaper(){
clickMorningEveningPaper()
{
if (NetworkUtil.isNetConnected()) {
DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean =>{
DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean =>
{
if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) {
SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id);
ProcessUtils.gotoMorningEveningPaper()
TrackingButton.click('morning_evening_news_click',TrackConstants.SummaryType.MorningAndEveningNews,TrackConstants.SummaryType.MorningAndEveningNews)
}else {
TrackingButton.click('morning_evening_news_click', TrackConstants.SummaryType.MorningAndEveningNews,
TrackConstants.SummaryType.MorningAndEveningNews)
} else {
ToastUtils.showToast('暂无早晚报信息', 1000)
}
}).catch((err:
string) =>
{
}).catch((err:
string) =>
{
ToastUtils.showToast('暂无早晚报信息', 1000)
})
} else {
ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000)
}
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment