8.6更新
This commit is contained in:
parent
0db474a49a
commit
1c4006eb85
@ -190,7 +190,9 @@ export default {
|
|||||||
status: '',
|
status: '',
|
||||||
keyword: ''
|
keyword: ''
|
||||||
},
|
},
|
||||||
articleList: []
|
articleList: [],
|
||||||
|
articleTypeSummary: [],
|
||||||
|
articleTypeSummaryEn: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -215,12 +217,18 @@ export default {
|
|||||||
行业洞察: { label: '行业洞察', type: '行业洞察', icon: 'el-icon-data-analysis', iconClass: 'amber' },
|
行业洞察: { label: '行业洞察', type: '行业洞察', icon: 'el-icon-data-analysis', iconClass: 'amber' },
|
||||||
活动资讯: { label: '活动资讯', type: '活动资讯', icon: 'el-icon-date', iconClass: 'purple' }
|
活动资讯: { label: '活动资讯', type: '活动资讯', icon: 'el-icon-date', iconClass: 'purple' }
|
||||||
}
|
}
|
||||||
|
const summaryMap = {}
|
||||||
|
this.articleTypeSummary.forEach(item => {
|
||||||
|
if (item && item.article_type) {
|
||||||
|
summaryMap[item.article_type] = item
|
||||||
|
}
|
||||||
|
})
|
||||||
return Object.values(map).map(item => {
|
return Object.values(map).map(item => {
|
||||||
const list = this.articleList.filter(article => article.type === item.type)
|
const summary = summaryMap[item.type] || {}
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
count: list.length,
|
count: Number(summary.article_count || 0),
|
||||||
views: list.reduce((total, article) => total + Number(article.views || 0), 0)
|
views: Number(summary.read_count || 0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -312,6 +320,18 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getArticleTypeSummary(res) {
|
||||||
|
if (Array.isArray(res.article_type_summary)) return res.article_type_summary
|
||||||
|
const data = res.data && !Array.isArray(res.data) ? res.data : {}
|
||||||
|
if (Array.isArray(data.article_type_summary)) return data.article_type_summary
|
||||||
|
return []
|
||||||
|
},
|
||||||
|
getArticleTypeSummaryEn(res) {
|
||||||
|
if (Array.isArray(res.article_type_summary_en)) return res.article_type_summary_en
|
||||||
|
const data = res.data && !Array.isArray(res.data) ? res.data : {}
|
||||||
|
if (Array.isArray(data.article_type_summary_en)) return data.article_type_summary_en
|
||||||
|
return []
|
||||||
|
},
|
||||||
getResponseList(res) {
|
getResponseList(res) {
|
||||||
// 兼容接口可能返回的多种列表结构。
|
// 兼容接口可能返回的多种列表结构。
|
||||||
if (Array.isArray(res.data)) return res.data
|
if (Array.isArray(res.data)) return res.data
|
||||||
@ -384,16 +404,19 @@ export default {
|
|||||||
const list = this.getResponseList(res)
|
const list = this.getResponseList(res)
|
||||||
// 将接口数据映射成页面展示字段。
|
// 将接口数据映射成页面展示字段。
|
||||||
this.articleList = list.map(item => this.normalizeArticle(item))
|
this.articleList = list.map(item => this.normalizeArticle(item))
|
||||||
// 读取接口总数,用于分页器和底部统计。
|
this.articleTypeSummary = this.getArticleTypeSummary(res)
|
||||||
|
this.articleTypeSummaryEn = this.getArticleTypeSummaryEn(res)
|
||||||
this.total = this.getResponseTotal(res, list)
|
this.total = this.getResponseTotal(res, list)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 接口返回失败时清空列表,避免展示旧数据。
|
|
||||||
this.articleList = []
|
this.articleList = []
|
||||||
|
this.articleTypeSummary = []
|
||||||
|
this.articleTypeSummaryEn = []
|
||||||
this.total = 0
|
this.total = 0
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 请求异常时清空列表并提示用户。
|
|
||||||
this.articleList = []
|
this.articleList = []
|
||||||
|
this.articleTypeSummary = []
|
||||||
|
this.articleTypeSummaryEn = []
|
||||||
this.total = 0
|
this.total = 0
|
||||||
this.$message.error('文章列表加载失败')
|
this.$message.error('文章列表加载失败')
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user