鏡像自
https://github.com/ialley-workshop-open/uni-halo.git
已同步 2026-06-11 12:49:30 +08:00
feat: 新增首页轮播支持配置
此提交包含在:
+9
-2
@@ -31,8 +31,15 @@ export default {
|
||||
// #endif
|
||||
|
||||
// 获取mockjson
|
||||
if (res.basicConfig.auditModeEnabled) {
|
||||
await uni.$tm.vx.actions('config/fetchMockJson')
|
||||
if (res.auditConfig.auditModeEnabled) {
|
||||
if (res.auditConfig.auditModeData.jsonUrl) {
|
||||
await uni.$tm.vx.actions('config/fetchMockJson')
|
||||
} else {
|
||||
const mockJson = uni.$utils.checkJsonAndParse(res.auditConfig.auditModeData.jsonData)
|
||||
if (mockJson.ok) {
|
||||
uni.$tm.vx.commit('config/setMockJson', mockJson.jsonData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 进入检查
|
||||
|
||||
@@ -152,7 +152,9 @@ export default {
|
||||
},
|
||||
copyrightConfig() {
|
||||
return this.haloConfigs.basicConfig.copyrightConfig;
|
||||
}
|
||||
}, calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
haloConfigs: {
|
||||
@@ -180,10 +182,10 @@ export default {
|
||||
this.navList = [
|
||||
{
|
||||
key: 'archives',
|
||||
title: this.haloConfigs.basicConfig.auditModeEnabled ? '内容归档' : '文章归档',
|
||||
title: this.calcAuditModeEnabled ? '内容归档' : '文章归档',
|
||||
leftIcon: 'halocoloricon-classify',
|
||||
leftIconColor: 'red',
|
||||
rightText: this.haloConfigs.basicConfig.auditModeEnabled ? '已归档的内容' : '已归档的文章',
|
||||
rightText: this.calcAuditModeEnabled ? '已归档的内容' : '已归档的文章',
|
||||
path: '/pagesA/archives/archives',
|
||||
isAdmin: false,
|
||||
type: 'page',
|
||||
@@ -396,7 +398,7 @@ export default {
|
||||
url: '/pagesC/website/website?data=' +
|
||||
JSON.stringify({
|
||||
title: item.text || this.$haloConfig.title,
|
||||
url: item.path
|
||||
url: encodeURIComponent(item.path)
|
||||
})
|
||||
});
|
||||
return;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<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 v-if="!haloConfigs.basicConfig.auditModeEnabled" style="font-size: 24rpx;color: #ffffff;margin-top: 6rpx;">
|
||||
<view v-if="!calcAuditModeEnabled" style="font-size: 24rpx;color: #ffffff;margin-top: 6rpx;">
|
||||
共 {{ item.postCount }} 篇文章
|
||||
</view>
|
||||
<view v-else style="font-size: 24rpx;color: #ffffff;margin-top: 6rpx;">
|
||||
@@ -73,6 +73,9 @@ export default {
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
calcAuditModeEnabled(){
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
}
|
||||
@@ -87,7 +90,7 @@ export default {
|
||||
},
|
||||
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
@@ -107,7 +110,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
fnGetData() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.dataList = this.mockJson.category.list.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
@@ -176,7 +179,7 @@ export default {
|
||||
})
|
||||
},
|
||||
handleToCategory(data) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
|
||||
@@ -100,7 +100,10 @@ export default {
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
}
|
||||
},
|
||||
calcAuditModeEnabled(){
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
galleryConfig: {
|
||||
@@ -120,7 +123,7 @@ export default {
|
||||
this.fnGetData(true);
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
@@ -148,7 +151,7 @@ export default {
|
||||
this.fnGetData(true);
|
||||
},
|
||||
fnGetCategory() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.fnGetData(true);
|
||||
return
|
||||
}
|
||||
@@ -169,7 +172,7 @@ export default {
|
||||
});
|
||||
},
|
||||
fnGetData(isClearWaterfall = false) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.dataList = this.mockJson.gallery.list.map(item => {
|
||||
return {
|
||||
metadata: {
|
||||
|
||||
+98
-37
@@ -21,16 +21,18 @@
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<block v-else>
|
||||
<view class="bg-white pb-24">
|
||||
<view v-if="bannerConfig.enabled" 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
|
||||
height="400rpx"
|
||||
dotPosition="right"
|
||||
:autoplay="true"
|
||||
:useDot="false"
|
||||
:list="bannerList"
|
||||
:height="bannerConfig.height"
|
||||
:dotPosition="bannerConfig.dotPosition"
|
||||
:autoplay="true"
|
||||
:useDot="bannerConfig.showIndicator"
|
||||
:showTitle="bannerConfig.showTitle"
|
||||
:type="bannerConfig.type"
|
||||
:list="bannerList"
|
||||
@on-click="fnOnBannerClick"
|
||||
/>
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 精品分类 -->
|
||||
@@ -86,6 +88,11 @@
|
||||
icon="icon-angle-up"></tm-flotbutton>
|
||||
</block>
|
||||
</block>
|
||||
|
||||
|
||||
<!-- 弹窗 -->
|
||||
<NotifyDialog v-if="notify.show" :show="notify.show" :title="notify.data.title" :content="notify.data.content"
|
||||
:url="notify.data.url" @on-change="fnOnNotifyChange"></NotifyDialog>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -98,6 +105,7 @@ import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
|
||||
import eSwiper from '@/components/e-swiper/e-swiper.vue';
|
||||
import NotifyDialog from "@/components/notify-dialog/notify-dialog.vue";
|
||||
import qs from 'qs'
|
||||
|
||||
export default {
|
||||
@@ -108,7 +116,8 @@ export default {
|
||||
tmFlotbutton,
|
||||
tmIcons,
|
||||
tmEmpty,
|
||||
eSwiper
|
||||
eSwiper,
|
||||
NotifyDialog
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -126,6 +135,10 @@ export default {
|
||||
noticeList: [],
|
||||
articleList: [],
|
||||
categoryList: [],
|
||||
notify: {
|
||||
show: false,
|
||||
data: {}
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -145,14 +158,20 @@ export default {
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
calcIsShowCategory() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled && this.categoryList.length !== 0) {
|
||||
if (this.calcAuditModeEnabled && this.categoryList.length !== 0) {
|
||||
return false
|
||||
}
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return false
|
||||
}
|
||||
return this.haloConfigs.pageConfig.homeConfig.useCategory
|
||||
},
|
||||
bannerConfig() {
|
||||
return this.haloConfigs.pageConfig.homeConfig.bannerConfig
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@@ -167,7 +186,7 @@ export default {
|
||||
this.fnQuery();
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
@@ -187,13 +206,12 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
fnQuery() {
|
||||
console.log('this.mockJson', this.mockJson)
|
||||
this.fnGetBanner();
|
||||
this.fnGetArticleList();
|
||||
this.fnGetCategoryList();
|
||||
},
|
||||
fnGetCategoryList() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.categoryList = this.mockJson.home.categoryList.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
@@ -215,8 +233,8 @@ export default {
|
||||
|
||||
this.$httpApi.v2
|
||||
.getCategoryList({
|
||||
fieldSelector:['spec.hideFromList=false']
|
||||
})
|
||||
fieldSelector: ['spec.hideFromList=false']
|
||||
})
|
||||
.then(res => {
|
||||
this.categoryList = res.items.sort((a, b) => {
|
||||
return b.postCount - a.postCount;
|
||||
@@ -239,7 +257,7 @@ export default {
|
||||
},
|
||||
// 获取轮播图
|
||||
fnGetBanner() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.bannerList = this.mockJson.home.bannerList.map((item) => {
|
||||
return {
|
||||
mp4: '',
|
||||
@@ -250,27 +268,37 @@ export default {
|
||||
createTime: item.time,
|
||||
title: item.title,
|
||||
src: this.$utils.checkThumbnailUrl(item.cover),
|
||||
image: this.$utils.checkThumbnailUrl(item.cover)
|
||||
image: this.$utils.checkThumbnailUrl(item.cover),
|
||||
type: "custom",
|
||||
content: "",
|
||||
url: ""
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
const _this = this;
|
||||
const _format = function (list) {
|
||||
return list.map((item, index) => {
|
||||
|
||||
|
||||
if (!this.bannerConfig.enabled) return;
|
||||
|
||||
if (this.bannerConfig.type === 'custom') {
|
||||
this.bannerList = this.bannerConfig.list.map((item) => {
|
||||
return {
|
||||
mp4: '',
|
||||
id: item.metadata.name,
|
||||
nickname: item.owner.displayName,
|
||||
avatar: _this.$utils.checkAvatarUrl(item.owner.avatar),
|
||||
id: Date.now() * Math.random(),
|
||||
nickname: this.haloConfigs.authorConfig.blogger.nickname,
|
||||
avatar: this.$utils.checkAvatarUrl(this.haloConfigs.authorConfig.blogger.avatar),
|
||||
address: '',
|
||||
createTime: uni.$tm.dayjs(item.spec.publishTime).fromNow(),
|
||||
title: item.spec.title,
|
||||
src: _this.$utils.checkThumbnailUrl(item.spec.cover),
|
||||
image: _this.$utils.checkThumbnailUrl(item.spec.cover)
|
||||
};
|
||||
});
|
||||
};
|
||||
createTime: "",
|
||||
title: item.title,
|
||||
src: this.$utils.checkThumbnailUrl(item.cover),
|
||||
image: this.$utils.checkThumbnailUrl(item.cover),
|
||||
type: "custom",
|
||||
content: item.content,
|
||||
url: item.url
|
||||
}
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
const paramsStr = qs.stringify(this.queryParams, {
|
||||
allowDots: true,
|
||||
@@ -283,20 +311,53 @@ export default {
|
||||
url: this.$baseApiUrl + '/apis/api.content.halo.run/v1alpha1/posts?' + paramsStr,
|
||||
method: 'GET',
|
||||
success: (res) => {
|
||||
this.bannerList = _format(res.data.items);
|
||||
this.bannerList = res.data.items.map((item, index) => {
|
||||
return {
|
||||
mp4: '',
|
||||
id: item.metadata.name,
|
||||
nickname: item.owner.displayName,
|
||||
avatar: this.$utils.checkAvatarUrl(item.owner.avatar),
|
||||
address: '',
|
||||
createTime: uni.$tm.dayjs(item.spec.publishTime).fromNow(),
|
||||
title: item.spec.title,
|
||||
src: this.$utils.checkThumbnailUrl(item.spec.cover),
|
||||
image: this.$utils.checkThumbnailUrl(item.spec.cover),
|
||||
type: "post",
|
||||
content: item.status.excerpt,
|
||||
url: ""
|
||||
};
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
fnOnBannerChange(e) {
|
||||
this.bannerCurrent = e.current;
|
||||
fnOnNotifyChange(e) {
|
||||
this.notify.show = e;
|
||||
},
|
||||
fnOnBannerClick(item) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
if (item.type === 'custom') {
|
||||
if (item.content) {
|
||||
this.notify.data = item
|
||||
this.notify.show = true
|
||||
return;
|
||||
}
|
||||
if (uni.$utils.checkIsUrl(item.url)) {
|
||||
uni.navigateTo({
|
||||
url: '/pagesC/website/website?data=' +
|
||||
JSON.stringify({
|
||||
title: item.title || "加载中...",
|
||||
url: encodeURIComponent(item.url)
|
||||
})
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.id === '') return;
|
||||
this.fnToArticleDetail({
|
||||
metadata: {
|
||||
@@ -306,7 +367,7 @@ export default {
|
||||
},
|
||||
// 文章列表
|
||||
fnGetArticleList() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.articleList = this.mockJson.home.postList.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
@@ -371,7 +432,7 @@ export default {
|
||||
},
|
||||
//跳转文章详情
|
||||
fnToArticleDetail(article) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
@@ -409,7 +470,7 @@ export default {
|
||||
|
||||
// 根据slug查询分类下的文章
|
||||
fnToCategoryBy(category) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
|
||||
@@ -107,7 +107,10 @@ export default {
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
}
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -120,7 +123,7 @@ export default {
|
||||
},
|
||||
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
@@ -140,7 +143,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
fnGetData() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.dataList = this.mockJson.moments.list.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
|
||||
新增問題並參考
封鎖使用者