mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2025-05-19 01:50:15 +09:00
update: 优化审核模式,新增审核使用模拟数据
This commit is contained in:
parent
74a5efb596
commit
bf41b08b35
@ -1,5 +1,6 @@
|
||||
// 应用设置存储key值
|
||||
export const _AppConfigKey = 'APP_GLOBAL_CONFIGS';
|
||||
export const _AppMockJsonKey = 'APP_GLOBAL_MOCK_JSON';
|
||||
|
||||
// 默认的应用设置
|
||||
export const DefaultAppConfigs = {
|
||||
@ -28,3 +29,22 @@ export const getAppConfigs = () => {
|
||||
export const setAppConfigs = (configs) => {
|
||||
uni.setStorageSync(_AppConfigKey, JSON.stringify(configs))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取应用模拟数据
|
||||
*/
|
||||
export const getAppMockJson = () => {
|
||||
let json = uni.getStorageSync(_AppMockJsonKey)
|
||||
if (json) return JSON.parse(json)
|
||||
|
||||
uni.setStorageSync(_AppMockJsonKey, JSON.stringify({}))
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存应用模拟数据
|
||||
*/
|
||||
export const setAppMockJson = (json) => {
|
||||
uni.setStorageSync(_AppMockJsonKey, JSON.stringify(json))
|
||||
}
|
||||
|
@ -29,6 +29,11 @@
|
||||
// #ifdef MP-WEIXIN
|
||||
// uni.$tm.vx.commit('setWxShare', res.shareConfig);
|
||||
// #endif
|
||||
|
||||
// 获取mockjson
|
||||
await uni.$tm.vx.actions('config/fetchMockJson')
|
||||
|
||||
// 进入检查
|
||||
this.fnCheckShowStarted();
|
||||
}).catch((err) => {
|
||||
uni.switchTab({
|
||||
|
@ -190,7 +190,8 @@
|
||||
path: '/pagesA/archives/archives',
|
||||
isAdmin: false,
|
||||
type: 'page',
|
||||
show: !this.haloConfigs.basicConfig.auditModeEnabled
|
||||
// show: !this.haloConfigs.basicConfig.auditModeEnabled
|
||||
show: true
|
||||
}, {
|
||||
key: 'love',
|
||||
title: '恋爱日记',
|
||||
|
@ -1,20 +1,14 @@
|
||||
<template>
|
||||
<view class="app-page">
|
||||
<view class="auditModeEnabled" v-if="haloConfigs.basicConfig.auditModeEnabled">
|
||||
<view>你好呀,很开心认识你!</view>
|
||||
<view style="margin-top: 36rpx;">
|
||||
{{haloConfigs.appConfig.appInfo.name}}
|
||||
</view>
|
||||
</view>
|
||||
<block v-else>
|
||||
<view v-if="loading != 'success'" class="loading-wrap">
|
||||
|
||||
<view v-if="loading !== 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view v-else class="app-page-content">
|
||||
<view v-if="dataList.length == 0" class="content-empty flex flex-center" style="height: 70vh;">
|
||||
<view v-if="dataList.length === 0" class="content-empty flex flex-center" style="height: 70vh;">
|
||||
<!-- 空布局 -->
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无数据"></tm-empty>
|
||||
</view>
|
||||
@ -25,8 +19,11 @@
|
||||
<view class="catgory-card" :style="{backgroundImage:`url(${item.spec.cover})`}">
|
||||
<view class="content" @click="handleToCategory(item)">
|
||||
<view style="font-size: 32rpx;color: #ffffff;">{{ item.spec.displayName }}</view>
|
||||
<view style="font-size: 24rpx;color: #ffffff;margin-top: 6rpx;">共
|
||||
{{ item.postCount }} 篇文章
|
||||
<view v-if="!haloConfigs.basicConfig.auditModeEnabled" style="font-size: 24rpx;color: #ffffff;margin-top: 6rpx;">
|
||||
共 {{ item.postCount }} 篇文章
|
||||
</view>
|
||||
<view v-else style="font-size: 24rpx;color: #ffffff;margin-top: 6rpx;">
|
||||
共 {{ item.postCount }} 篇内容
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -36,7 +33,7 @@
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -75,6 +72,9 @@
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.fnGetData();
|
||||
@ -86,6 +86,13 @@
|
||||
},
|
||||
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
return
|
||||
}
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
@ -100,9 +107,22 @@
|
||||
methods: {
|
||||
fnGetData() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
uni.setNavigationBarTitle({
|
||||
title: "你好,很高兴认识你!"
|
||||
})
|
||||
this.dataList = this.mockJson.category.list.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
name: Date.now() * Math.random(),
|
||||
},
|
||||
spec: {
|
||||
displayName: item.title,
|
||||
cover: this.$utils.checkImageUrl(item.cover)
|
||||
},
|
||||
postCount: 0
|
||||
}
|
||||
});
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = '呜呜,没有更多数据啦~';
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
@ -155,6 +175,9 @@
|
||||
})
|
||||
},
|
||||
handleToCategory(data) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pagesA/category-detail/category-detail?name=${data.metadata.name}&title=${data.spec.displayName}`
|
||||
})
|
||||
|
@ -94,6 +94,12 @@ export default {
|
||||
computed: {
|
||||
galleryConfig() {
|
||||
return this.$tm.vx.getters().getConfigs.pageConfig.galleryConfig;
|
||||
},
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -114,6 +120,13 @@ export default {
|
||||
this.fnGetData(true);
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
@ -135,6 +148,10 @@ export default {
|
||||
this.fnGetData(true);
|
||||
},
|
||||
fnGetCategory() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
this.fnGetData(true);
|
||||
return
|
||||
}
|
||||
this.$httpApi.v2.getPhotoGroupList({
|
||||
page: 1,
|
||||
size: 0
|
||||
@ -151,7 +168,37 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
fnGetData(isClearWallfull = false) {
|
||||
fnGetData(isClearWaterfall = false) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
this.dataList = this.mockJson.gallery.list.map(item => {
|
||||
return {
|
||||
metadata: {
|
||||
name: Date.now() * Math.random(),
|
||||
},
|
||||
spec: {
|
||||
url: this.$utils.checkImageUrl(item)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
this.loading = 'success';
|
||||
|
||||
if (this.galleryConfig.useWaterfall) {
|
||||
this.$nextTick(() => {
|
||||
if (isClearWaterfall) {
|
||||
this.$refs.wafll.clear()
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.$refs.wafll.pushData(this.dataList)
|
||||
}, 50)
|
||||
})
|
||||
}
|
||||
this.loadMoreText = '呜呜,没有更多数据啦~';
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置状态为加载中
|
||||
if (!this.isLoadMore) {
|
||||
this.loading = 'loading';
|
||||
@ -174,7 +221,7 @@ export default {
|
||||
}
|
||||
if (this.galleryConfig.useWaterfall) {
|
||||
this.$nextTick(() => {
|
||||
if(isClearWallfull){
|
||||
if (isClearWaterfall) {
|
||||
this.$refs.wafll.clear()
|
||||
}
|
||||
this.$refs.wafll.pushData(_list)
|
||||
|
@ -21,15 +21,15 @@
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<block v-else>
|
||||
<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">
|
||||
<view 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>
|
||||
<!-- 精品分类 -->
|
||||
<block v-if="haloConfigs.pageConfig.homeConfig.useCategory">
|
||||
<block v-if="calcIsShowCategory">
|
||||
<view 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">
|
||||
@ -42,7 +42,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view class="category" scroll-x="true">
|
||||
<view v-if="categoryList.length == 0" class="cate-empty round-3 mr-5 flex flex-center text-grey">
|
||||
<view v-if="categoryList.length === 0" class="cate-empty round-3 mr-5 flex flex-center text-grey">
|
||||
还没有任何分类~
|
||||
</view>
|
||||
<block v-else>
|
||||
@ -55,7 +55,7 @@
|
||||
</block>
|
||||
|
||||
<!-- 最新文章 -->
|
||||
<view v-if="!haloConfigs.basicConfig.auditModeEnabled" class="flex flex-between mt-24 mb-24 pl-24 pr-24">
|
||||
<view class="flex flex-between mt-24 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="fnToArticlesPage">
|
||||
<text class="iconfont icon-angle-right text-size-s text-grey-darken-1"></text>
|
||||
@ -65,7 +65,7 @@
|
||||
<text class="iconfont icon-angle-right text-size-s "></text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="articleList.length == 0" class="article-empty">
|
||||
<view v-if="articleList.length === 0" class="article-empty">
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="博主还没有发表任何内容~"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
@ -136,12 +136,23 @@
|
||||
const appInfo = this.haloConfigs.appConfig.appInfo;
|
||||
appInfo.logo = this.$utils.checkImageUrl(appInfo.logo)
|
||||
return appInfo;
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
},
|
||||
calcIsShowCategory() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled && this.categoryList.length !== 0) {
|
||||
return false
|
||||
}
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
return false
|
||||
}
|
||||
return this.haloConfigs.pageConfig.homeConfig.useCategory
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.fnSetPageTitle();
|
||||
},
|
||||
|
||||
created() {
|
||||
this.fnQuery();
|
||||
},
|
||||
@ -151,6 +162,13 @@
|
||||
this.fnQuery();
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
return
|
||||
}
|
||||
if (this.result.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
@ -164,15 +182,32 @@
|
||||
},
|
||||
methods: {
|
||||
fnQuery() {
|
||||
console.log('this.mockJson', this.mockJson)
|
||||
this.fnGetBanner();
|
||||
this.fnGetArticleList();
|
||||
this.fnGetCategoryList();
|
||||
},
|
||||
|
||||
fnGetCategoryList() {
|
||||
if (!this.haloConfigs.pageConfig.homeConfig.useCategory) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
this.categoryList = this.mockJson.home.categoryList.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
name: Date.now() * Math.random(),
|
||||
},
|
||||
spec: {
|
||||
displayName: item.title,
|
||||
cover: item.cover
|
||||
},
|
||||
postCount: 0
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.calcIsShowCategory) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$httpApi.v2
|
||||
.getCategoryList({})
|
||||
.then(res => {
|
||||
@ -198,6 +233,19 @@
|
||||
// 获取轮播图
|
||||
fnGetBanner() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
this.bannerList = this.mockJson.home.bannerList.map((item) => {
|
||||
return {
|
||||
mp4: '',
|
||||
id: Date.now() * Math.random(),
|
||||
nickname: this.haloConfigs.authorConfig.blogger.nickname,
|
||||
avatar: this.$utils.checkAvatarUrl(this.haloConfigs.authorConfig.blogger.avatar),
|
||||
address: '',
|
||||
createTime: item.time,
|
||||
title: item.title,
|
||||
src: this.$utils.checkThumbnailUrl(item.cover),
|
||||
image: this.$utils.checkThumbnailUrl(item.cover)
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
const _this = this;
|
||||
@ -230,7 +278,8 @@
|
||||
success: (res) => {
|
||||
this.bannerList = _format(res.data.items);
|
||||
},
|
||||
fail: (err) => {}
|
||||
fail: (err) => {
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
@ -238,7 +287,10 @@
|
||||
this.bannerCurrent = e.current;
|
||||
},
|
||||
fnOnBannerClick(item) {
|
||||
if (item.id == '') return;
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
if (item.id === '') return;
|
||||
this.fnToArticleDetail({
|
||||
metadata: {
|
||||
name: item.id
|
||||
@ -247,6 +299,32 @@
|
||||
},
|
||||
// 文章列表
|
||||
fnGetArticleList() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
this.articleList = this.mockJson.home.postList.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
name: Date.now() * Math.random(),
|
||||
},
|
||||
spec: {
|
||||
pinned: false,
|
||||
cover: item.cover,
|
||||
title: item.title,
|
||||
publishTime: item.time
|
||||
},
|
||||
status: {
|
||||
excerpt: item.desc
|
||||
},
|
||||
stats: {
|
||||
visit: 0
|
||||
}
|
||||
}
|
||||
});
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = '呜呜,没有更多数据啦~';
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return;
|
||||
}
|
||||
// 设置状态为加载中
|
||||
if (!this.isLoadMore) {
|
||||
this.loading = 'loading';
|
||||
@ -284,9 +362,11 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
//跳转文章详情
|
||||
fnToArticleDetail(article) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/article-detail/article-detail?name=' + article.metadata.name,
|
||||
animationType: 'slide-in-right'
|
||||
@ -322,6 +402,9 @@
|
||||
|
||||
// 根据slug查询分类下的文章
|
||||
fnToCategoryBy(category) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pagesA/category-detail/category-detail?name=${category.metadata.name}&title=${category.spec.displayName}`
|
||||
});
|
||||
@ -382,9 +465,11 @@
|
||||
margin-right: 24rpx;
|
||||
|
||||
/* #endif */
|
||||
&_icon {}
|
||||
&_icon {
|
||||
}
|
||||
|
||||
&_text {}
|
||||
&_text {
|
||||
}
|
||||
}
|
||||
|
||||
.show-more {
|
||||
|
@ -1,13 +1,13 @@
|
||||
<template>
|
||||
<view class="app-page">
|
||||
<view v-if="loading != 'success'" class="loading-wrap">
|
||||
<view v-if="loading !== 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view v-else class="app-page-content">
|
||||
<view v-if="dataList.length == 0" class="content-empty flex flex-center" style="min-height: 70vh;">
|
||||
<view v-if="dataList.length === 0" class="content-empty flex flex-center" style="min-height: 70vh;">
|
||||
<!-- 空布局 -->
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无数据"></tm-empty>
|
||||
</view>
|
||||
@ -101,6 +101,12 @@ export default {
|
||||
let blogger = this.$tm.vx.getters().getConfigs.authorConfig.blogger;
|
||||
blogger.avatar = this.$utils.checkAvatarUrl(blogger.avatar, true);
|
||||
return blogger;
|
||||
},
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
}
|
||||
},
|
||||
|
||||
@ -114,6 +120,13 @@ export default {
|
||||
},
|
||||
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
return
|
||||
}
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
@ -127,6 +140,37 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
fnGetData() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
this.dataList = this.mockJson.moments.list.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
name: Date.now() * Math.random(),
|
||||
},
|
||||
spec: {
|
||||
user: {
|
||||
displayName: this.bloggerInfo.nickname,
|
||||
avatar: this.$utils.checkAvatarUrl(this.bloggerInfo.avatar),
|
||||
},
|
||||
content: {
|
||||
html: item.content
|
||||
},
|
||||
releaseTime: item.time
|
||||
},
|
||||
images: item.images.map((img) => {
|
||||
return {
|
||||
type: "PHOTO",
|
||||
url: this.$utils.checkThumbnailUrl(img),
|
||||
}
|
||||
}),
|
||||
videos: []
|
||||
}
|
||||
});
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = '呜呜,没有更多数据啦~';
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
mask: true,
|
||||
title: '加载中...'
|
||||
@ -139,9 +183,6 @@ export default {
|
||||
this.$httpApi.v2
|
||||
.getMomentList(this.queryParams)
|
||||
.then(res => {
|
||||
console.log('请求结果:');
|
||||
console.log(res);
|
||||
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
this.hasNext = res.hasNext;
|
||||
|
@ -1,12 +1,6 @@
|
||||
<template>
|
||||
<view class="app-page">
|
||||
<view class="auditModeEnabled" v-if="haloConfigs.basicConfig.auditModeEnabled">
|
||||
<view>你好呀,很开心认识你!</view>
|
||||
<view style="margin-top: 36rpx;">
|
||||
{{haloConfigs.appConfig.appInfo.name}}
|
||||
</view>
|
||||
</view>
|
||||
<block v-else>
|
||||
|
||||
<view class="e-fixed">
|
||||
<tm-tabs color="light-blue" v-model="tab.activeIndex" :list="tab.list" align="center"
|
||||
@change="fnOnTabChange"></tm-tabs>
|
||||
@ -15,7 +9,7 @@
|
||||
<view style="width: 100vw;height: 90rpx;"></view>
|
||||
|
||||
<!-- 骨架屏:加载区域 -->
|
||||
<view v-if="loading != 'success'" class="loading-wrap">
|
||||
<view v-if="loading !== 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
@ -23,8 +17,9 @@
|
||||
|
||||
<!-- 加载完成区域 -->
|
||||
<block v-else>
|
||||
<view v-if="dataList.length == 0" class="list-empty flex flex-center">
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无归档的文章"></tm-empty>
|
||||
<view v-if="dataList.length === 0" class="list-empty flex flex-center">
|
||||
<tm-empty v-if="haloConfigs.basicConfig.auditModeEnabled" icon="icon-shiliangzhinengduixiang-" label="暂无归档的内容"></tm-empty>
|
||||
<tm-empty v-else icon="icon-shiliangzhinengduixiang-" label="暂无归档的文章"></tm-empty>
|
||||
</view>
|
||||
<view v-else class="e-timeline tm-timeline mt-24">
|
||||
<block v-for="(item, index) in dataList" :key="index">
|
||||
@ -41,12 +36,15 @@
|
||||
<view class="tm-timeline-item-left">
|
||||
<view class="flex time text-weight-b mb-24">
|
||||
<text>{{ item.year }}年</text>
|
||||
<text v-if="tab.activeIndex == 0">{{ item.month }}月</text>
|
||||
<view class="text-size-s text-grey-darken-1 ml-12">
|
||||
<text v-if="tab.activeIndex === 0">{{ item.month }}月</text>
|
||||
<view v-if="haloConfigs.basicConfig.auditModeEnabled" class="text-size-s text-grey-darken-1 ml-12">
|
||||
(共 {{ item.posts.length }} 篇内容)
|
||||
</view>
|
||||
<view v-else class="text-size-s text-grey-darken-1 ml-12">
|
||||
(共 {{ item.posts.length }} 篇文章)
|
||||
</view>
|
||||
</view>
|
||||
<block v-if="item.posts.length != 0">
|
||||
<block v-if="item.posts.length !== 0">
|
||||
<block v-for="(post, postIndex) in item.posts" :key="post.metadata.name">
|
||||
<view class="flex post shadow-3 pa-24 mb-24"
|
||||
:class="[globalAppSettings.layout.cardType]"
|
||||
@ -81,7 +79,6 @@
|
||||
<tm-flotbutton @click="fnToTopPage" size="m" color="bg-gradient-light-blue-accent"
|
||||
icon="icon-angle-up"></tm-flotbutton>
|
||||
</block>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -128,6 +125,9 @@
|
||||
},
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@ -139,6 +139,13 @@
|
||||
this.fnGetData();
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
return
|
||||
}
|
||||
if (this.result.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
@ -159,6 +166,40 @@
|
||||
},
|
||||
fnGetData() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
const dataList = this.mockJson.archives.list.map(item => {
|
||||
const date = new Date(item.time)
|
||||
const year = date.getFullYear()
|
||||
const month = date.getMonth() + 1
|
||||
return {
|
||||
metadata: {
|
||||
name: Date.now() * Math.random(),
|
||||
labels: {
|
||||
"content.halo.run/archive-year": year,
|
||||
"content.halo.run/archive-month": month
|
||||
}
|
||||
},
|
||||
spec: {
|
||||
pinned: false,
|
||||
cover: item.cover,
|
||||
title: item.title,
|
||||
publishTime: item.time
|
||||
},
|
||||
status: {
|
||||
excerpt: item.desc
|
||||
},
|
||||
stats: {
|
||||
visit: 0
|
||||
}
|
||||
}
|
||||
});
|
||||
const posts = this.handleGetPosts(dataList)
|
||||
this.dataList = []
|
||||
this.cacheDataList = dataList;
|
||||
this.dataList = this.handleGetShowDataList(posts)
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = '呜呜,没有更多数据啦~';
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return;
|
||||
}
|
||||
if (this.isLoadMore) {
|
||||
@ -185,9 +226,8 @@
|
||||
const posts = this.handleGetPosts(data.items)
|
||||
const showDataList = this.handleGetShowDataList(posts)
|
||||
if (this.isLoadMore) {
|
||||
this.cacheDataList = this.handleUniqueCacheDatalist([...this.cacheDataList, ...
|
||||
data
|
||||
.items
|
||||
this.cacheDataList = this.handleUniqueCacheDatalist([
|
||||
...this.cacheDataList, ...data.items
|
||||
]);
|
||||
this.handleMergeDataList2(showDataList)
|
||||
} else {
|
||||
@ -218,7 +258,7 @@
|
||||
const postLabelMonthKey = "content.halo.run/archive-month"
|
||||
dataList.forEach(item => {
|
||||
let postItemKey = ""
|
||||
if (this.tab.activeIndex == 0) {
|
||||
if (this.tab.activeIndex === 0) {
|
||||
postItemKey =
|
||||
`${item.metadata.labels[postLabelYearKey]}-${item.metadata.labels[postLabelMonthKey]}`
|
||||
} else {
|
||||
@ -313,6 +353,9 @@
|
||||
});
|
||||
},
|
||||
fnToArticleDetail(article) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/article-detail/article-detail?name=' + article.metadata.name,
|
||||
animationType: 'slide-in-right'
|
||||
@ -427,7 +470,8 @@
|
||||
border-radius: 12rpx;
|
||||
background-color: #fff;
|
||||
|
||||
&.lr_image_text {}
|
||||
&.lr_image_text {
|
||||
}
|
||||
|
||||
&.lr_text_image {
|
||||
.post-thumbnail {
|
||||
|
@ -5,25 +5,34 @@
|
||||
* 时间:2024年06月22日 12:00:44
|
||||
* 版本:v0.1.0
|
||||
*/
|
||||
import {DefaultAppConfigs, getAppConfigs, setAppConfigs} from '@/config/index.js'
|
||||
import {DefaultAppConfigs, getAppConfigs, setAppConfigs,setAppMockJson,getAppMockJson} from '@/config/index.js'
|
||||
import v2Config from '@/api/v2/all.config.js'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
configs: getAppConfigs(),
|
||||
mockJson: getAppMockJson(),
|
||||
},
|
||||
getters: {
|
||||
getConfigs(state) {
|
||||
if (state.configs) return state.configs;
|
||||
return getAppConfigs()
|
||||
},
|
||||
getMockJson(state) {
|
||||
if(state.mockJson) return state.mockJson;
|
||||
return getAppMockJson()
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
setConfigs(state, data) {
|
||||
state.configs = data;
|
||||
setAppConfigs(data)
|
||||
},
|
||||
setMockJson(state, data) {
|
||||
setAppMockJson(data)
|
||||
state.mockJson = data;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
fetchConfigs({commit, dispatch}) {
|
||||
@ -47,5 +56,30 @@ export default {
|
||||
setDefaultAppSettings({commit}) {
|
||||
commit('setConfigs', JSON.parse(JSON.stringify(DefaultAppConfigs)))
|
||||
},
|
||||
// 请求模拟数据
|
||||
fetchMockJson({state, commit, dispatch}) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
// const mockJsonUrl = utils.checkUrl(state.configs.basicConfig.auditModeMock)
|
||||
const mockJsonUrl = "https://uni-halo.925i.cn/unihalo.mock.json"
|
||||
uni.request({
|
||||
url: mockJsonUrl,
|
||||
method: "GET",
|
||||
success: (res) => {
|
||||
console.log("mockJson", res.data)
|
||||
commit('setMockJson', res.data)
|
||||
resolve({
|
||||
ok: true,
|
||||
data: res.data
|
||||
})
|
||||
},
|
||||
fail: (err) => {
|
||||
resolve({
|
||||
ok: false,
|
||||
data: err
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user