Compare commits
No commits in common. "d6e0531b94b6d1d3d0424fdabe23c226e4fb749f" and "8c6bd7307b7d8a6076f410376bf0e3fa47ff750e" have entirely different histories.
d6e0531b94
...
8c6bd7307b
@ -190,9 +190,7 @@ export default {
|
|||||||
status: '',
|
status: '',
|
||||||
keyword: ''
|
keyword: ''
|
||||||
},
|
},
|
||||||
articleList: [],
|
articleList: []
|
||||||
articleTypeSummary: [],
|
|
||||||
articleTypeSummaryEn: []
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -217,18 +215,12 @@ 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 summary = summaryMap[item.type] || {}
|
const list = this.articleList.filter(article => article.type === item.type)
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
count: Number(summary.article_count || 0),
|
count: list.length,
|
||||||
views: Number(summary.read_count || 0)
|
views: list.reduce((total, article) => total + Number(article.views || 0), 0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -320,18 +312,6 @@ 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
|
||||||
@ -404,19 +384,16 @@ 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