mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2025-05-19 01:50:15 +09:00
fix: 修复文章归档
This commit is contained in:
parent
76c00f31f6
commit
32b3bbaa74
@ -21,14 +21,14 @@
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<block v-else>
|
||||
<view class="bg-white pb-24">
|
||||
<view v-if="!haloConfigs.basicConfig.auditModeEnabled" class="bg-white pb-24">
|
||||
<view class="banner bg-white ml-24 mr-24 mt-12 round-3" v-if="bannerList.length != 0">
|
||||
<e-swiper :dotPosition="globalAppSettings.banner.dotPosition" :autoplay="true"
|
||||
:useDot="globalAppSettings.banner.useDot" :list="bannerList"
|
||||
@on-click="fnOnBannerClick"></e-swiper>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex flex-between mt-16 mb-24 pl-24 pr-24">
|
||||
<view v-if="!haloConfigs.basicConfig.auditModeEnabled" class="flex flex-between mt-16 mb-24 pl-24 pr-24">
|
||||
<view class="page-item_title text-weight-b ">精品分类</view>
|
||||
<view class="show-more flex flex-center bg-white round-3" @click="fnToCategoryPage">
|
||||
<text class="iconfont icon-angle-right text-size-s text-grey-darken-1"></text>
|
||||
@ -38,7 +38,7 @@
|
||||
<text class="iconfont icon-angle-right text-size-s "></text>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view class="category" scroll-x="true">
|
||||
<scroll-view v-if="!haloConfigs.basicConfig.auditModeEnabled" class="category" scroll-x="true">
|
||||
<view v-if="categoryList.length == 0" class="cate-empty round-3 mr-5 flex flex-center text-grey">
|
||||
还没有任何分类~
|
||||
</view>
|
||||
@ -194,9 +194,7 @@ export default {
|
||||
},
|
||||
// 获取轮播图
|
||||
fnGetBanner() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const _this = this;
|
||||
const _format = function (list) {
|
||||
return list.map((item, index) => {
|
||||
@ -245,9 +243,6 @@ export default {
|
||||
},
|
||||
// 文章列表
|
||||
fnGetArticleList() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
// 设置状态为加载中
|
||||
if (!this.isLoadMore) {
|
||||
this.loading = 'loading';
|
||||
|
@ -41,28 +41,26 @@
|
||||
</view>
|
||||
<block v-if="item.posts.length != 0">
|
||||
<block v-for="(post, postIndex) in item.posts" :key="post.metadata.name">
|
||||
<tm-translate animation-name="fadeUp" :wait="calcAniWait(postIndex)">
|
||||
<view class="flex post shadow-3 pa-24 mb-24"
|
||||
:class="[globalAppSettings.layout.cardType]"
|
||||
@click="fnToArticleDetail(post)">
|
||||
<image class="post-thumbnail"
|
||||
:src="$utils.checkThumbnailUrl(post.spec.cover)" mode="aspectFill">
|
||||
</image>
|
||||
<view class="post-info pl-20">
|
||||
<view class="post-info_title text-overflow">{{ post.spec.title }}
|
||||
</view>
|
||||
<view
|
||||
class="post-info_summary text-overflow-2 mt-12 text-size-s text-grey-darken-1">
|
||||
{{ post.status.excerpt }}
|
||||
</view>
|
||||
<view class="post-info_time mt-12 text-size-s text-grey-darken-1">
|
||||
<text class="iconfont icon-clock text-size-s mr-6"></text>
|
||||
<text class="time-label">发布时间:</text>
|
||||
{{ {d: post.spec.publishTime, f: 'yyyy年MM月dd日 星期w'} | formatTime }}
|
||||
</view>
|
||||
<view class="flex post shadow-3 pa-24 mb-24"
|
||||
:class="[globalAppSettings.layout.cardType]"
|
||||
@click="fnToArticleDetail(post)">
|
||||
<image class="post-thumbnail"
|
||||
:src="$utils.checkThumbnailUrl(post.spec.cover)" mode="aspectFill">
|
||||
</image>
|
||||
<view class="post-info pl-20">
|
||||
<view class="post-info_title text-overflow">{{ post.spec.title }}
|
||||
</view>
|
||||
<view
|
||||
class="post-info_summary text-overflow-2 mt-12 text-size-s text-grey-darken-1">
|
||||
{{ post.status.excerpt }}
|
||||
</view>
|
||||
<view class="post-info_time mt-12 text-size-s text-grey-darken-1">
|
||||
<text class="iconfont icon-clock text-size-s mr-6"></text>
|
||||
<text class="time-label">发布时间:</text>
|
||||
{{ {d: post.spec.publishTime, f: 'yyyy年MM月dd日 星期w'} | formatTime }}
|
||||
</view>
|
||||
</view>
|
||||
</tm-translate>
|
||||
</view>
|
||||
</block>
|
||||
</block>
|
||||
<view v-else class="post-empty text-size-m text-grey-darken-1">该日期下暂无归档文章!</view>
|
||||
@ -146,6 +144,7 @@
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.queryParams.page = 0;
|
||||
this.dataList = this.handleGetShowDataList(this.handleGetPosts(this.cacheDataList))
|
||||
this.fnToTopPage();
|
||||
},
|
||||
fnGetData() {
|
||||
if (this.isLoadMore) {
|
||||
@ -154,9 +153,8 @@
|
||||
})
|
||||
} else {
|
||||
this.loading = 'loading';
|
||||
this.loadMoreText = "加载中...";
|
||||
}
|
||||
|
||||
this.loadMoreText = "加载中...";
|
||||
const paramsStr = qs.stringify(this.queryParams, {
|
||||
allowDots: true,
|
||||
encodeValuesOnly: true,
|
||||
@ -173,7 +171,10 @@
|
||||
const posts = this.handleGetPosts(data.items)
|
||||
const showDataList = this.handleGetShowDataList(posts)
|
||||
if (this.isLoadMore) {
|
||||
this.cacheDataList = this.cacheDataList.concat(data.items);
|
||||
this.cacheDataList = this.handleUniqueCacheDatalist([...this.cacheDataList, ...
|
||||
data
|
||||
.items
|
||||
]);
|
||||
this.handleMergeDataList2(showDataList)
|
||||
} else {
|
||||
this.dataList = []
|
||||
@ -185,6 +186,7 @@
|
||||
this.loadMoreText = data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
|
||||
},
|
||||
fail: (err) => {
|
||||
this.loading = 'error';
|
||||
@ -237,11 +239,11 @@
|
||||
}
|
||||
dataListResult.push(postData)
|
||||
})
|
||||
if (this.tab.activeIndex == 1) {
|
||||
dataListResult.sort((a, b) => {
|
||||
return Number(b.year) - Number(a.year)
|
||||
})
|
||||
}
|
||||
|
||||
dataListResult.sort((a, b) => {
|
||||
return Number(b.sort) - Number(a.sort)
|
||||
})
|
||||
|
||||
return dataListResult;
|
||||
},
|
||||
handleMergeDataList(list1, list2) {
|
||||
@ -270,22 +272,31 @@
|
||||
return Object.values(merged);
|
||||
},
|
||||
handleMergeDataList2(list) {
|
||||
const tempList = [...list]
|
||||
this.dataList.forEach((item, index) => {
|
||||
list.forEach((item, index) => {
|
||||
const find = this.dataList.find(x => x.key == item.key)
|
||||
if (find) {
|
||||
item.posts.forEach(post => {
|
||||
if (!find.posts.some(x => x.metadata.name == post.metadata.name)) {
|
||||
if (!find.posts.find(x => x.metadata.name == post.metadata.name)) {
|
||||
find.posts.push(post)
|
||||
}
|
||||
})
|
||||
tempList.splice(index, 1)
|
||||
}
|
||||
})
|
||||
tempList.forEach(post => {
|
||||
this.dataList.push(post)
|
||||
list.forEach(post => {
|
||||
if (!this.dataList.find(x => x.key === post.key)) {
|
||||
this.dataList.push(post)
|
||||
}
|
||||
})
|
||||
console.log("this.dataList", this.dataList)
|
||||
|
||||
this.dataList.sort((a, b) => {
|
||||
return Number(b.sort) - Number(a.sort)
|
||||
})
|
||||
},
|
||||
handleUniqueCacheDatalist(dataList) {
|
||||
const seen = new Set();
|
||||
return dataList.filter(item => {
|
||||
return seen.has(item.metadata.name) ? false : seen.add(item.metadata.name);
|
||||
});
|
||||
},
|
||||
fnToArticleDetail(article) {
|
||||
uni.navigateTo({
|
||||
|
Loading…
Reference in New Issue
Block a user