diff --git a/components/e-swiper/e-swiper.vue b/components/e-swiper/e-swiper.vue index 82f1572..e1784bb 100644 --- a/components/e-swiper/e-swiper.vue +++ b/components/e-swiper/e-swiper.vue @@ -43,7 +43,7 @@ - {{ title }} + {{ title }} @@ -63,7 +63,7 @@ - {{ item.title }} + {{ item.title }} @@ -217,4 +217,4 @@ \ No newline at end of file + diff --git a/components/notify-dialog/notify-dialog.vue b/components/notify-dialog/notify-dialog.vue new file mode 100644 index 0000000..f6895e5 --- /dev/null +++ b/components/notify-dialog/notify-dialog.vue @@ -0,0 +1,93 @@ + + + + + + + diff --git a/config/index.js b/config/index.js index b58ff4f..1b45f73 100644 --- a/config/index.js +++ b/config/index.js @@ -4,6 +4,7 @@ export const _AppMockJsonKey = 'APP_GLOBAL_MOCK_JSON'; // 默认的应用设置 export const DefaultAppConfigs = { + basicConfig: {}, loveConfig: {}, imagesConfig: {}, authorConfig: {}, @@ -12,7 +13,28 @@ export const DefaultAppConfigs = { toolsPlugin: {}, linksSubmitPlugin: {}, }, - pageConfig: {} + pageConfig: { + homeConfig: { + pageTitle: "首页", + useCategory: true, + bannerConfig: { + enabled: true, + showTitle: true, + showIndicator: true, + height: "400rpx", + dotPosition: "right", + type: "post", + list: [] + } + } + }, + auditConfig: { + auditModeEnabled: false, + auditModeData: { + jsonUrl: "", + jsonData: "" + } + } } /** diff --git a/main.js b/main.js index 13d44f5..de7c2b3 100644 --- a/main.js +++ b/main.js @@ -4,6 +4,7 @@ import Vue from "vue"; // 挂载全局工具类 import utils from "./utils/index.js"; Vue.prototype.$utils = utils; +uni.$utils = utils; // 全局统一样式的对话框 import Fy from '@/js_sdk/fy-showModal/index.js' diff --git a/pages/index/index.vue b/pages/index/index.vue index 68881e8..7d00a6f 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -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) + } + } } // 进入检查 diff --git a/pages/tabbar/about/about.vue b/pages/tabbar/about/about.vue index eaf0569..37d3dc1 100644 --- a/pages/tabbar/about/about.vue +++ b/pages/tabbar/about/about.vue @@ -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; diff --git a/pages/tabbar/category/category.vue b/pages/tabbar/category/category.vue index c056cad..c8e249f 100644 --- a/pages/tabbar/category/category.vue +++ b/pages/tabbar/category/category.vue @@ -19,7 +19,7 @@ {{ item.spec.displayName }} - + 共 {{ item.postCount }} 篇文章 @@ -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({ diff --git a/pages/tabbar/gallery/gallery.vue b/pages/tabbar/gallery/gallery.vue index 0a63398..7d0c1df 100644 --- a/pages/tabbar/gallery/gallery.vue +++ b/pages/tabbar/gallery/gallery.vue @@ -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: { diff --git a/pages/tabbar/home/home.vue b/pages/tabbar/home/home.vue index e6f8bd1..a38c9b0 100644 --- a/pages/tabbar/home/home.vue +++ b/pages/tabbar/home/home.vue @@ -21,16 +21,18 @@ - + @@ -86,6 +88,11 @@ icon="icon-angle-up"> + + + + @@ -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({ diff --git a/pages/tabbar/moments/moments.vue b/pages/tabbar/moments/moments.vue index 67ee95c..f7ab259 100644 --- a/pages/tabbar/moments/moments.vue +++ b/pages/tabbar/moments/moments.vue @@ -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: { diff --git a/pagesA/archives/archives.vue b/pagesA/archives/archives.vue index da1b940..e3df6da 100644 --- a/pagesA/archives/archives.vue +++ b/pagesA/archives/archives.vue @@ -18,7 +18,7 @@ - + @@ -37,7 +37,7 @@ {{ item.year }}年 {{ item.month }}月 - + (共 {{ item.posts.length }} 篇内容) @@ -128,7 +128,10 @@ export default { }, mockJson() { return this.$tm.vx.getters().getMockJson; - } + }, + calcAuditModeEnabled() { + return this.haloConfigs.auditConfig.auditModeEnabled + }, }, created() { this.fnGetData(); @@ -139,7 +142,7 @@ export default { this.fnGetData(); }, onReachBottom(e) { - if (this.haloConfigs.basicConfig.auditModeEnabled) { + if (this.calcAuditModeEnabled) { uni.showToast({ icon: 'none', title: '没有更多数据了' @@ -165,7 +168,7 @@ export default { this.fnToTopPage(); }, fnGetData() { - if (this.haloConfigs.basicConfig.auditModeEnabled) { + if (this.calcAuditModeEnabled) { const dataList = this.mockJson.archives.list.map(item => { const date = new Date(item.time) const year = date.getFullYear() @@ -353,7 +356,7 @@ export default { }); }, fnToArticleDetail(article) { - if (this.haloConfigs.basicConfig.auditModeEnabled) { + if (this.calcAuditModeEnabled) { return; } uni.navigateTo({ diff --git a/pagesA/article-detail/article-detail.vue b/pagesA/article-detail/article-detail.vue index e014d0b..b139e82 100644 --- a/pagesA/article-detail/article-detail.vue +++ b/pagesA/article-detail/article-detail.vue @@ -1067,7 +1067,7 @@ export default { url: '/pagesC/website/website?data=' + JSON.stringify({ title: data.title, - url: data.url + url: encodeURIComponent(data.url) }) }); }, diff --git a/pagesA/articles/articles.vue b/pagesA/articles/articles.vue index 25e3aa3..b743887 100644 --- a/pagesA/articles/articles.vue +++ b/pagesA/articles/articles.vue @@ -85,9 +85,12 @@ export default { }; }, computed: { - haloConfigs() { - return this.$tm.vx.getters().getConfigs; - }, + haloConfigs() { + return this.$tm.vx.getters().getConfigs; + }, + calcAuditModeEnabled() { + return this.haloConfigs.auditConfig.auditModeEnabled + }, }, onLoad() { this.fnSetPageTitle('内容搜索'); @@ -130,11 +133,11 @@ export default { } }, fnGetData() { - if (this.haloConfigs.basicConfig.auditModeEnabled) { - return; + if (this.calcAuditModeEnabled) { + return; } // 设置状态为加载中 - this.loading = 'loading'; + this.loading = 'loading'; this.$httpApi.v2 .getPostListByKeyword(this.queryParams) .then(res => { diff --git a/pagesA/friend-links/friend-links.vue b/pagesA/friend-links/friend-links.vue index 8893e0f..9de9f9c 100644 --- a/pagesA/friend-links/friend-links.vue +++ b/pagesA/friend-links/friend-links.vue @@ -166,7 +166,10 @@ export default { } return 'https://image.thum.io/get/width/1000/crop/800/' + val; }; - } + }, + calcAuditModeEnabled() { + return this.haloConfigs.auditConfig.auditModeEnabled + }, }, onLoad() { this.fnSetPageTitle('友情链接'); @@ -210,8 +213,8 @@ export default { return this.linkGroupList.find(item => item.metadata.name === groupName)?.spec?.displayName || groupName || "未分组" }, fnGetData() { - if (this.haloConfigs.basicConfig.auditModeEnabled) { - return; + if (this.calcAuditModeEnabled) { + return; } if (!this.isLoadMore) { this.loading = 'loading'; diff --git a/pagesC/website/website.vue b/pagesC/website/website.vue index a484f48..cecba06 100644 --- a/pagesC/website/website.vue +++ b/pagesC/website/website.vue @@ -14,8 +14,10 @@ export default { }, onLoad(e) { const {title, url} = JSON.parse(e.query.data); - this.webUrl = url; - this.fnSetPageTitle(title); + this.webUrl = decodeURIComponent(url); + if (title) { + this.fnSetPageTitle(title); + } } }; diff --git a/tm-vuetify/components/tm-poup/tm-poup.vue b/tm-vuetify/components/tm-poup/tm-poup.vue index 20038b1..26d15d4 100644 --- a/tm-vuetify/components/tm-poup/tm-poup.vue +++ b/tm-vuetify/components/tm-poup/tm-poup.vue @@ -15,13 +15,13 @@ @@ -178,7 +178,7 @@ dhshiKa:true,//是否结束动画 aniData:null, timdiiid:6369784254, - + }; }, deactivated() { @@ -198,7 +198,7 @@ this.close(); }, close() { - let t = this; + let t = this; clearTimeout(this.timdiiid) this.dhshiKa=false; t.aniOn=false; @@ -213,18 +213,18 @@ open() { let t = this; clearTimeout(this.timdiiid) - - + + this.dhshiKa=false this.aniOn=true; - + this.createBtT(this.position_sv,'on').then(()=>{ t.dhshiKa=true - + t.isclick=false // console.log('on'); }) - + }, //下至上。 createBtT(pos,type){ @@ -239,60 +239,60 @@ if(type=='on'){ aniData.translateY('0%').step(); this.aniData = aniData.export() - + } if(type=='off'){ aniData.translateY('100%').step(); this.aniData = aniData.export() - + } }else if(pos=='top'){ if(type=='on'){ aniData.translateY('0%').step(); this.aniData = aniData.export() - + } if(type=='off'){ aniData.translateY('-100%').step(); this.aniData = aniData.export() - + } }else if(pos=='left'){ if(type=='on'){ aniData.translateX('0%').step(); this.aniData = aniData.export() - + } if(type=='off'){ aniData.translateX('-100%').step(); this.aniData = aniData.export() - + } }else if(pos=='right'){ if(type=='on'){ aniData.translateX('0%').step(); this.aniData = aniData.export() - + } if(type=='off'){ aniData.translateX('100%').step(); this.aniData = aniData.export() - + } }else if(pos=='center'){ - + if(type=='on'){ aniData.opacity(1).scale(1).step(); this.aniData = aniData.export() - + } if(type=='off'){ aniData.opacity(0).scale(0.6).step(); this.aniData = aniData.export() - + } } - + return new Promise(res=>{ t.timdiiid = setTimeout(()=>{ t.aniData = null; @@ -319,7 +319,7 @@ overflow: hidden; top: 0; left: 0; - + &.isClickbled { pointer-events: none; } @@ -346,7 +346,7 @@ transform: translateY(100%); width: 100%; bottom: 0; - + } &.top { @@ -382,7 +382,7 @@ justify-content: center; align-items: center; align-content: center; - + .tm-poup-wk { position: static; diff --git a/utils/index.js b/utils/index.js index 3dc1821..f64dc4c 100644 --- a/utils/index.js +++ b/utils/index.js @@ -160,6 +160,24 @@ const utils = { urls: list, loop: true }) + }, + /** + * 检查是否为json字符串 + * @param {Object} jsonStr 数据源 + */ + checkJsonAndParse(jsonStr) { + try { + const jsonResult = JSON.parse(jsonStr); + return { + ok: true, + jsonData: jsonResult, + } + } catch (e) { + return { + ok: false, + jsonData: {}, + } + } } };