diff --git a/.gitignore b/.gitignore index 30a66b9..8cc86a6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,7 @@ unpackage/ package-lock.json .idea -config/halo.config.js -config/ad.config.js +config/halo.config.js config/love.config.js config/token.config.js config/plugins.config.js diff --git a/App.vue b/App.vue index 69ee5ea..024fbe7 100644 --- a/App.vue +++ b/App.vue @@ -1,7 +1,5 @@ + \ No newline at end of file diff --git a/config/ad.config.template.js b/config/ad.config.template.js deleted file mode 100644 index b019649..0000000 --- a/config/ad.config.template.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * 广告配置 - */ -export default { - // 文章详情广告 - articleDetail: { - use: true, - cover: 'https://b.925i.cn/uni_halo/uni_halo_ad_cover.png', - title: 'uni-halo 正式开源啦,欢迎来使用和体验!', - content: '基于 uni-app + halo1.x API 实现一款现代化的开源博客 / CMS 系统API开发的多端应用。功能包括:前台博客系统 和 后台管理系统,同时满足浏览和管理两端合一的需求,真正实现一个应用实现博客浏览和后台管理。', - url: 'https://uni-halo.925i.cn' - }, - rewardedVideoAd: '微信小程序激励广告id' // 奖励视频广告 -} \ No newline at end of file diff --git a/config/halo.config.template.js b/config/halo.config.template.js deleted file mode 100644 index 997495d..0000000 --- a/config/halo.config.template.js +++ /dev/null @@ -1,94 +0,0 @@ -/** - * 功能:基础配置 - * 作者:小莫唐尼 - * 邮箱:studio@925i.cn - * 时间:2022年08月23日 15:19:14 - * 版本:v0.1.0 - * 修改记录: - * 修改内容: - * 修改人员: - * 修改时间: - */ -export default { - showCopyright: true, // 显示开源版权信息 - showAbout: true, // 显示关于项目入口 - uni_halo_logo: 'https://b.925i.cn/uni_halo/uni_halo_logo.png', // uni-halo的logo - - title: '', // 博客标题 [建议必填]:在某些页面没有设置具体的页面名称时候,使用该值显示 - miniCodeImageUrl: '', // 小程序的太阳码/二维码的图片地址 [建议必填] - - aboutProfileImageUrl: '', // 关于页面中的资料卡背景图 [建议必填] - - // 启动页面的配置(页面地址`/pagesA/start/start`) - start: { - use: true, // 是否使用首次启动页:用户第一次使用你的应用会显示否则不显示 - title: 'uni-halo2.0', // 标题 - bg: '', // 留空则使用默认 开屏首页背景,可以是颜色值或者图片图片地址 - logo: 'https://b.925i.cn/uni_halo/uni_halo_logo.png', // 开屏首页图片 - desc1: '准备好了吗,即刻就出发', // 描述信息1 - desc2: '新触动 新感受 新体验', // 描述信息2 - btnText: '立即体验' - }, - - // 博主信息 - author: { - use: true, // 是否启用这里配置的信息,不启用则获取PC端博客设置的信息 - nickname: '', // 昵称 - avatar: '', // 头像 - email: '', // 邮箱 - description: '', // 介绍 - }, - - // 版权信息(用于文章详情) - copyright: { - use: true, // 是否使用版权描述 - author: '', // 版权归属说明 - description: '', // 版权描述 - violation: '', // 侵权处理说明 - }, - - // 社交信息(将会在`/pagesA/contact/contact`页面中展示) - // 具体的某个参数值留空则不展示 - social: { - qq: "", // qq号 - wechat: "", // 微信号 - weibo: "", // 微博地址 - email: "", // 邮箱地址 - blog: "", // 博客地址 - juejin: "", // 掘金地址 - bilibili: "", // b站地址 - gitee: "", // gitee地址 - github: "", // github地址 - csdn: "" // CSDN地址 - }, - - defaultThumbnailUrl: '', // 默认封面图地址 - defaultStaticThumbnailUrl: '', // 静态默认封面图(不可以是随机图地址) - defaultImageUrl: '', // 默认图片地址 - defaultAvatarUrl: '', // 默认头像地址 - - loadingGifUrl: '', // 图片加载中的地址 - loadingErrUrl: '', // 图片加载失败的地址 - loadingEmptyUrl: '', // 加载图片为空地址 - - waveImageUrl: '', // 关于页面波浪图片 - - // 微信分享信息 - wxShareConfig: { - title: '', // 小程序分享标题[非必填] - desc: '', // 小程序分享描述[非必填] - imageUrl: '', // 小程序分享时候图片地址[非必填] - path: '/pages/index/index', // 分享路径[非必填] - 基本不需要修改 - copyLink: '/pages/index/index', // 复制链接[非必填] - 基本不需要修改 - query: {}, // 分享参数[非必填] - 基本不需要填写 - }, - - colors: [ - '#39B449', - '#E44C41', - '#8698A2', - '#0080FE', - '#1CBCB4', - '#6638B5', - ] -} \ No newline at end of file diff --git a/config/index.js b/config/index.js new file mode 100644 index 0000000..4df37d1 --- /dev/null +++ b/config/index.js @@ -0,0 +1,30 @@ +// 应用设置存储key值 +export const _AppConfigKey = 'APP_GLOBAL_CONFIGS'; + +// 默认的应用设置 +export const DefaultAppConfigs = { + loveConfig: {}, + imagesConfig: {}, + authorConfig: {}, + startConfig: {}, + pluginConfig: {}, + adConfig: {}, +} + +/** + * 获取应用设置 + */ +export const getAppConfigs = () => { + let configs = uni.getStorageSync(_AppConfigKey) + if (configs) return JSON.parse(configs) + + uni.setStorageSync(_AppConfigKey, JSON.stringify(DefaultAppConfigs)) + return configs; +} + +/** + * 保存应用设置 + */ +export const setAppConfigs = (configs) => { + uni.setStorageSync(_AppConfigKey, JSON.stringify(configs)) +} \ No newline at end of file diff --git a/config/love.config.js b/config/love.config.js deleted file mode 100644 index b381306..0000000 --- a/config/love.config.js +++ /dev/null @@ -1,148 +0,0 @@ -/** - * 恋爱日记配置 - */ -export default { - waveImageUrl: 'https://b.925i.cn/uni_halo/uni_halo_about_wave.gif', // 波浪图片地址 - bgImageUrl: 'https://b.925i.cn/uni_halo_love/love_bg1.png', // 背景图片 - loveImageUrl: 'https://b.925i.cn/uni_halo_love/like.png', // 爱心图片 - - boy: { - name: '未知男主', - avatar: 'https://b.925i.cn/uni_halo_love/love_boy.png', - birthday: '2022-09-25', // 生日 - }, - - girl: { - name: '未知女主', - avatar: 'https://b.925i.cn/uni_halo_love/love_girl.png', - birthday: '2022-04-19', // 生日 - }, - timeTitle: '这是我们一起走过的', - loveStartDate: '2022-04-10 13:14:20', // 恋爱开始时间 - - nav: [{ - key: 'journey', - use: true, - iconImageUrl: 'https://b.925i.cn/uni_halo_love/diandian.png', - title: '关于我们', - desc: '我们一起度过的那些经历' - }, - // { - // key: 'album', - // use: true, - // iconImageUrl: 'https://b.925i.cn/uni_halo_love/diandian.png', - // title: '恋爱相册', - // desc: '定格了我们的那些小美好' - // }, - { - key: 'list', - use: true, - iconImageUrl: 'https://b.925i.cn/uni_halo_love/diandian.png', - title: '恋爱清单', - desc: '你我之间的约定我们都在努力实现' - }, - ], - - // 关于我们:支持富文本内容 - journey: ` - 准备晚安啦,睡觉前讲个故事吧~

槐树庄的村口有一棵大槐树,树下的村口第一家就是猫奶奶的家。

猫奶奶是一位孤寡老人,因为她经常收留和救治周围的流浪猫,所以村民就都管她叫“猫奶奶”。

一个月圆之夜,猫奶奶走到院门口,忽然发现门口石级上放着一个红毯子,里面包着一个啼(tí)哭的女婴。

猫奶奶找不到女婴的父母,只好收留了她,并给她起了个名字叫樱红。

猫奶奶辛苦地抚育着樱红成长,转眼之间,樱红已经九岁,上小学三年级了。

从樱红懂事起,猫奶奶就爱给她讲一个睡前故事,那是当地一个古老的传说。

在浓郁的树影深处有一个百花园,百花园里生长着奇花异草,还住了一个会唱歌的花仙子。花仙子的歌声美丽动人,能治百病。但是那里有一条奇怪的规矩,寻找花仙子的人在进入百花园后,见到花仙子之前,都不能发出一点声音,不然花仙子就不会出来见他。

受这个故事的影响,樱红特别喜欢唱歌。

这天晚上,樱红放学回家,家家户户炊烟袅(niǎo)袅,而自家烟囱却连一丝一缕(lǚ)的炊烟都没有。

樱红一惊,冲进院门一看,果然出事了!只见猫奶奶呻吟着倒在灶台前,双目紧闭,两只小脚也在不停地抽搐(chù)。

樱红慌了,好在有邻居的帮助,猫奶奶被送到了医院。经过抢救,猫奶奶总算醒过来,但是却半身不遂(suí),说话也不利落了。

猫奶奶不能下地行走做家务,小小的樱红,一夜之间就挑起了家庭的重担。

樱红一面求助于村委会,四处寻医问药,让猫奶奶获得进一步的治疗;一面在课余学做家务,悉心照顾猫奶奶,端水喂饭,不辞辛苦。

自从猫奶奶病倒以后,樱红每天早晨推开院门就会看见门前放着一朵小花,有时还会有一两尾鲜活的鲑(guī)鱼。

这样过了三个月,好奇的樱红在一个夜晚悄悄躲在院门的后面,想看看到底是谁。

到了午夜十二点,只见一只花猫衔着一棵风铃草来到院门前,把风铃草放下,转身就走。(浪漫童话小故事)樱红认出这只小花猫曾经被猫奶奶救助过,于是,她悄悄地尾随小花猫往前走。

不一会儿,她就发现自己进入了一个从未见过的世界:蔚蓝的天空飘着七色的云,阳光千丝万缕地落下来,鲜花盛开,彩蝶飞舞,百鸟齐鸣。

这到底是什么地方?她忽然想起了那个传说,这该不会就是花仙子住的百花园吧?

樱红几乎惊叫起来,但她立即想起了那条在见到花仙子之前,不能发出一点声音的规矩。于是她捂紧了嘴巴。

这时,她发现百花园里除了自己还有一个面色苍白的男孩子,闭着眼睛,右手攥着一根竹竿摸索着前行,应该是眼睛看不见了。

只见男孩子慢慢地偏离了路径,马上就要掉进路边的水沟里了。

樱红下意识地大声呼喊:“站住,小心脚底下!”一张口,樱红才想起来,自己已经坏了规矩!

此时,“轰隆”一声巨响后,眼前的一切都消失了,樱红仍然站在自家院门前的大槐树下。

真遗憾啊!樱红深深叹了口气,可为了救人,她并不觉得后悔。

第二天早上,樱红被一种美妙的歌声唤醒。

唱歌的人就是美丽的花仙子,她乘坐着奇花异草编成的花篮,飘进了她家的院子里。

奇迹发生了,只见猫奶奶起身下床,像健康人一样走出房门。

猫奶奶看到了花仙子,不敢相信地揉着眼睛说:“你就是传说中的花仙子吗?是你治好了我的病?”

花仙子说:“是的!是这个小女孩的善良打动了我,连我那不能出声的规矩都要为她破例了。”

樱红高兴地看着猫奶奶。从此,她和猫奶奶继续幸福地生活着。

- `, - // 恋爱相册 - albumKeyName: '恋爱相册', // 对应后台的图库分组名称 - // 恋爱清单 - loveList: { - useApi: false, // 是否启用api接口 - api: '', // api 接口(如果使用api接口的方式,则下方的data可以留空,但是api接口必须按照对应的数据格式返回) - data: [{ - index: 0, // 序号 - finish: true, // 是否已完成 - title: '偷偷记录对方熟睡的模样', // 事件名称 - desc: '偷偷观察对方熟睡的模样,记录下来', // 事件描述 - detail: { - start: '2022年05月20日', // 计划开始时间 - desc: '偷偷观察对方熟睡的模样,记录下来', // 事件详细描述 - end: '每天', // 完成时间, - moment: '', // 完成瞬间的记录 - other: '', // 其他说明 - } - }, { - index: 1, - finish: false, - title: '陪对方过生日', - desc: '陪对方一起过生日', - detail: { - start: '2023年05月20日', - desc: '陪对方一起过生日,他和我的生日', - end: '', - moment: '', - other: '他 生日5月20日 我生日9月25日', - } - }, - { - index: 2, - finish: false, - title: '一起去旅行', - desc: '一起来一场说走就走的旅行,希望去的是大理', - detail: { - start: '', - desc: '', - end: '', - moment: '一起来一场说走就走的旅行,希望去的是大理', - other: '', - } - }, - { - index: 3, - finish: false, - title: '一起穿情侣装逛街', - desc: '一起穿情侣装逛街', - detail: { - start: '', - desc: '', - end: '', - moment: '', - other: '', - } - }, - { - index: 4, - finish: false, - title: '一起看日出', - desc: '一起看日出', - detail: { - start: '', - desc: '', - end: '', - moment: '', - other: '', - } - }, - { - index: 5, - finish: false, - title: '一起看日落', - desc: '一起看日落', - detail: { - start: '', - desc: '', - end: '', - moment: '', - other: '', // 其他说明 - } - }, - { - index: 6, - finish: false, - title: '一起买菜、做饭、刷碗', - desc: '一起买菜、做饭、刷碗', - detail: { - start: '', - desc: '', - end: '', - moment: '', - other: '', - } - } - ], - } -} \ No newline at end of file diff --git a/config/love.config.template.js b/config/love.config.template.js deleted file mode 100644 index 2922a85..0000000 --- a/config/love.config.template.js +++ /dev/null @@ -1,142 +0,0 @@ -/** - * 恋爱日记配置 - */ -export default { - waveImageUrl: 'https://b.925i.cn/uni_halo/uni_halo_about_wave.gif', // 波浪图片地址 - bgImageUrl: 'https://b.925i.cn/uni_halo_love/love_bg1.png', // 背景图片 - loveImageUrl: 'https://b.925i.cn/uni_halo_love/like.png', // 爱心图片 - - boy: { - name: '未知男主', - avatar: 'https://b.925i.cn/uni_halo_love/love_boy.png', - birthday: '2022-09-25', // 生日 - }, - - girl: { - name: '未知女主', - avatar: 'https://b.925i.cn/uni_halo_love/love_girl.png', - birthday: '2022-07-25', // 生日 - }, - - timeTitle: '这是我们一起走过的', // 恋爱时间标题 - loveStartDate: '2022-05-20 13:14:20', // 恋爱开始时间 - - // 恋爱日记首页导航(除了 key 以外都可以修改) - nav: [{ - key: 'journey', - use: true, - iconImageUrl: 'https://b.925i.cn/uni_halo_love/diandian.png', - title: '关于我们', - desc: '我们一起度过的那些经历' - }, - { - key: 'list', - use: true, - iconImageUrl: 'https://b.925i.cn/uni_halo_love/diandian.png', - title: '恋爱清单', - desc: '你我之间的约定我们都在努力实现' - }, - ], - - // 关于我们:支持富文本内容 - journey: ` -

有一只马,它的邻居是一只驴。

有一天,马和驴都被主人牵到外面晒太阳,马和驴聊起了天。

马说:“我叫马,你呢?”

驴说:“我叫驴。(哄小宝贝睡觉的甜甜睡前故事)”

马说:“为什么我俩的名字不一样呢?”

驴说:“因为我和你不一样。”

马说:“我们俩什么地方不一样呢?”

驴说:“我身材小巧,而你却比较粗壮,不如我耐看。”马看了看比自已矮小很多的驴,认为驴说的话有点道理。

马说:“我们俩除了身材不一样,还有什么不同呢?”

驴说:“我们俩的声音不一样,我的声音多动听呀!”说着驴伸长脖子叫了两声。“不信,你也叫两声试试。”马也伸长脖子嘶鸣了两声,的确和驴的声音有点不同,马不好意思地低下了头。

过了一会儿,马又说:“我们俩除了身材和声音不一样外,还有什么不同呢?”

驴说:“我的步伐多么优雅呀。”说着,驴迈开蹄子走了两步,“而你呢,却昂首阔步,一点儿也不优雅,(如何哄女朋友睡觉的睡前故事爱情浪漫)不信你走两步试试。”

马听驴这么一说,就高昂着头走了两步,旋即,马飞奔了起来,转了一圈回来后,驴得意地说:“怎么样,我没说错罢,你就是急性子,和优雅不沾边。”马听了驴的话,有点感到惭愧。

最后,马又鼓起勇气说:“我们俩还有什么不同呢?”

驴说:“我的家庭意识比你强,主人抽我一鞭子,我就跟着主人回家,而你呢?恐怕不会吧……”

马还没有来得及回答,马和驴的主人同时来到了马和驴的身边。只见驴的主人抽了驴一鞭子后,驴乖乖地跟着主人回家了。马把这一切都看在了眼里,它为自已和驴的诸多不同而感到惭愧,只见马的主人也抽了马一鞭子,马犹豫了一下,终于象驴一样乖乖地跟着主人回了家。

一个伯乐站在远处看到了这一幕后,叹口气离开了。

- `, - - // 恋爱清单 - loveList: { - useApi: false, // 是否启用api接口 - api: '', // api 接口(如果使用api接口的方式,则下方的data可以留空,但是api接口必须按照对应的数据格式返回) - data: [{ - index: 0, // 序号 - finish: true, // 是否已完成 - title: '偷偷记录对方熟睡的模样', // 事件名称 - desc: '偷偷观察对方熟睡的模样,记录下来', // 事件描述 - detail: { - start: '2022年05月20日', // 计划开始时间 - desc: '偷偷观察对方熟睡的模样,记录下来', // 事件详细描述 - end: '每天', // 完成时间, - moment: '', // 完成瞬间的记录 - other: '', // 其他说明 - } - }, { - index: 1, - finish: false, - title: '陪对方过生日', - desc: '陪对方一起过生日', - detail: { - start: '2023年05月20日', - desc: '陪对方一起过生日,他和我的生日', - end: '', - moment: '', - other: '他 生日5月20日 我生日9月25日', - } - }, - { - index: 2, - finish: false, - title: '一起去旅行', - desc: '一起来一场说走就走的旅行,希望去的是大理', - detail: { - start: '', - desc: '', - end: '', - moment: '一起来一场说走就走的旅行,希望去的是大理', - other: '', - } - }, - { - index: 3, - finish: false, - title: '一起穿情侣装逛街', - desc: '一起穿情侣装逛街', - detail: { - start: '', - desc: '', - end: '', - moment: '', - other: '', - } - }, - { - index: 4, - finish: false, - title: '一起看日出', - desc: '一起看日出', - detail: { - start: '', - desc: '', - end: '', - moment: '', - other: '', - } - }, - { - index: 5, - finish: false, - title: '一起看日落', - desc: '一起看日落', - detail: { - start: '', - desc: '', - end: '', - moment: '', - other: '', // 其他说明 - } - }, - { - index: 6, - finish: false, - title: '一起买菜、做饭、刷碗', - desc: '一起买菜、做饭、刷碗', - detail: { - start: '', - desc: '', - end: '', - moment: '', - other: '', - } - } - ], - } -} diff --git a/config/plugins.config.js b/config/plugins.config.js deleted file mode 100644 index b9ff77d..0000000 --- a/config/plugins.config.js +++ /dev/null @@ -1,24 +0,0 @@ -/** 插件相关配置 */ -const PluginsConfig = Object.freeze({ - // 友链提交配置 - autoSubmitLink: { - // 可以考虑配置一个插件id,检测是否开启了友链提交插件 - pluginId:"", - // 是否开启(可能不启用插件) - enabled: false, - // 我的友链信息 - blogDetail: { - // 博客名称 - name: "uni-halo 博客", - // 博客地址 - url: "https://uni-halo.925i.cn/", - // 博客logo - logo: "https://uni-halo.925i.cn/logo.png", - // 博客简介 - description: "一个基于Halo2.0 API 的博客小程序开源项目。", - } - } -}) - - -export default PluginsConfig; diff --git a/config/plugins.config.template.js b/config/plugins.config.template.js deleted file mode 100644 index b2763a2..0000000 --- a/config/plugins.config.template.js +++ /dev/null @@ -1,30 +0,0 @@ -/** 插件相关配置 */ -const PluginsConfig = Object.freeze({ - // 友链提交配置 - autoSubmitLink: { - // 可以考虑配置一个插件id,检测是否开启了友链提交插件(暂未使用) - pluginId: "", - // 是否开启(可能后台没有安装或未不启用插件) - enabled: true, - // 我的友链信息 - blogDetail: { - // 博客名称 - name: "", - // 博客地址 - url: "", - // 博客logo - logo: "", - // 博客简介 - description: "", - } - }, - // tools工具箱插件配置 - toolsPlugin: { - pluginId:"tools", - enabled: true, - Authorization: "Tools工具箱插件设置的认证token" - } -}) - - -export default PluginsConfig; \ No newline at end of file diff --git a/main.js b/main.js index 73f95b4..6ac5337 100644 --- a/main.js +++ b/main.js @@ -62,18 +62,9 @@ Vue.prototype.$http = http; import ApiManager from '@/api/index.js' Vue.use(ApiManager); -import HaloConfig from '@/config/halo.config.js' import HaloTokenConfig from '@/config/token.config.js' -Vue.prototype.$haloConfig = HaloConfig Vue.prototype.$baseApiUrl = HaloTokenConfig.BASE_API -import HaloAdConfig from '@/config/ad.config.js' -Vue.prototype.$haloAdConfig = HaloAdConfig - -import HaloPluginsConfig from '@/config/plugins.config.js' -Vue.prototype.$haloPluginsConfig = HaloPluginsConfig - - // 由于微信小程序的运行机制问题,需声明如下一行,H5和APP非必填 Vue.prototype._i18n = i18n; @@ -83,7 +74,6 @@ const app = new Vue({ i18n, ...App, }); -// app.$mount(); // #ifdef H5 RouterMount(app, router, '#app') diff --git a/pages/index/index.vue b/pages/index/index.vue index 9e8ca58..90b6e62 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -1,35 +1,46 @@ \ No newline at end of file +export default { + computed: { + configs() { + return this.$tm.vx.getters().getConfigs; + } + }, + onLoad() { + uni.$tm.vx.actions('config/fetchConfigs').then((res) => { + console.log('正常:', res) + // #ifdef MP-WEIXIN + uni.$tm.vx.commit('setWxShare', res.shareConfig); + // #endif + this.fnCheckShowStarted(); + }).catch((err) => { + console.log('异常:', err) + uni.switchTab({ + url: '/pages/tabbar/home/home' + }); + }) + }, + methods: { + fnCheckShowStarted() { + if (!this.configs.startConfig.enable) { + uni.switchTab({ + url: '/pages/tabbar/home/home' + }); + return; + } + if (uni.getStorageSync('APP_HAS_STARTED')) { + uni.switchTab({ + url: '/pages/tabbar/home/home' + }); + } else { + uni.redirectTo({ + url: '/pagesA/start/start' + }); + } + } + } +}; + diff --git a/pages/tabbar/about/about.vue b/pages/tabbar/about/about.vue index c231f00..dc3653f 100644 --- a/pages/tabbar/about/about.vue +++ b/pages/tabbar/about/about.vue @@ -1,644 +1,621 @@ \ No newline at end of file + &::after { + border: none; + border-radius: 0; + transform: initial; + } +} + diff --git a/pages/tabbar/category/category.vue b/pages/tabbar/category/category.vue index 4c4420e..f1d7c21 100644 --- a/pages/tabbar/category/category.vue +++ b/pages/tabbar/category/category.vue @@ -7,20 +7,19 @@ - + - - {{item.spec.displayName}} + {{ item.spec.displayName }} 共 - {{item.postCount}} 篇文章 + {{ item.postCount }} 篇文章 @@ -40,6 +39,7 @@ import MarkdownConfig from '@/common/markdown/markdown.config.js'; import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue'; + export default { components: { tmSkeleton, @@ -63,12 +63,6 @@ }; }, - computed: { - bloggerInfo() { - return this.$tm.vx.getters().getBlogger; - }, - }, - onLoad() { this.fnGetData(); }, diff --git a/pages/tabbar/gallery/gallery.vue b/pages/tabbar/gallery/gallery.vue index 0221de6..dc8881c 100644 --- a/pages/tabbar/gallery/gallery.vue +++ b/pages/tabbar/gallery/gallery.vue @@ -1,253 +1,253 @@ \ No newline at end of file +.load-text { + width: 100%; + text-align: center; +} + diff --git a/pages/tabbar/home/home.vue b/pages/tabbar/home/home.vue index b1b15f8..6fe25dc 100644 --- a/pages/tabbar/home/home.vue +++ b/pages/tabbar/home/home.vue @@ -1,446 +1,452 @@ \ No newline at end of file + .ani-item { + width: 50%; + } +} + diff --git a/pages/tabbar/moments/moments.vue b/pages/tabbar/moments/moments.vue index f2416fc..6a12e61 100644 --- a/pages/tabbar/moments/moments.vue +++ b/pages/tabbar/moments/moments.vue @@ -1,236 +1,240 @@ \ No newline at end of file + &-2 { + > .image-item { + width: 50%; + height: 250rpx + } + } +} + diff --git a/pagesA/about/about.vue b/pagesA/about/about.vue index a754a81..8ea874c 100644 --- a/pagesA/about/about.vue +++ b/pagesA/about/about.vue @@ -1,94 +1,99 @@ diff --git a/pagesA/advertise/advertise.vue b/pagesA/advertise/advertise.vue index d1367a2..aec759b 100644 --- a/pagesA/advertise/advertise.vue +++ b/pagesA/advertise/advertise.vue @@ -54,6 +54,11 @@ export default { } } }, + computed: { + adConfigs() { + return this.$tm.vx.getters().getConfigs.adConfig; + } + }, onLoad(options) { // #ifdef MP-WEIXIN wx.hideShareMenu(); @@ -71,7 +76,7 @@ export default { adLoad() { if (wx.createRewardedVideoAd) { videoAd = wx.createRewardedVideoAd({ - adUnitId: this.$haloAdConfig.rewardedVideoAd //你的广告key + adUnitId: this.adConfigs.rewardedVideoAdId //你的广告key }) videoAd.onError(err => { }) @@ -86,7 +91,7 @@ export default { } }, openVideoAd: function () { - if (videoAd && this.$haloAdConfig.rewardedVideoAd != '') { + if (videoAd && this.adConfigs.rewardedVideoAdId != '') { videoAd.show().catch(err => { // 失败重试 console.log("广告拉取失败") @@ -138,7 +143,3 @@ export default { } } - - diff --git a/pagesA/archives/archives.vue b/pagesA/archives/archives.vue index 66db466..24ff3e7 100644 --- a/pagesA/archives/archives.vue +++ b/pagesA/archives/archives.vue @@ -1,367 +1,379 @@ \ No newline at end of file + &_time { + .time-label { + display: none; + } + } +} + diff --git a/pagesA/article-detail/article-detail.vue b/pagesA/article-detail/article-detail.vue index a8277b8..3555383 100644 --- a/pagesA/article-detail/article-detail.vue +++ b/pagesA/article-detail/article-detail.vue @@ -65,12 +65,10 @@ 原文: - {{ originalURL }} + {{ originalURL }} 阅读原文 - + @@ -82,8 +80,8 @@ + :content="result.content.raw" :markdown="true" :showLineNumber="true" :showLanguageName="true" + :copyByLongPress="true"/> @@ -97,44 +95,32 @@ - - - 广告 - - - - {{ haloAdConfig.articleDetail.title }} - {{ haloAdConfig.articleDetail.content }} - - 立即查看 - - - - + 版权声明 - - 版权归属:{{ copyright.author }} + + 版权归属:{{ postDetailConfig.copyrightAuthor }} - - 版权说明:{{ copyright.description }} + + 版权说明:{{ postDetailConfig.copyrightDesc }} - - 侵权处理:{{ copyright.violation }} + + 侵权处理:{{ postDetailConfig.copyrightViolation }} - - - - + + + + + + @@ -238,9 +224,7 @@ import commentItem from '@/components/comment-item/comment-item.vue'; import rCanvas from '@/components/r-canvas/r-canvas.vue'; import barrage from '@/components/barrage/barrage.vue'; -import { - haloWxShareMixin -} from '@/common/mixins/wxshare.mixin.js'; +import {haloWxShareMixin} from '@/common/mixins/wxshare.mixin.js'; export default { components: { @@ -311,8 +295,11 @@ export default { }; }, computed: { - copyright() { - return getApp().globalData.copyright; + haloConfigs() { + return this.$tm.vx.getters().getConfigs; + }, + postDetailConfig() { + return this.$tm.vx.getters().getConfigs.postDetailConfig; }, calcUrl() { return url => { @@ -324,10 +311,11 @@ export default { }, // 获取博主信息 bloggerInfo() { - let blogger = this.$tm.vx.getters().getBlogger; + let blogger = this.$tm.vx.getters().getConfigs.authorConfig.blogger; blogger.avatar = this.$utils.checkAvatarUrl(blogger.avatar, true); return blogger; }, + // 原文链接:个人资质=可以打开公众号文章;非个人:任意链接地址(需在小程序后台配置) originalURL() { if ('unihalo_originalURL' in this.result?.metadata?.annotations) { @@ -357,14 +345,15 @@ export default { this.result = res; const openid = uni.getStorageSync('openid'); - if (openid == '' || openid == null) { + if (openid === '' || openid === null) { this.fnGetOpenid(); } const visitFlag = uni.getStorageSync('visit_' + this.result?.metadata?.name); if (!visitFlag) { const annotationsMap = res?.metadata?.annotations; - if (('restrictReadEnable' in annotationsMap) && annotationsMap.restrictReadEnable === 'true') { + if (('restrictReadEnable' in annotationsMap) && annotationsMap.restrictReadEnable === + 'true') { this.visitType = 1; this.showValidVisitMorePop(); } else if ('unihalo_useVisitMorePwd' in annotationsMap) { @@ -375,9 +364,10 @@ export default { this.visitType = 3; this.visitPwd = annotationsMap.unihalo_useVisitPwd; this.showValidVisitPop(); - } else if (('restrictReadEnable' in annotationsMap) && annotationsMap.restrictReadEnable === 'password') { - this.visitType = 4; - this.showValidVisitPop(); + } else if (('restrictReadEnable' in annotationsMap) && annotationsMap + .restrictReadEnable === 'password') { + this.visitType = 4; + this.showValidVisitPop(); } else { this.visitType = 0; this.showValidVisitMore = false; @@ -425,6 +415,9 @@ export default { }, fnToComment() { + if (!this.haloConfig.basicConfig.postDetailConfig.showComment) { + return; + } if (!this.result.spec.allowComment) { return uni.$tm.toast('文章已开启禁止评论!'); } @@ -615,7 +608,7 @@ export default { // 小程序信息 await this.$refs.rCanvas .drawImage({ - url: this.$haloConfig.miniCodeImageUrl, + url: this.haloConfig.imagesConfig.miniCodeImageUrl, x: 20, y: 360, w: 80, @@ -681,23 +674,6 @@ export default { // #ifdef MP-WEIXIN uni.$tm.toast('点击右上角分享给好友!'); // #endif - // #ifdef APP-PLUS - uni.share({ - provider: 'weixin', - scene: 'WXSceneSession', - type: 0, - href: this.$baseApiUrl, - title: this.result.spec.title, - summary: this.result.content.raw, - imageUrl: this.poster.res.tempFilePath, - success: function (res) { - console.log('success:' + JSON.stringify(res)); - }, - fail: function (err) { - console.log('fail:' + JSON.stringify(err)); - } - }); - // #endif }, fnOnShowCommentDetail(data) { const { @@ -723,7 +699,7 @@ export default { this.commentDetail.list = res.items; }) .catch(err => { - console.log('getPostChildrenCommentList err', error); + console.log('getPostChildrenCommentList err', err); this.commentDetail.loading = 'error'; }); }, @@ -742,12 +718,12 @@ export default { const _list = []; const _handleData = list => { return new Promise(resolve => { - if (list.length == 0) { + if (list.length === 0) { resolve(); } else { list.forEach(item => { _list.push(item); - if (item.replies && item.replies.length != 0) { + if (item.replies && item.replies.length !== 0) { _handleData(item.replies.items); } resolve(); @@ -833,6 +809,7 @@ export default { }, // 获取openid fnGetOpenid() { + // #ifdef MP-WEIXIN uni.login({ provider: 'weixin', success: function (loginRes) { @@ -844,6 +821,7 @@ export default { } } }) + // #endif }, // 隐藏内容 fnHideContent() { @@ -872,18 +850,19 @@ export default { case 0: return; case 1: - this.$httpApi.v2.checkPostVerifyCode(this.validVisitModal.value, this.result?.metadata?.name).then(res => { - if (res.code === 200) { - uni.setStorageSync('visit_' + this.result?.metadata?.name, true) - this.closeAllPop(); - this.fnGetData(); - } else { - uni.showToast({ - title: '密码错误', - icon: 'none' - }); - } - }).catch(err => { + this.$httpApi.v2.checkPostVerifyCode(this.validVisitModal.value, this.result?.metadata?.name).then( + res => { + if (res.code === 200) { + uni.setStorageSync('visit_' + this.result?.metadata?.name, true) + this.closeAllPop(); + this.fnGetData(); + } else { + uni.showToast({ + title: '密码错误', + icon: 'none' + }); + } + }).catch(err => { console.log(err); }); return; @@ -900,22 +879,23 @@ export default { }); } return; - case 4: - this.$httpApi.v2.checkPostPasswordAccess(this.validVisitModal.value, this.result?.metadata?.name).then(res => { - if (res.code === 200) { - uni.setStorageSync('visit_' + this.result?.metadata?.name, true) - this.closeAllPop(); - this.fnGetData(); - } else { - uni.showToast({ - title: '密码错误', - icon: 'none' + case 4: + this.$httpApi.v2.checkPostPasswordAccess(this.validVisitModal.value, this.result?.metadata?.name) + .then(res => { + if (res.code === 200) { + uni.setStorageSync('visit_' + this.result?.metadata?.name, true) + this.closeAllPop(); + this.fnGetData(); + } else { + uni.showToast({ + title: '密码错误', + icon: 'none' + }); + } + }).catch(err => { + console.log(err); }); - } - }).catch(err => { - console.log(err); - }); - return; + return; default: return; } diff --git a/pagesA/articles/articles.vue b/pagesA/articles/articles.vue index 2a97c0d..13066c2 100644 --- a/pagesA/articles/articles.vue +++ b/pagesA/articles/articles.vue @@ -1,214 +1,214 @@ \ No newline at end of file +.article-card { + display: flex; + flex-direction: column; + box-sizing: border-box; + margin: 0 24rpx; + padding: 24rpx; + border-radius: 12rpx; + background-color: #ffff; + box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03); + overflow: hidden; + margin-bottom: 24rpx; +} + diff --git a/pagesA/category-detail/category-detail.vue b/pagesA/category-detail/category-detail.vue index 3b3bd96..ae57b6c 100644 --- a/pagesA/category-detail/category-detail.vue +++ b/pagesA/category-detail/category-detail.vue @@ -1,149 +1,154 @@ \ No newline at end of file +.empty { + height: 60vh; + display: flex; + align-items: center; + justify-content: center; +} + diff --git a/pagesA/comment/comment.vue b/pagesA/comment/comment.vue index f243fd6..a5abb35 100644 --- a/pagesA/comment/comment.vue +++ b/pagesA/comment/comment.vue @@ -1,197 +1,201 @@ diff --git a/pagesA/contact/contact.vue b/pagesA/contact/contact.vue index c9484da..7587e5e 100644 --- a/pagesA/contact/contact.vue +++ b/pagesA/contact/contact.vue @@ -1,256 +1,269 @@ diff --git a/pagesA/disclaimers/disclaimers.vue b/pagesA/disclaimers/disclaimers.vue index dd5a1d0..46d2d24 100644 --- a/pagesA/disclaimers/disclaimers.vue +++ b/pagesA/disclaimers/disclaimers.vue @@ -1,42 +1,51 @@ diff --git a/pagesA/friend-links/friend-links.vue b/pagesA/friend-links/friend-links.vue index 0ca02bf..4a6d699 100644 --- a/pagesA/friend-links/friend-links.vue +++ b/pagesA/friend-links/friend-links.vue @@ -26,8 +26,8 @@ - + {{ link.spec.groupName || '暂未分组' }} {{ link.spec.displayName }} @@ -120,7 +120,8 @@ - @@ -152,7 +153,7 @@ - @@ -172,7 +173,6 @@ import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue'; import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue'; - import {GetRandomNumberByRange} from '@/utils/random.js'; export default { @@ -200,14 +200,25 @@ export default { isLoadMore: false, loadMoreText: '', dataList: [], - cacheDataList: [] + cacheDataList: [], + colors: [ + '#39B449', + '#E44C41', + '#8698A2', + '#0080FE', + '#1CBCB4', + '#6638B5' + ] }; }, computed: { - caclSiteThumbnail(val) { + haloPluginConfigs(){ + return this.$tm.vx.getters().getConfigs.pluginConfig; + }, + calcSiteThumbnail(val) { return val => { if (!val) return ''; - if (val.charAt(val.length - 1) != '/') { + if (val.charAt(val.length - 1) !== '/') { val = val + '/'; } return 'https://image.thum.io/get/width/1000/crop/800/' + val; @@ -239,8 +250,8 @@ export default { }, methods: { fnRandomColor() { - const _r = GetRandomNumberByRange(0, this.$haloConfig.colors.length - 1); - return this.$haloConfig.colors[_r]; + const _r = GetRandomNumberByRange(0, this.colors.length - 1); + return this.colors[_r]; }, fnGetData() { if (!this.isLoadMore) { @@ -259,9 +270,6 @@ export default { return item; }) this.dataList = this.dataList.concat(list); - - // this.cacheDataList = this.cacheDataList.concat(list); - // this.dataList = this.handleGroup(this.cacheDataList).reverse(); setTimeout(() => { this.loading = 'success'; this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; diff --git a/pagesA/journal/journal.vue b/pagesA/journal/journal.vue index 68d2ef1..9435c80 100644 --- a/pagesA/journal/journal.vue +++ b/pagesA/journal/journal.vue @@ -1,135 +1,137 @@ \ No newline at end of file +.content-empty { + height: 60vh; +} + diff --git a/pagesA/love/album.vue b/pagesA/love/album.vue index c50d90d..722f69c 100644 --- a/pagesA/love/album.vue +++ b/pagesA/love/album.vue @@ -1,78 +1,69 @@ diff --git a/pagesA/love/journey.vue b/pagesA/love/journey.vue index 83ed8c8..ec9c57b 100644 --- a/pagesA/love/journey.vue +++ b/pagesA/love/journey.vue @@ -1,92 +1,106 @@ diff --git a/pagesA/love/list.vue b/pagesA/love/list.vue index ce0a486..26054c5 100644 --- a/pagesA/love/list.vue +++ b/pagesA/love/list.vue @@ -1,421 +1,430 @@ diff --git a/pagesA/love/love.vue b/pagesA/love/love.vue index 82cfa0f..70437d6 100644 --- a/pagesA/love/love.vue +++ b/pagesA/love/love.vue @@ -1,358 +1,418 @@ diff --git a/pagesA/start/start.vue b/pagesA/start/start.vue index 3759f44..e9db488 100644 --- a/pagesA/start/start.vue +++ b/pagesA/start/start.vue @@ -1,400 +1,443 @@ diff --git a/pagesA/submit-link/submit-link.vue b/pagesA/submit-link/submit-link.vue index 7640871..939e45e 100644 --- a/pagesA/submit-link/submit-link.vue +++ b/pagesA/submit-link/submit-link.vue @@ -53,12 +53,12 @@ - {{ blogDetail.name }} + {{ blogDetail.blogName }} - {{ blogDetail.description }} + {{ blogDetail.blogDesc }} @@ -69,12 +69,12 @@ - - 复制友链交换信息 + 复制友链交换信息 关闭 @@ -117,7 +117,6 @@ export default { data() { return { blogDetailPoupShow: false, - blogDetail: this.$haloPluginsConfig.autoSubmitLink.blogDetail, form: { url: '', // 网址 name: '', // 名称 @@ -129,10 +128,16 @@ export default { }; }, computed: { - caclSiteThumbnail(val) { + haloPluginConfigs(){ + return this.$tm.vx.getters().getConfigs.pluginConfig; + }, + blogDetail() { + return this.haloPluginConfigs.submitLink; + }, + calcSiteThumbnail(val) { return val => { if (!val) return ''; - if (val.charAt(val.length - 1) != '/') { + if (val.charAt(val.length - 1) !== '/') { val = val + '/'; } return 'https://image.thum.io/get/width/1000/crop/800/' + val; @@ -140,17 +145,17 @@ export default { }, calcBlogContent() { return ` - 博客名称:${this.blogDetail.name} - 博客地址:${this.blogDetail.url} - 博客logo:${this.blogDetail.logo} - 博客简介:${this.blogDetail.description} + 博客名称:${this.blogDetail.blogName} + 博客地址:${this.blogDetail.blogUrl} + 博客logo:${this.blogDetail.blogLogo} + 博客简介:${this.blogDetail.blogDesc} ` }, calcBlogCoupon() { return { - img: this.blogDetail.logo, - title: this.blogDetail.name, - time: this.blogDetail.description, + img: this.blogDetail.blogLogo, + title: this.blogDetail.blogName, + time: this.blogDetail.blogDesc, btnText: '友链详情' } } diff --git a/pagesA/tag-detail/tag-detail.vue b/pagesA/tag-detail/tag-detail.vue index f0f96ea..f6684a7 100644 --- a/pagesA/tag-detail/tag-detail.vue +++ b/pagesA/tag-detail/tag-detail.vue @@ -1,151 +1,155 @@ \ No newline at end of file +.empty { + height: 60vh; + display: flex; + align-items: center; + justify-content: center; +} + diff --git a/pagesA/tags/tags.vue b/pagesA/tags/tags.vue index cf2572a..95dccd0 100644 --- a/pagesA/tags/tags.vue +++ b/pagesA/tags/tags.vue @@ -1,13 +1,13 @@ diff --git a/pagesC/website/website.vue b/pagesC/website/website.vue index 389bf1a..a484f48 100644 --- a/pagesC/website/website.vue +++ b/pagesC/website/website.vue @@ -1,25 +1,27 @@ diff --git a/router/router.js b/router/router.js index c83f0ff..991ac00 100644 --- a/router/router.js +++ b/router/router.js @@ -8,11 +8,6 @@ const router = createRouter({ platform: process.env.VUE_APP_PLATFORM, routes: [...ROUTES] }); - -import { - checkHasWxLogin, - checkHasAdminLogin -} from '@/utils/auth.js' //全局路由前置守卫 router.beforeEach((to, from, next) => { @@ -26,4 +21,4 @@ router.afterEach((to, from) => { export { router, RouterMount -} \ No newline at end of file +} diff --git a/store/auth.js b/store/auth.js deleted file mode 100644 index a99aa5c..0000000 --- a/store/auth.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * 功能:登录用户 - * 作者:小莫唐尼 - * 邮箱:studio@925i.cn - * 时间:2022年07月21日 18:41:44 - * 版本:v0.1.0 - * 修改记录: - * 修改内容: - * 修改人员: - * 修改时间: - */ - -import HaloConfig from '@/config/halo.config.js'; -import { - getWxLoginInfo -} from '@/utils/auth.js' -import { - setCache, - getCache -} from '@/utils/storage.js' -export default { - state: { - // 微信登录的信息 - wxLoginInfo: getWxLoginInfo(), - }, - getters: { - getWxLoginInfo(state) { - return state.wxLoginInfo - }, - }, - mutations: { - setWxLoginInfo(state, data) { - state.wxLoginInfo = data - uni.setStorageSync('APP_WX_LOGIN_INFO', JSON.stringify(data)) - }, - }, - actions: { - checkAndSetDefaultUser(context) { - if (!context.state.wxLoginInfo) { - context.commit('setWxLoginInfo', { - avatarUrl: HaloConfig.defaultAvatarUrl, - nickName: '匿名访客', - email: '', - url: '' - }) - } - } - }, -}; diff --git a/store/blogger.js b/store/blogger.js deleted file mode 100644 index fa95d57..0000000 --- a/store/blogger.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * 功能:博客作者信息 - * 作者:小莫唐尼 - * 邮箱:studio@925i.cn - * 时间:2022年07月21日 18:41:44 - * 版本:v0.1.0 - * 修改记录: - * 修改内容: - * 修改人员: - * 修改时间: - */ -import HaloConfig from '@/config/halo.config.js'; -export default { - state: { - blogger: {}, - }, - getters: { - getBlogger(state) { - return state.blogger - }, - }, - mutations: { - setBlogger(state, data) { - state.blogger = data; - }, - }, - actions: { - fnGetBlogger(context) { - context.commit("setBlogger", HaloConfig.author); - }, - }, -}; \ No newline at end of file diff --git a/store/config.js b/store/config.js new file mode 100644 index 0000000..e2510e3 --- /dev/null +++ b/store/config.js @@ -0,0 +1,51 @@ +/** + * 功能:应用配置 + * 作者:小莫唐尼 + * 邮箱:studio@925i.cn + * 时间:2024年06月22日 12:00:44 + * 版本:v0.1.0 + */ +import {DefaultAppConfigs, getAppConfigs, setAppConfigs} from '@/config/index.js' +import v2Config from '@/api/v2/all.config.js' + +export default { + namespaced: true, + state: { + configs: getAppConfigs(), + }, + getters: { + getConfigs(state) { + if (state.configs) return state.configs; + return getAppConfigs() + }, + }, + mutations: { + setConfigs(state, data) { + state.configs = data; + setAppConfigs(data) + }, + }, + actions: { + fetchConfigs({commit, dispatch}) { + return new Promise(async (resolve, reject) => { + try { + const res = await v2Config.getAppConfigs() + if (res) { + commit('setConfigs', res) + resolve(res) + } else { + dispatch("setDefaultAppSettings"); + reject() + } + } catch (e) { + dispatch("setDefaultAppSettings"); + reject() + } + }) + }, + // 设置默认的数据 + setDefaultAppSettings({commit}) { + commit('setConfigs', JSON.parse(JSON.stringify(DefaultAppConfigs))) + }, + } +}; diff --git a/store/user.js b/store/user.js deleted file mode 100644 index 719107c..0000000 --- a/store/user.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * 功能:登录用户 - * 作者:小莫唐尼 - * 邮箱:studio@925i.cn - * 时间:2022年07月21日 18:41:44 - * 版本:v0.1.0 - * 修改记录: - * 修改内容: - * 修改人员: - * 修改时间: - */ -import HaloConfig from '@/config/halo.config.js'; -import { - getWxLoginInfo -} from '@/utils/auth.js' -import { - setCache, - getCache -} from '@/utils/storage.js' -export default { - state: { - // 微信登录的信息 - wxLoginInfo: getWxLoginInfo(), - }, - getters: { - - getWxLoginInfo(state) { - return state.wxLoginInfo - }, - }, - mutations: { - setWxLoginInfo(state, data) { - state.wxLoginInfo = data - uni.setStorageSync('APP_WX_LOGIN_INFO', JSON.stringify(data)) - }, - }, - actions: { - - checkAndSetDefaultUser(context) { - if (!context.state.wxLoginInfo) { - context.commit('setWxLoginInfo', { - avatarUrl: HaloConfig.defaultAvatarUrl, - nickName: '匿名访客', - email: '', - url: '' - }) - } - }, - - }, -}; diff --git a/utils/app.js b/utils/app.js index 5d47e50..7ccd14b 100644 --- a/utils/app.js +++ b/utils/app.js @@ -7,7 +7,7 @@ export const Platform = { * 检查当前环境是什么环境 */ export const checkPlatform = (name) => { - return uni.getSystemInfoSync().platform == name; + return uni.getSystemInfoSync().platform === name; } // 默认的应用设置 @@ -20,7 +20,7 @@ export const _DefaultAppSettings = { }, // 布局配置 layout: { - // h_row_col1 = 一行一列 + // h_row_col1 = 一行一列 // h_row_col2 = 一行两列 home: 'h_row_col1', // lr_image_text=左图右文 @@ -51,7 +51,7 @@ export const _DefaultAppSettings = { }, about: { showAdmin: false, // 显示后台登录入口 - showAllCount: false, // 默认显示所有的统计信息(关于页面) + showAllCount: false, // 默认显示所有的统计信息(关于页面) }, // 文章配置 article: { diff --git a/utils/index.js b/utils/index.js index 72687b3..3dc1821 100644 --- a/utils/index.js +++ b/utils/index.js @@ -10,160 +10,157 @@ * 修改时间: */ -import HaloConfig from '@/config/halo.config.js'; import HaloTokenConfig from '@/config/token.config.js' -import { - logTypes, - logUtils -} from '@/utils/halo.logs.js' +import {getAppConfigs} from '@/config/index.js' + const utils = { - /** - * 检查是否为http/https链接 - */ - checkIsUrl: function(s) { - var reg = /^(http(s)?:\/\/)/i; - return reg.test(s) - }, + /** + * 检查是否为http/https链接 + */ + checkIsUrl: function (s) { + var reg = /^(http(s)?:\/\/)/i; + return reg.test(s) + }, - // 检查链接 - checkUrl: function(url) { - if (!url) return ''; - if (!this.checkIsUrl(url)) return HaloTokenConfig.BASE_API + url; - return url - }, + // 检查链接 + checkUrl: function (url) { + if (!url) return ''; + if (!this.checkIsUrl(url)) return HaloTokenConfig.BASE_API + url; + return url + }, - // 检查封面图 - checkThumbnailUrl: function(thumbnail, mustRealUrl = false) { - if (!thumbnail && mustRealUrl) { - return HaloConfig.defaultStaticThumbnailUrl - } - let _url = HaloConfig.defaultThumbnailUrl - if (_url) { - if (_url.indexOf('?') == -1) { - _url += `?next-v=${new Date().getTime()}` - } else { - _url += `&next-v=${new Date().getTime()}` - } - } - if (!thumbnail) return _url; - if (!this.checkIsUrl(thumbnail)) return HaloTokenConfig.BASE_API + thumbnail; - return thumbnail - }, + // 检查封面图 + checkThumbnailUrl: function (thumbnail, mustRealUrl = false) { + if (!thumbnail && mustRealUrl) { + return this.checkUrl(getAppConfigs().imagesConfig.defaultStaticThumbnailUrl); + } + let _url = this.checkUrl(getAppConfigs().imagesConfig.defaultThumbnailUrl); + if (_url) { + if (_url.indexOf('?') === -1) { + _url += `?next-v=${new Date().getTime()}` + } else { + _url += `&next-v=${new Date().getTime()}` + } + } + if (!thumbnail) return _url; + if (!this.checkIsUrl(thumbnail)) return HaloTokenConfig.BASE_API + thumbnail; + return thumbnail + }, - // 检查图片 - checkImageUrl: function(image) { - let _url = HaloConfig.defaultImageUrl - if (_url) { - if (_url.indexOf('?') == -1) { - _url += `?next-v=${new Date().getTime()}` - } else { - _url += `&next-v=${new Date().getTime()}` - } - } - if (!image) return _url; - if (!this.checkIsUrl(image)) return HaloTokenConfig.BASE_API + image; - return image - }, + // 检查图片 + checkImageUrl: function (image) { + let _url + this.checkUrl(getAppConfigs().imagesConfig.defaultImageUrl); + if (_url) { + if (_url.indexOf('?') === -1) { + _url += `?next-v=${new Date().getTime()}` + } else { + _url += `&next-v=${new Date().getTime()}` + } + } + if (!image) return _url; + if (!this.checkIsUrl(image)) return HaloTokenConfig.BASE_API + image; + return image + }, - // 检查头像 - checkAvatarUrl: function(avatar, isAdmin = false) { - if (isAdmin) return HaloConfig.author.avatar; - if (!avatar) { - let _url = HaloConfig.defaultAvatarUrl - if (_url) { - if (_url.indexOf('?') == -1) { - _url += `?next-v=${new Date().getTime()}` - } else { - _url += `&next-v=${new Date().getTime()}` - } - } - return _url; - } - if (!this.checkIsUrl(avatar)) return HaloTokenConfig.BASE_API + avatar; - return avatar - }, + // 检查头像 + checkAvatarUrl: function (avatar) { + if (!avatar) { + let _url = this.checkUrl(getAppConfigs().imagesConfig.defaultAvatarUrl); + if (_url) { + if (_url.indexOf('?') === -1) { + _url += `?next-v=${new Date().getTime()}` + } else { + _url += `&next-v=${new Date().getTime()}` + } + } + return _url; + } + if (!this.checkIsUrl(avatar)) return HaloTokenConfig.BASE_API + avatar; + return avatar + }, - // 检查文件类型 - fnCheckIsFileType(type, attachment) { - if (!attachment) return false; - if (!attachment.mediaType) return false; - if (type == 'video') return attachment.mediaType.indexOf('video/') != -1; - else if (type == 'image') return attachment.mediaType.indexOf('image/') != -1; - else return false; - }, - groupData: function(arr, fun) { - const groups = {} - arr.forEach((el) => { - const group = fun(el) - groups[group] = groups[group] || [] - groups[group].push(el) - }) - return Object.keys(groups).map((group) => { - // 更改data的数据结构 可以改变新数据的结构 data即为newData的数组中每个数据的结构 - let data = { - groupName: group, - data: groups[group] - } - return data - }) - }, - /** - * 数据分组 - * @param {Object} oldData 数据源 - * @param {Object} prop 分组属性 - */ - arrayGroupBy: function(oldData, prop) { - const newData = this.groupData(oldData, (item) => { - return item[prop] - }) - return newData - }, - /** - * 深克隆 - * @param {Object} obj 数据源 - */ - deepClone(obj) { - var objClone = Array.isArray(obj) ? [] : {}; - if (obj && typeof obj === "object") { - for (const key in obj) { - if (obj.hasOwnProperty(key)) { - if (obj[key] && typeof obj[key] === "object") { - objClone[key] = this.deepClone(obj[key]); - } else { - objClone[key] = obj[key]; - } - } - } - } - return objClone; - }, - /** - * 复制内容到剪贴板 - * @param {Object} obj 数据源 - */ - copyText(content, tips = '复制成功') { - uni.setClipboardData({ - data: content, - showToast: false, - success: () => { - if (tips) { - uni.showToast({ - icon: 'none', - title: tips - }) - } - } - }) - }, - previewImage(list) { - list = list.map(item => { - return this.checkUrl(item) - }) - uni.previewImage({ - urls: list, - loop: true - }) - } + // 检查文件类型 + fnCheckIsFileType(type, attachment) { + if (!attachment) return false; + if (!attachment.mediaType) return false; + if (type === 'video') return attachment.mediaType.indexOf('video/') !== -1; + else if (type === 'image') return attachment.mediaType.indexOf('image/') !== -1; + else return false; + }, + groupData: function (arr, fun) { + const groups = {} + arr.forEach((el) => { + const group = fun(el) + groups[group] = groups[group] || [] + groups[group].push(el) + }) + return Object.keys(groups).map((group) => { + // 更改data的数据结构 可以改变新数据的结构 data即为newData的数组中每个数据的结构 + let data = { + groupName: group, + data: groups[group] + } + return data + }) + }, + /** + * 数据分组 + * @param {Object} oldData 数据源 + * @param {Object} prop 分组属性 + */ + arrayGroupBy: function (oldData, prop) { + const newData = this.groupData(oldData, (item) => { + return item[prop] + }) + return newData + }, + /** + * 深克隆 + * @param {Object} obj 数据源 + */ + deepClone(obj) { + var objClone = Array.isArray(obj) ? [] : {}; + if (obj && typeof obj === "object") { + for (const key in obj) { + if (obj.hasOwnProperty(key)) { + if (obj[key] && typeof obj[key] === "object") { + objClone[key] = this.deepClone(obj[key]); + } else { + objClone[key] = obj[key]; + } + } + } + } + return objClone; + }, + /** + * 复制内容到剪贴板 + * @param {Object} obj 数据源 + */ + copyText(content, tips = '复制成功') { + uni.setClipboardData({ + data: content, + showToast: false, + success: () => { + if (tips) { + uni.showToast({ + icon: 'none', + title: tips + }) + } + } + }) + }, + previewImage(list) { + list = list.map(item => { + return this.checkUrl(item) + }) + uni.previewImage({ + urls: list, + loop: true + }) + } };