Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leozhang007 committed Aug 26, 2020
1 parent 65733e5 commit ab5b304
Showing 1 changed file with 35 additions and 28 deletions.
63 changes: 35 additions & 28 deletions pages/home/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,34 +134,41 @@ export default {
components: {
ArticleList
},
async asyncData ({ query }) {
const page = Number.parseInt(query.page || 1)
const limit = 20
const tab = query.tab || 'global_feed'
const tag = query.tag
const loadArticles = tab === 'your_feed' ? getYourFeedArticles : getArticles
const [ data, tagData ] = await Promise.all([
loadArticles({
limit,
offset: (page - 1) * 2,
tag
}),
getTags()
])
const { articles, articlesCount } = data
const { tags } = tagData
articles.forEach(article => article.favoriteDisabled = false)
return {
articles, // 文章列表
articlesCount, // 文章总数
tags, // 标签列表
limit, // 每页大小
page, // 页码
tab, // 选项卡
tag // 数据标签
async asyncData ({ query, error }) {
try {
console.log(error);
const page = Number.parseInt(query.page || 1)
const limit = 20
const tab = query.tab || 'global_feed'
const tag = query.tag
const loadArticles = tab === 'your_feed' ? getYourFeedArticles : getArticles
const [ data, tagData ] = await Promise.all([
loadArticles({
limit,
offset: (page - 1) * 2,
tag
}),
getTags()
])
const { articles, articlesCount } = data
const { tags } = tagData
articles.forEach(article => article.favoriteDisabled = false)
return {
articles, // 文章列表
articlesCount, // 文章总数
tags, // 标签列表
limit, // 每页大小
page, // 页码
tab, // 选项卡
tag // 数据标签
}
} catch (err) {
console.log(err);
console.log('=====================');
error(err)
}
},
watchQuery: ['page', 'tag', 'tab'],
Expand Down

0 comments on commit ab5b304

Please sign in to comment.