mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2025-05-19 10:00:13 +09:00
fix: 修复首页文章排序问题、修复文章详情广告问题
This commit is contained in:
parent
0d618e21ce
commit
85f166e7d0
@ -31,6 +31,7 @@ http.setConfig((config) => {
|
|||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
})
|
})
|
||||||
|
|
||||||
setInterceptors(http)
|
setInterceptors(http)
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* 封装各种请求方式
|
* 封装各种请求方式
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
http
|
http
|
||||||
} from '@/common/http/index.js'
|
} from '@/common/http/index.js'
|
||||||
@ -11,7 +9,7 @@ export default {
|
|||||||
Get: (url, params, config = {}) => {
|
Get: (url, params, config = {}) => {
|
||||||
return http.get(url, {
|
return http.get(url, {
|
||||||
params,
|
params,
|
||||||
...config
|
...config
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Post: (url, data, config = {}) => {
|
Post: (url, data, config = {}) => {
|
||||||
@ -26,4 +24,4 @@ export default {
|
|||||||
Delete: (url, data, config = {}) => {
|
Delete: (url, data, config = {}) => {
|
||||||
return http.delete(url, data, config)
|
return http.delete(url, data, config)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -72,13 +72,7 @@ export default {
|
|||||||
loadingEmptyUrl: '', // 加载图片为空地址
|
loadingEmptyUrl: '', // 加载图片为空地址
|
||||||
|
|
||||||
waveImageUrl: '', // 关于页面波浪图片
|
waveImageUrl: '', // 关于页面波浪图片
|
||||||
|
|
||||||
banner: { // 轮播图配置
|
|
||||||
type: 'article', // 轮播图数据源 list=下方配置 article=热门文章封面
|
|
||||||
list: [],
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
// 微信分享信息
|
// 微信分享信息
|
||||||
wxShareConfig: {
|
wxShareConfig: {
|
||||||
title: '', // 小程序分享标题[非必填]
|
title: '', // 小程序分享标题[非必填]
|
||||||
|
@ -6,7 +6,11 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://gitee.com/ialley-workshop-open/uni-halo.git"
|
"url": "git+https://gitee.com/ialley-workshop-open/uni-halo.git"
|
||||||
},
|
},
|
||||||
"keywords": ["uni-halo", "小莫唐尼", "巷子工坊"],
|
"keywords": [
|
||||||
|
"uni-halo",
|
||||||
|
"小莫唐尼",
|
||||||
|
"巷子工坊"
|
||||||
|
],
|
||||||
"author": "巷子工坊丨小莫唐尼",
|
"author": "巷子工坊丨小莫唐尼",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@ -17,6 +21,7 @@
|
|||||||
"vue-i18n": "^9.1.10"
|
"vue-i18n": "^9.1.10"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"qs": "^6.12.1",
|
||||||
"uni-read-pages": "^1.0.5",
|
"uni-read-pages": "^1.0.5",
|
||||||
"uni-simple-router": "^2.0.8-beta.4"
|
"uni-simple-router": "^2.0.8-beta.4"
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,8 @@
|
|||||||
<view :class="globalAppSettings.layout.home">
|
<view :class="globalAppSettings.layout.home">
|
||||||
<tm-translate v-for="(article, index) in articleList" :key="index" class="ani-item"
|
<tm-translate v-for="(article, index) in articleList" :key="index" class="ani-item"
|
||||||
animation-name="fadeUp" :wait="calcAniWait(index)">
|
animation-name="fadeUp" :wait="calcAniWait(index)">
|
||||||
<article-card from="home" :article="article" :post="article" @on-click="fnToArticleDetail"></article-card>
|
<article-card from="home" :article="article" :post="article"
|
||||||
|
@on-click="fnToArticleDetail"></article-card>
|
||||||
</tm-translate>
|
</tm-translate>
|
||||||
</view>
|
</view>
|
||||||
<view class="load-text mt-12">{{ loadMoreText }}</view>
|
<view class="load-text mt-12">{{ loadMoreText }}</view>
|
||||||
@ -84,6 +85,7 @@
|
|||||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||||
|
|
||||||
import eSwiper from '@/components/e-swiper/e-swiper.vue';
|
import eSwiper from '@/components/e-swiper/e-swiper.vue';
|
||||||
|
import qs from 'qs'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -100,7 +102,8 @@
|
|||||||
loading: 'loading',
|
loading: 'loading',
|
||||||
queryParams: {
|
queryParams: {
|
||||||
size: 5,
|
size: 5,
|
||||||
page: 1
|
page: 1,
|
||||||
|
sort: ['spec.pinned,desc', 'spec.publishTime,desc']
|
||||||
},
|
},
|
||||||
result: {},
|
result: {},
|
||||||
isLoadMore: false,
|
isLoadMore: false,
|
||||||
@ -110,7 +113,6 @@
|
|||||||
noticeList: [],
|
noticeList: [],
|
||||||
articleList: [],
|
articleList: [],
|
||||||
categoryList: [],
|
categoryList: [],
|
||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -180,58 +182,39 @@
|
|||||||
// 获取轮播图
|
// 获取轮播图
|
||||||
fnGetBanner() {
|
fnGetBanner() {
|
||||||
const _this = this;
|
const _this = this;
|
||||||
const _format = function(list, type) {
|
const _format = function(list) {
|
||||||
console.log("list", list)
|
|
||||||
return list.map((item, index) => {
|
return list.map((item, index) => {
|
||||||
switch (type) {
|
return {
|
||||||
case 'list':
|
mp4: '',
|
||||||
return {
|
id: item.metadata.name,
|
||||||
id: index,
|
nickname: item.owner.displayName,
|
||||||
nickname: _this.bloggerInfo.nickname,
|
avatar: _this.$utils.checkImageUrl(item.owner.avatar),
|
||||||
avatar: _this.bloggerInfo.avatar,
|
address: '',
|
||||||
address: item.href || '',
|
createTime: uni.$tm.dayjs(item.spec.publishTime).fromNow(),
|
||||||
title: item.title,
|
title: item.spec.title,
|
||||||
image: _this.$utils.checkImageUrl(item.thumbnail)
|
src: _this.$utils.checkImageUrl(item.spec.cover),
|
||||||
};
|
image: _this.$utils.checkImageUrl(item.spec.cover)
|
||||||
case 'article':
|
};
|
||||||
return {
|
|
||||||
mp4: '',
|
|
||||||
id: item.metadata.name,
|
|
||||||
nickname: item.owner.displayName,
|
|
||||||
avatar: _this.$utils.checkImageUrl(item.owner.avatar),
|
|
||||||
address: '',
|
|
||||||
createTime: uni.$tm.dayjs(item.spec.publishTime).fromNow(),
|
|
||||||
title: item.spec.title,
|
|
||||||
src: _this.$utils.checkImageUrl(item.spec.cover),
|
|
||||||
image: _this.$utils.checkImageUrl(item.spec.cover)
|
|
||||||
};
|
|
||||||
case 'banner':
|
|
||||||
return {
|
|
||||||
id: '',
|
|
||||||
src: item
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
switch (this.$haloConfig.banner.type) {
|
|
||||||
case 'list': // 手动配置的banner
|
const paramsStr = qs.stringify(this.queryParams, {
|
||||||
this.bannerList = _format(this.$haloConfig.banner.list, 'list');
|
allowDots: true,
|
||||||
break;
|
encodeValuesOnly: true,
|
||||||
case 'article': // 来自热门文章的封面
|
skipNulls: true,
|
||||||
this.$httpApi.getPostList({
|
encode: true,
|
||||||
page: 0,
|
arrayFormat: 'repeat'
|
||||||
size: 6
|
})
|
||||||
}).then(res => {
|
uni.request({
|
||||||
this.bannerList = _format(res.items, 'article');
|
url: '/apis/api.content.halo.run/v1alpha1/posts?' + paramsStr,
|
||||||
if (this.bannerList.length == 0) {
|
method: 'GET',
|
||||||
this.bannerList = _format(this.$haloConfig.banner.list, 'list');
|
params: this.queryParams,
|
||||||
}
|
success: (res) => {
|
||||||
});
|
this.bannerList = _format(res.data.items);
|
||||||
break;
|
},
|
||||||
case 'banner': // 来自后台配置的banner(暂未开放)
|
fail: (err) => {}
|
||||||
this.bannerList = _format([], 'banner');
|
})
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
fnOnBannerChange(e) {
|
fnOnBannerChange(e) {
|
||||||
this.bannerCurrent = e.current;
|
this.bannerCurrent = e.current;
|
||||||
@ -256,28 +239,37 @@
|
|||||||
}
|
}
|
||||||
this.loadMoreText = '加载中...';
|
this.loadMoreText = '加载中...';
|
||||||
|
|
||||||
this.$httpApi.v2
|
const paramsStr = qs.stringify(this.queryParams, {
|
||||||
.getPostList(this.queryParams)
|
allowDots: true,
|
||||||
.then(res => {
|
encodeValuesOnly: true,
|
||||||
console.log('加载成功', res);
|
skipNulls: true,
|
||||||
this.result.hasNext = res.hasNext;
|
encode: true,
|
||||||
|
arrayFormat: 'repeat'
|
||||||
|
})
|
||||||
|
uni.request({
|
||||||
|
url: '/apis/api.content.halo.run/v1alpha1/posts?' + paramsStr,
|
||||||
|
method: 'GET',
|
||||||
|
params: this.queryParams,
|
||||||
|
success: (res) => {
|
||||||
|
const data = res.data;
|
||||||
|
this.result.hasNext = data.hasNext;
|
||||||
if (this.isLoadMore) {
|
if (this.isLoadMore) {
|
||||||
this.articleList = this.articleList.concat(res.items);
|
this.articleList = this.articleList.concat(data.items);
|
||||||
} else {
|
} else {
|
||||||
this.articleList = res.items;
|
this.articleList = data.items;
|
||||||
}
|
}
|
||||||
this.loading = 'success';
|
this.loading = 'success';
|
||||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
this.loadMoreText = data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||||
})
|
uni.hideLoading();
|
||||||
.catch(err => {
|
uni.stopPullDownRefresh();
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
this.loading = 'error';
|
this.loading = 'error';
|
||||||
this.loadMoreText = '加载失败,请下拉刷新!';
|
this.loadMoreText = '加载失败,请下拉刷新!';
|
||||||
uni.$tm.toast(err.message || '数据加载失败!');
|
uni.$tm.toast(err.message || '数据加载失败!');
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
uni.hideLoading();
|
|
||||||
uni.stopPullDownRefresh();
|
uni.stopPullDownRefresh();
|
||||||
});
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
//跳转文章详情
|
//跳转文章详情
|
||||||
|
@ -72,16 +72,6 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 广告区域 -->
|
|
||||||
<view v-if="haloAdConfig.articleDetail.use && (haloAdConfig.unitId || haloAdConfig.adpid)"
|
|
||||||
class="ad-wrap ma-24 mb-0">
|
|
||||||
<!-- #ifdef MP-WEIXIN -->
|
|
||||||
<ad v-if="haloAdConfig.unitId" :unit-id="haloAdConfig.unitId"></ad>
|
|
||||||
<!-- #endif -->
|
|
||||||
<!-- #ifndef MP-WEIXIN -->
|
|
||||||
<ad v-if="haloAdConfig.adpid" :adpid="haloAdConfig.adpid"></ad>
|
|
||||||
<!-- #endif -->
|
|
||||||
</view>
|
|
||||||
<!-- 内容区域 -->
|
<!-- 内容区域 -->
|
||||||
<view class="content ml-24 mr-24">
|
<view class="content ml-24 mr-24">
|
||||||
<!-- markdown渲染 -->
|
<!-- markdown渲染 -->
|
||||||
@ -101,19 +91,8 @@
|
|||||||
</template>
|
</template>
|
||||||
</tm-more>
|
</tm-more>
|
||||||
</view>
|
</view>
|
||||||
<!-- 广告区域:微信/decloud申请 -->
|
|
||||||
<view v-if="haloAdConfig.articleDetail.use && (haloAdConfig.unitId || haloAdConfig.adpid)"
|
|
||||||
class="ad-wrap mt-24 mb-24 ">
|
|
||||||
<!-- #ifdef MP-WEIXIN -->
|
|
||||||
<ad v-if="haloAdConfig.unitId" :unit-id="haloAdConfig.unitId"></ad>
|
|
||||||
<!-- #endif -->
|
|
||||||
<!-- #ifndef MP-WEIXIN -->
|
|
||||||
<ad v-if="haloAdConfig.adpid" :adpid="haloAdConfig.adpid"></ad>
|
|
||||||
<!-- #endif -->
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 广告区域:自定义广告位 -->
|
<!-- 广告区域:自定义广告位 -->
|
||||||
<view class="ad-card mt-24" v-if="haloAdConfig.articleDetail.custom.use">
|
<view class="ad-card mt-24" v-if="haloAdConfig.articleDetail.custom">
|
||||||
<text class="ad-card_tip">广告</text>
|
<text class="ad-card_tip">广告</text>
|
||||||
<image class="ad-card_cover" :src="haloAdConfig.articleDetail.custom.cover" mode="scaleToFill">
|
<image class="ad-card_cover" :src="haloAdConfig.articleDetail.custom.cover" mode="scaleToFill">
|
||||||
</image>
|
</image>
|
||||||
|
Loading…
Reference in New Issue
Block a user