8.6更新

This commit is contained in:
hrx 2026-08-06 11:26:07 +08:00
parent 0db474a49a
commit 1c4006eb85
2 changed files with 31 additions and 8 deletions

View File

@ -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 {