1
0
鏡像自 https://github.com/ialley-workshop-open/uni-halo.git 已同步 2026-06-10 11:59:28 +08:00

release: 发布 uni-halo beta-v2.0 版本

此提交包含在:
小莫唐尼
2024-05-20 01:27:15 +08:00
父節點 a81c506a14
當前提交 057a7cf6f0
共有 49 個檔案被更改,包括 2696 行新增2531 行删除
+4 -1
查看文件
@@ -1,6 +1,9 @@
node_modules/ node_modules/
unpackage/ unpackage/
package-lock.json
config/halo.config.js config/halo.config.js
config/ad.config.js config/ad.config.js
config/love.config.js config/love.config.js
package-lock.json config/token.config.js
+27 -26
查看文件
@@ -1,28 +1,29 @@
{ // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/ {
// launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
"version": "0.0", // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
"configurations": [{ "version" : "0.0",
"app-plus" : "configurations" : [
{ {
"launchtype" : "local" "app-plus" : {
}, "launchtype" : "local"
"default" : },
{ "default" : {
"launchtype" : "local" "launchtype" : "local"
}, },
"h5" : "h5" : {
{ "launchtype" : "local"
"launchtype" : "local" },
}, "mp-qq" : {
"mp-qq" : "launchtype" : "local"
{ },
"launchtype" : "local" "mp-weixin" : {
}, "launchtype" : "local"
"mp-weixin" : },
{ "type" : "uniCloud"
"launchtype" : "local" },
}, {
"type" : "uniCloud" "playground" : "standard",
} "type" : "uni-app:app-android"
}
] ]
} }
+61 -58
查看文件
@@ -1,73 +1,76 @@
<script> <script>
import HaloConfig from '@/config/halo.config.js'; import HaloTokenConfig from '@/config/token.config.js';
import HaloAdConfig from '@/config/ad.config.js'; import HaloConfig from '@/config/halo.config.js';
import HaloAdConfig from '@/config/ad.config.js';
// app升级检测(搭配:https://ext.dcloud.net.cn/plugin?id=4470 升级中心) // app升级检测(搭配:https://ext.dcloud.net.cn/plugin?id=4470 升级中心)
import CheckAppUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'; import CheckAppUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
import { CheckWxUpdate } from '@/utils/update.js'; import {
export default { CheckWxUpdate
globalData: { } from '@/utils/update.js';
baseApiUrl: HaloConfig.apiUrl, export default {
...HaloConfig, globalData: {
haloAdConfig: HaloAdConfig baseApiUrl: HaloTokenConfig.BASE_API,
}, ...HaloConfig,
onLaunch: function() { haloAdConfig: HaloAdConfig
console.log('App Launch'); },
onLaunch: function() {
console.log('App Launch');
// #ifdef APP-PLUS // #ifdef APP-PLUS
CheckAppUpdate(); CheckAppUpdate();
// #endif // #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
CheckWxUpdate(); CheckWxUpdate();
uni.$tm.vx.commit('setWxShare', HaloConfig.wxShareConfig); uni.$tm.vx.commit('setWxShare', HaloConfig.wxShareConfig);
// #endif // #endif
// 监听中间按钮(暂时没有使用) // 监听中间按钮(暂时没有使用)
uni.onTabBarMidButtonTap(() => { uni.onTabBarMidButtonTap(() => {
console.log('点击中间按钮'); console.log('点击中间按钮');
}); });
// 初始化博主信息 // 初始化博主信息
uni.$tm.vx.actions('blogger/fnGetBlogger'); uni.$tm.vx.actions('blogger/fnGetBlogger');
// 临时:检查是否有用户,没有的话添加一个默认的用户 // 临时:检查是否有用户,没有的话添加一个默认的用户
uni.$tm.vx.actions('user/checkAndSetDefaultUser'); uni.$tm.vx.actions('user/checkAndSetDefaultUser');
// 启动检查app的配置是否已经就绪,若未就绪则设置默认的 // 启动检查app的配置是否已经就绪,若未就绪则设置默认的
uni.$tm.vx.actions('setting/checkAndSetDefaultAppSettings'); uni.$tm.vx.actions('setting/checkAndSetDefaultAppSettings');
}, },
onShow: function() { onShow: function() {
console.log('App Show'); console.log('App Show');
}, },
onHide: function() { onHide: function() {
console.log('App Hide'); console.log('App Hide');
} }
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
// 基础样式 // 基础样式
@import './common/styles/app.theme.scss'; @import './common/styles/app.theme.scss';
@import './common/styles/app.base.scss'; @import './common/styles/app.base.scss';
// 引入tmUI2.x样式 // 引入tmUI2.x样式
@import './tm-vuetify/mian.min.css'; @import './tm-vuetify/mian.min.css';
// 引入tmUI2.x主题包 // 引入tmUI2.x主题包
@import './tm-vuetify/scss/theme.css'; @import './tm-vuetify/scss/theme.css';
// 引入tmUI2.x预置图标 // 引入tmUI2.x预置图标
@import './tm-vuetify/scss/fonts/fontawesome_base64.css'; @import './tm-vuetify/scss/fonts/fontawesome_base64.css';
// 自定义图标 // 自定义图标
@import './common/icons/halocoloriconfont.css'; @import './common/icons/halocoloriconfont.css';
@import './common/icons/haloiconfont.css'; @import './common/icons/haloiconfont.css';
@import './common/icons/mphtmliconfont.css'; @import './common/icons/mphtmliconfont.css';
/* #ifndef MP-WEIXIN */ /* #ifndef MP-WEIXIN */
@import './common/markdown/markdown.scss'; @import './common/markdown/markdown.scss';
/* #endif */ /* #endif */
page { page {
background-color: #fafafa; background-color: #fafafa;
} }
</style> </style>
+10 -19
查看文件
@@ -4,12 +4,12 @@
</a> </a>
</p> </p>
<p align="center"><b>【uni-halo】</b> 基于 uniapp + Halo API 开发的多端项目,值得一试。</p> <p align="center"><b>【uni-halo v2.0】</b> 基于 Halo API 多端项目,值得一试。</p>
<br /> <br />
<p align="center"> <p align="center">
<a href="https://b.925i.cn">作者博客</a> <a href="https://b.925i.cn">作者博客</a>
<a href="https://uni-halo.925i.cn">文档地址</a> <a href="https://uni-halo.925i.cn">文档地址(等待更新v2版本说明)</a>
<a href="https://gitee.com/ialley-workshop-open/uni-halo">Gitee仓库</a> <a href="https://gitee.com/ialley-workshop-open/uni-halo">Gitee仓库</a>
<a href="https://github.com/ialley-workshop-open/uni-halo">Github仓库</a> <a href="https://github.com/ialley-workshop-open/uni-halo">Github仓库</a>
</p> </p>
@@ -26,10 +26,9 @@
#### 🍻 基础功能 #### 🍻 基础功能
几乎实现PC端后台的全功能,让您在手机端也可以管理您的博客。 `重要说明:2.0版本 暂时去掉后台管理功能。`
- 用户端:文章列表、文章分类、文章详情、图库、留言板、友链、个人日记等 - 用户端:文章列表、文章分类、文章详情、图库、友链、瞬间等
- 管理端:资料修改、密码修改、日记管理、文章管理、分类管理、标签管理、附件管理、友链管理、评论管理、日志管理等
<br/> <br/>
@@ -42,7 +41,7 @@
## 😎 文档源码 ## 😎 文档源码
- 作者博客:[https://b.925i.cn/](https://b.925i.cn/) - 作者博客:[https://b.925i.cn/](https://b.925i.cn/)
- 官方文档:[https://uni-halo.925i.cn/](https://uni-halo.925i.cn/) - 官方文档(待更新v2版本说明):[https://uni-halo.925i.cn/](https://uni-halo.925i.cn/)
- Gitee :[https://gitee.com/ialley-workshop-open/uni-halo](https://gitee.com/ialley-workshop-open/uni-halo) - Gitee :[https://gitee.com/ialley-workshop-open/uni-halo](https://gitee.com/ialley-workshop-open/uni-halo)
- Github :[https://github.com/ialley-workshop-open/uni-halo](https://github.com/ialley-workshop-open/uni-halo) - Github :[https://github.com/ialley-workshop-open/uni-halo](https://github.com/ialley-workshop-open/uni-halo)
@@ -69,22 +68,14 @@
|我的|归档|详情|留言板| |我的|归档|详情|留言板|
|:--:|:--:|:--:|:--:| |:--:|:--:|:--:|:--:|
|![我的](https://uni-halo.925i.cn/assets/005.d1ccf84e.jpg)|![归档](https://uni-halo.925i.cn/assets/007.e481f0c1.jpg)|![详情](https://uni-halo.925i.cn/assets/008.a4f5af80.jpg)|![留言板](https://uni-halo.925i.cn/assets/006.fc80dc8c.jpg)| |![我的](https://uni-halo.925i.cn/assets/005.d1ccf84e.jpg)|![归档](https://uni-halo.925i.cn/assets/007.e481f0c1.jpg)|![详情](https://uni-halo.925i.cn/assets/008.a4f5af80.jpg)|![留言板](https://uni-halo.925i.cn/assets/006.fc80dc8c.jpg)|
##### 💻 管理端
说明:以下仅为部分截图
|后台首页|文章管理|
|:--:|:--:|
|![后台首页](https://uni-halo.925i.cn/assets/009.707f9a85.jpg)|![文章管理](https://uni-halo.925i.cn/assets/010.0b018b02.jpg)|
##### 📱 恋爱日记 ##### 📱 恋爱日记
说明:以下仅为部分截图 说明:以下仅为部分截图
|主页 |恋爱相册 |恋爱清单 | | 主页 | 恋爱清单 |
|:--: |:--: |-- | |:-----------------------------------------------------------:|-- |
|![主页](https://uni-halo.925i.cn/assets/love_001.6bf8b4e9.jpg) |![恋爱相册](https://uni-halo.925i.cn/assets/love_003.b8effd48.jpg) |![恋爱清单](https://uni-halo.925i.cn/assets/love_002.a08bd8d6.jpg) | |![主页](https://uni-halo.925i.cn/assets/love_001.6bf8b4e9.jpg) | ![恋爱清单](https://uni-halo.925i.cn/assets/love_002.a08bd8d6.jpg) |
<br/> <br/>
@@ -119,4 +110,4 @@ uni-halo 得益于以下优秀的技术支撑,我只是站在巨人的肩膀
- [Halo:一款好用又强大的开源建站工具](https://halo.run/) - [Halo:一款好用又强大的开源建站工具](https://halo.run/)
- [uni-app:是一个使用 Vue.js 开发所有前端应用的框架,开发者编写一套代码可编译到多个平台](https://uniapp.dcloud.net.cn/) - [uni-app:是一个使用 Vue.js 开发所有前端应用的框架,开发者编写一套代码可编译到多个平台](https://uniapp.dcloud.net.cn/)
- [tm-vuetify:是一个为 uni-app 平台定制的颜值也非常高的 UI 框架](https://www.jx2d.cn/) - [tm-vuetify:是一个为 uni-app 平台定制的颜值也非常高的 UI 框架](https://www.jx2d.cn/)
- [mp-html:一个强大的小程序富文本组件](https://jin-yufeng.gitee.io/mp-html/#/) - [mp-html:一个强大的小程序富文本组件](https://jin-yufeng.gitee.io/mp-html/#/)
+4 -7
查看文件
@@ -14,12 +14,9 @@ export default {
/** /**
* 获取文章详情 * 获取文章详情
* @param {String} articleId 文章id * @param {String} name 文章 name
*/ */
getArticleDetail: (articleId) => { getArticleDetail: (name) => {
return HttpHandler.Get(`/api/content/posts/${articleId}`, { return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts/${name}`, {})
formatDisabled: false,
sourceDisabled: true
})
}, },
} }
+16 -7
查看文件
@@ -11,17 +11,26 @@ export default {
* @param {Object} params 查询参数 * @param {Object} params 查询参数
*/ */
getCategoryList: (params) => { getCategoryList: (params) => {
return HttpHandler.Get('/api/content/categories', params) return HttpHandler.Get('/apis/api.content.halo.run/v1alpha1/categories', params)
},
/**
* 根据分类名称查询一个分类
* @param {String} name 分类名称
* @param {Object} params 查询参数
*/
getCategoryPostList: (name, params) => {
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/categories/${name}`, params)
}, },
/** /**
* 查询分类下的文章 * 查询分类下的文章
* @param {String} slug 分类名称 * @param {String} name 分类名称
* @param {Object} params 查询参数 * @param {Object} params 查询参数
*/ */
getCategoryPostList: (slug, params) => { getCategoryPostList: (name, params) => {
// 从缓存中根据分类获取密码,如果获取到了说明本分类需要密码,避免多个分类需要密码在输入密码后刷新页面点错了分类 return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/categories/${name}/posts`, params)
params.password = getCache('APP_CATEGORY_PWD_' + slug)
return HttpHandler.Get(`/api/content/categories/${slug}/posts`, params)
}, },
}
}
+4 -4
查看文件
@@ -16,11 +16,11 @@ export default {
/** /**
* 获取评论列表接口(列表数据) * 获取评论列表接口(列表数据)
* @param {String} postId 文章id * @param {String} name 文章id
* @param {Object} params 查询参数 * @param {Object} params 查询参数
*/ */
getPostCommentList: (postId, params) => { getPostCommentList: (name, params) => {
return HttpHandler.Get(`/api/content/posts/${postId}/comments/list_view`, params) return HttpHandler.Get(`/apis/content.halo.run/v1alpha1/comments${name}`, params)
}, },
/** /**
@@ -42,4 +42,4 @@ export default {
getPostChildrenCommentList: (postId, commentParentId, params) => { getPostChildrenCommentList: (postId, commentParentId, params) => {
return HttpHandler.Get(`/api/content/posts/${postId}/comments/${commentParentId}/children`, params) return HttpHandler.Get(`/api/content/posts/${postId}/comments/${commentParentId}/children`, params)
}, },
} }
+4
查看文件
@@ -40,7 +40,11 @@ import admin_comments from './admin/comments.js'
import admin_posts from './admin/posts.js' import admin_posts from './admin/posts.js'
import admin_logs from './admin/logs.js' import admin_logs from './admin/logs.js'
// 2.0接口
import v2 from './v2/all.api.js'
const ApiManager = { const ApiManager = {
v2,
...archive, ...archive,
...article, ...article,
...blogger, ...blogger,
+10 -2
查看文件
@@ -11,7 +11,15 @@ export default {
* @param {Object} params 参数 * @param {Object} params 参数
*/ */
getPostList: (params) => { getPostList: (params) => {
return HttpHandler.Get(`/api/content/posts`, params) return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts`, params)
},
/**
* 根据名称获取文章
* @param {String} name 分类名称
*/
getPostByName: (name) => {
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts/${name}`, {})
}, },
/** /**
@@ -79,4 +87,4 @@ export default {
return HttpHandler.Get(`/api/content/posts/${postId}/next`) return HttpHandler.Get(`/api/content/posts/${postId}/next`)
}, },
} }
+143
查看文件
@@ -0,0 +1,143 @@
/**
* 所有的接口
*/
import HaloTokenConfig from '@/config/token.config.js'
import HttpHandler from '@/common/http/request.js'
import {
getCache
} from '@/utils/storage.js'
export default {
/**
* 获取文章列表
* @param {Object} params 参数
*/
getPostList: (params) => {
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts`, params)
},
/**
* 根据名称获取文章
* @param {String} name 分类名称
*/
getPostByName: (name) => {
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts/${name}`, {})
},
/**
* 搜索文章
* @param {Object} params 数据
*/
getPostListByKeyword: (params) => {
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/indices/post`, params)
},
/**
* 查询分类列表
* @param {Object} params 查询参数
*/
getCategoryList: (params) => {
return HttpHandler.Get('/apis/api.content.halo.run/v1alpha1/categories', params)
},
/**
* 查询分类下的文章
* @param {String} name 分类名称
* @param {Object} params 查询参数
*/
getCategoryPostList: (name, params) => {
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/categories/${name}/posts`, params)
},
/**
* 获取评论列表接口(列表数据)
* @param {Object} params 查询参数
*/
getPostCommentList: (params) => {
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/comments`, params)
},
/**
* 获取回复列表
* @param {String} commentName 名称
* @param {Object} params 查询参数
*/
getPostCommentReplyList: (commentName, params) => {
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, params)
},
// 提交评论
addPostComment: (data) => {
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/comments`, data)
},
// 提交回复
addPostCommentReply: (commentName, data) => {
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/comments/${commentName}/replay`, data)
},
/**
* 获取标签列表
* @param {Object} params 查询参数
*/
getTagList: (params) => {
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/tags`, params)
},
/**
* 根据标签获取文章列表
* @param {String} tagName 参数
* @param {Object} params 查询参数
*/
getPostByTagName: (tagName, params) => {
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/tags/${tagName}/posts`, params)
},
/**
* 获取瞬间列表
*/
getMomentList: (params) => {
return HttpHandler.Get(`/apis/moment.halo.run/v1alpha1/moments`, params, {
custom: {
systemToken: HaloTokenConfig.systemToken
}
})
},
/**
* 查询站点统计信息
*/
getBlogStatistics: () => {
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/stats/-`, {})
},
/**
* 获取相册分组
*/
getPhotoGroupList: (params) => {
return HttpHandler.Get(`/apis/core.halo.run/v1alpha1/photogroups`, params, {
custom: {
systemToken: HaloTokenConfig.systemToken
}
})
},
/**
* 根据分组获取相册
*/
getPhotoListByGroupName: (params) => {
return HttpHandler.Get(`/apis/console.api.photo.halo.run/v1alpha1/photos`, params, {
custom: {
systemToken: HaloTokenConfig.systemToken
}
})
},
/**
* 获取友链
*/
getFriendLinkList: (params) => {
return HttpHandler.Get(`/apis/api.plugin.halo.run/v1alpha1/plugins/PluginLinks/links`, params)
},
}
+3 -3
查看文件
@@ -11,6 +11,7 @@
*/ */
import HaloConfig from '@/config/halo.config.js' import HaloConfig from '@/config/halo.config.js'
import HaloTokenConfig from '@/config/token.config.js'
import { import {
setInterceptors setInterceptors
} from "./interceptors.js"; } from "./interceptors.js";
@@ -21,11 +22,10 @@ const http = new Request()
http.setConfig((config) => { http.setConfig((config) => {
// 如果是在外部浏览器调试或者编译为h5,请注释该行代码 // 如果是在外部浏览器调试或者编译为h5,请注释该行代码
config.baseURL = HaloConfig.apiUrl; config.baseURL = HaloTokenConfig.BASE_API;
config.header = { config.header = {
...config.header, ...config.header,
'api-authorization': HaloConfig.apiAuthorization,
ContentType: 'application/json', ContentType: 'application/json',
dataType: 'json' dataType: 'json'
} }
+6 -2
查看文件
@@ -64,13 +64,15 @@ const showCategoryInputPasswordModal = (response, category) => {
export const setInterceptors = (http) => { export const setInterceptors = (http) => {
http.interceptors.request.use( http.interceptors.request.use(
(config) => { (config) => {
console.log("config", config)
// 可使用async await 做异步操作 // 可使用async await 做异步操作
config.header = { config.header = {
...config.header ...config.header
// ... 可以直接加参数 // ... 可以直接加参数
}; };
if (getAdminAccessToken()) { if (config.custom.systemToken) {
config.header['admin-authorization'] = getAdminAccessToken() config.header['Authorization'] = `Bearer ${config.custom.systemToken}`
} }
return config; return config;
}, },
@@ -138,12 +140,14 @@ export const setInterceptors = (http) => {
}) })
}) })
} }
return Promise.reject(response.data);
} else if (response.data.status == 403) { } else if (response.data.status == 403) {
// 如果报403是请求分类文章接口(您没有该分类的访问权限)的话说明是私密分类,需要输入密码请求 // 如果报403是请求分类文章接口(您没有该分类的访问权限)的话说明是私密分类,需要输入密码请求
if (response.config.url.indexOf('/api/content/categories') >= 0) { if (response.config.url.indexOf('/api/content/categories') >= 0) {
const category = getCategoryNameByUrl(response.config.url); const category = getCategoryNameByUrl(response.config.url);
showCategoryInputPasswordModal(response, category); showCategoryInputPasswordModal(response, category);
} }
return Promise.reject(response.data);
} else { } else {
return Promise.reject(response.data); return Promise.reject(response.data);
} }
+2 -1
查看文件
@@ -3,8 +3,9 @@
*/ */
import HaloConfig from '@/config/halo.config.js' import HaloConfig from '@/config/halo.config.js'
import HaloTokenConfig from '@/config/token.config.js'
export default { export default {
domain: HaloConfig.apiUrl, domain: HaloTokenConfig.BASE_API,
tagStyle: { tagStyle: {
table: ` table: `
table-layout: fixed; table-layout: fixed;
+2 -1
查看文件
@@ -1,5 +1,6 @@
// 微信分享配置 // 微信分享配置
import haloConfig from '@/config/halo.config.js' import haloConfig from '@/config/halo.config.js'
import HaloTokenConfig from '@/config/token.config.js'
import { jsonToUrlParams2 } from '@/utils/url.params.js' import { jsonToUrlParams2 } from '@/utils/url.params.js'
export const haloWxShareMixin = { export const haloWxShareMixin = {
data() { data() {
@@ -55,7 +56,7 @@ export const haloWxShareMixin = {
} }
let _config = Object.assign({}, { let _config = Object.assign({}, {
path: sharePath, path: sharePath,
copyLink: haloConfig.apiUrl, copyLink: HaloTokenConfig.BASE_API,
query: {} query: {}
}, config) }, config)
+6 -6
查看文件
@@ -1,24 +1,24 @@
<template> <template>
<view class="article-card " :class="cardType" @click="fnClickEvent('card')"> <view class="article-card " :class="cardType" @click="fnClickEvent('card')">
<view class="left"> <view class="left">
<cache-image class="thumbnail" radius="6rpx" :url="$utils.checkThumbnailUrl(article.thumbnail)" :fileMd5="$utils.checkThumbnailUrl(article.thumbnail)" mode="aspectFill"></cache-image> <cache-image class="thumbnail" radius="6rpx" :url="$utils.checkThumbnailUrl(article.spec.cover)" :fileMd5="$utils.checkThumbnailUrl(article.spec.cover)" mode="aspectFill"></cache-image>
<!-- <image class="thumbnail" lazy-load :src="$utils.checkThumbnailUrl(article.thumbnail)" mode="aspectFill"></image> --> <!-- <image class="thumbnail" lazy-load :src="$utils.checkThumbnailUrl(article.thumbnail)" mode="aspectFill"></image> -->
</view> </view>
<view class="right"> <view class="right">
<view class="title"> <view class="title">
<text class="is-top bg-gradient-blue-accent" v-if="article.topped">置顶</text> <text class="is-top bg-gradient-blue-accent" v-if="article.spec.pinned">置顶</text>
<text class="title-text text-overflow">{{ article.title }}</text> <text class="title-text text-overflow">{{ article.spec.title }}</text>
</view> </view>
<view class="content text-overflow-2">{{ article.summary }}</view> <view class="content text-overflow-2">{{ article.status.excerpt }}</view>
<view class="foot"> <view class="foot">
<view class="create-time"> <view class="create-time">
<text class="time-label">发布时间</text> <text class="time-label">发布时间</text>
{{ { d: article.createTime, f: 'yyyy-MM-dd' } | formatTime }} {{ { d: article.spec.publishTime, f: 'yyyy-MM-dd' } | formatTime }}
</view> </view>
<view class="visits"> <view class="visits">
<!-- <tm-icons :size="24" name="icon-filter-fill"></tm-icons> --> <!-- <tm-icons :size="24" name="icon-filter-fill"></tm-icons> -->
浏览 浏览
<text class="number">{{ article.visits }}</text> <text class="number">{{ article.stats.visit }}</text>
</view> </view>
</view> </view>
+66 -54
查看文件
@@ -1,67 +1,79 @@
<template> <template>
<view class="category-mini-card"> <view class="category-mini-card">
<cache-image <cache-image class="img" height="180rpx" :url="$utils.checkThumbnailUrl(category.spec.cover,true)"
class="img" :fileMd5="$utils.checkThumbnailUrl(category.spec.cover)" mode="aspectFill"></cache-image>
height="120rpx" <view class="content">
:url="$utils.checkThumbnailUrl(category.thumbnail)" <view class="name">{{ category.spec.displayName }}</view>
:fileMd5="$utils.checkThumbnailUrl(category.thumbnail)" <text class="label"> {{ category.postCount }} </text>
mode="aspectFill" </view>
></cache-image>
<text class="label">{{ category.postCount }}&nbsp;</text>
<view class="name">{{ category.name }}</view>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
name: 'category-mini-card', name: 'category-mini-card',
props: { props: {
category: { category: {
type: Object, type: Object,
default: () => {} default: () => {}
}
} }
} };
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.category-mini-card { .category-mini-card {
display: inline-block; display: inline-block;
width: 260rpx; width: 260rpx;
height: 180rpx; height: 180rpx;
position: relative; position: relative;
border-radius: 12rpx; border-radius: 12rpx;
background-color: #fff; background-color: #fff;
overflow: hidden;
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
position: relative;
.img {
width: 100%;
height: 120rpx;
border: 6rpx 6rpx 0 0;
overflow: hidden; overflow: hidden;
} box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
.label { position: relative;
position: absolute;
left: 0;
top: 86rpx;
color: #03a9f4;
font-size: 24rpx;
background-color: rgba(255, 255, 255, 1);
border-radius: 0rpx 24rpx 0 0;
display: flex;
padding: 2rpx 12rpx;
padding-right: 24rpx;
}
.name {
position: absolute;
bottom: 16rpx;
left: 0;
right: 0;
font-size: 24rpx;
text-align: center; text-align: center;
color: #333; color: #ffffff;
&:before {
content: '';
position: absolute;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(3rpx);
}
.content {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 3;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.img {
width: 100%;
height: 100%;
}
.name {
font-weight: bold;
font-size: 30rpx;
}
.label {
font-size: 24rpx;
margin-top: 6rpx;
}
} }
} </style>
</style>
+121 -132
查看文件
@@ -1,167 +1,156 @@
<template> <template>
<view class=" comment-item flex flex-col mt-30 pt-24" :class="{ 'child-comment-item': isChild, 'no-solid': !useSolid, classItem }"> <view v-if="comment" class=" comment-item flex flex-col mt-30 pt-24"
:class="{ 'child-comment-item': isChild, 'no-solid': !useSolid, classItem }">
<view class="comment-item_user flex"> <view class="comment-item_user flex">
<image <image class="user-avatar" :class="{ 'is-radius': globalAppSettings.isAvatarRadius }"
v-if="comment.isAdmin" :src="$utils.checkAvatarUrl(comment.owner.avatar, false)" mode="aspectFill" @error="fnOnImageError(comment)"></image>
class="user-avatar"
:class="{ 'is-radius': globalAppSettings.isAvatarRadius }"
:src="bloggerInfo.avatar"
mode="aspectFill"
@error="fnOnImageError(comment)"
></image>
<image
v-else
class="user-avatar"
:class="{ 'is-radius': globalAppSettings.isAvatarRadius }"
:src="comment.avatar"
mode="aspectFill"
@error="fnOnImageError(comment)"
></image>
<view class="user-info pl-14"> <view class="user-info pl-14">
<view class="author"> <view class="author">
<text class="mr-6 text-grey-darken-1 text-size-m">{{ comment.author }}</text> <text class="mr-6 text-grey-darken-1 text-size-m">{{ comment.owner.displayName }}</text>
<tm-tags v-if="comment.isAdmin" :dense="true" color="bg-gradient-amber-accent" size="xs" model="fill">博主</tm-tags>
<tm-tags v-else :dense="true" color="bg-gradient-light-blue-lighten " size="xs" model="fill">游客</tm-tags>
</view> </view>
<view class="flex mt-4"> <view class="flex mt-4">
<view v-if="false" class="text-size-s text-grey mr-12">IP属地暂无信息</view>
<view class="time text-size-xs text-grey"> <view class="time text-size-xs text-grey">
<text class="">{{ $tm.dayjs(comment.createTime).format('YYYY年MM月DD日') }}</text> <text class="">{{ $tm.dayjs(comment.spec.creationTime).format('YYYY年MM月DD日') }}</text>
<text class="ml-12">{{ $tm.dayjs(comment.createTime).fromNow(true) }}</text> <text class="ml-12">{{ $tm.dayjs(comment.spec.creationTime).fromNow(true) }}</text>
</view> </view>
</view> </view>
</view> </view>
<view v-if="useActions" class=""> <view v-if="useActions" class="">
<tm-button v-if="!disallowComment" size="s" text theme="blue" @click="$emit('on-comment', { type: 'user', comment: comment })">回复</tm-button> <tm-button v-if="!disallowComment" size="s" text theme="blue"
<tm-button size="s" text theme="grey" @click="$emit('on-copy', comment.content)"></tm-button> @click="$emit('on-comment', { type: 'user', comment: comment })"></tm-button>
<tm-button size="s" text theme="grey" @click="$emit('on-copy', comment.spec.raw)">复制</tm-button>
</view> </view>
</view> </view>
<view class="comment-item_content mt-12" :class="{ 'has-bg': useContentBg, 'not-ml': isChild }" @click="$emit('on-detail', comment)" v-html="comment.content"></view> <view class="comment-item_content mt-12" :class="{ 'has-bg': useContentBg, 'not-ml': isChild }"
<!-- <view v-if="useActions" class="comment-item_info text-size-s text-grey"> @click="$emit('on-detail', comment)" v-html="comment.spec.raw"></view>
<text v-if="false" @click="$emit('on-todo')">点赞</text>
<text @click="$emit('on-comment', { type: 'user', comment: comment })">回复</text>
<text v-if="false" class="ml-24" @click="$emit('on-todo')">举报</text>
<text class="ml-24" @click="$emit('on-copy', comment.content)">复制内容</text>
</view> -->
</view> </view>
</template> </template>
<script> <script>
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue'; import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue'; import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
export default { export default {
name: 'comment-item', name: 'comment-item',
components: { tmTags, tmButton }, components: {
props: { tmTags,
classItem: { tmButton
type: Array,
default: () => []
}, },
disallowComment: { props: {
type: Boolean, classItem: {
default: false type: Array,
default: () => []
},
disallowComment: {
type: Boolean,
default: false
},
useActions: {
type: Boolean,
default: true
},
useSolid: {
type: Boolean,
default: true
},
useContentBg: {
type: Boolean,
default: true
},
isChild: {
type: Boolean,
default: false
},
postName: {
type: String,
default: ""
},
comment: {
type: Object,
default: () => null
}
}, },
useActions: { computed: {
type: Boolean, // 获取博主信息
default: true bloggerInfo() {
let blogger = this.$tm.vx.getters().getBlogger;
blogger.avatar = this.$utils.checkAvatarUrl(blogger.avatar, true);
return blogger;
}
}, },
useSolid: { methods: {
type: Boolean, fnOnImageError(data) {
default: true
},
useContentBg: {
type: Boolean,
default: true
},
isChild: {
type: Boolean,
default: false
},
postId: {
type: Number,
default: null
},
comment: {
type: Object,
default: () => {}
}
},
computed: {
// 获取博主信息
bloggerInfo() {
let blogger = this.$tm.vx.getters().getBlogger;
blogger.avatar = this.$utils.checkAvatarUrl(blogger.avatar, true);
return blogger;
}
},
methods: {
fnOnImageError(data) {
if (data.isAdmin) {
data.avatar = this.$haloConfig.author.avatar;
} else {
data.avatar = `${this.$haloConfig.defaultAvatarUrl}&rt=${new Date().getTime()}`; data.avatar = `${this.$haloConfig.defaultAvatarUrl}&rt=${new Date().getTime()}`;
} }
},
created() {
console.log("comment",this.comment)
} }
} };
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.comment-item { .comment-item {
box-sizing: border-box; box-sizing: border-box;
border-top: 2rpx solid #f5f5f5; border-top: 2rpx solid #f5f5f5;
&.child-comment-item { &.child-comment-item {
padding-top: 0; padding-top: 0;
margin-left: 80rpx; margin-left: 80rpx;
border: 0; border: 0;
} }
&.no-solid {
border: 0; &.no-solid {
margin-top: 0 !important; border: 0;
} margin-top: 0 !important;
&_user { }
display: flex;
align-items: center; &_user {
.user-avatar { display: flex;
width: 70rpx; align-items: center;
height: 70rpx;
box-sizing: border-box; .user-avatar {
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.05); width: 70rpx;
border: 4rpx solid #ffffff; height: 70rpx;
border-radius: 12rpx; box-sizing: border-box;
&.is-radius { box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.05);
border-radius: 50%; border: 4rpx solid #ffffff;
border-radius: 12rpx;
&.is-radius {
border-radius: 50%;
}
}
.user-info {
width: 0;
flex-grow: 1;
} }
} }
.user-info {
width: 0;
flex-grow: 1;
}
}
&_content { &_content {
font-size: 28rpx; font-size: 28rpx;
margin-left: 80rpx; margin-left: 80rpx;
box-sizing: border-box; box-sizing: border-box;
border-radius: 10rpx; border-radius: 10rpx;
line-height: 1.8; line-height: 1.8;
color: var(--main-text-color); color: var(--main-text-color);
&.has-bg {
background-color: #fafafa; &.has-bg {
padding: 6rpx 24rpx; background-color: #fafafa;
padding: 6rpx 24rpx;
}
&.not-ml {
margin-left: 80rpx;
}
} }
&.not-ml {
&_info {
margin-top: 6rpx;
display: flex;
align-items: center;
margin-left: 80rpx; margin-left: 80rpx;
} }
} }
&_info { </style>
margin-top: 6rpx;
display: flex;
align-items: center;
margin-left: 80rpx;
}
}
</style>
+207 -217
查看文件
@@ -3,13 +3,8 @@
<!-- 顶部区域 --> <!-- 顶部区域 -->
<view class="comment-list_head"> <view class="comment-list_head">
<view class="title"> <view class="title">
评论列表 <text>评论列表</text>
<text class="count">{{ result.total || 0 }}</text> <text class="count">{{ (result&& result.total) || 0 }}</text>
</view>
<view class="filter">
<text class="filter-item " :class="{ active: sort == 0 }" @click="fnOnSort(0)">默认</text>
<text class="filter-item " :class="{ active: sort == 1 }" @click="fnOnSort(1)">热评</text>
<!-- <text class="filter-item">全部</text> -->
</view> </view>
</view> </view>
<!-- 内容区域 --> <!-- 内容区域 -->
@@ -21,62 +16,44 @@
</view> </view>
<view v-else-if="loading == 'error'" class="error"> <view v-else-if="loading == 'error'" class="error">
<tm-empty icon="icon-wind-cry" label="加载失败"> <tm-empty icon="icon-wind-cry" label="加载失败">
<tm-button theme="bg-gradient-light-blue-accent" size="m" v-if="!disallowComment" @click="fnToComment()">刷新试试</tm-button> <tm-button theme="bg-gradient-light-blue-accent" size="m" v-if="!disallowComment"
@click="fnToComment()">刷新试试</tm-button>
</tm-empty> </tm-empty>
</view> </view>
</view> </view>
<block v-else> <block v-else>
<tm-alerts <tm-alerts v-if="disallowComment && dataList.length !== 0" color="red" text :margin="[0, 0]" :shadow="0"
v-if="disallowComment && dataList.length !== 0" label="Ծ‸Ծ博主已设置该文章禁止评论!" :round="3"></tm-alerts>
color="red"
text
:margin="[0, 0]"
:shadow="0"
label="Ծ‸Ծ博主已设置该文章禁止评论!"
:round="3"
></tm-alerts>
<view class="empty pt-50" v-if="dataList.length == 0"> <view class="empty pt-50" v-if="dataList.length == 0">
<tm-empty v-if="disallowComment" icon="icon-shiliangzhinengduixiang-" label="暂无评论"> <tm-empty v-if="disallowComment" icon="icon-shiliangzhinengduixiang-" label="暂无评论">
<text class="text-red text-size-s">- 文章已开启禁止评论 -</text> <text class="text-red text-size-s">- 文章已开启禁止评论 -</text>
</tm-empty> </tm-empty>
<tm-empty v-else icon="icon-shiliangzhinengduixiang-" label="暂无评论"> <tm-empty v-else icon="icon-shiliangzhinengduixiang-" label="暂无评论">
<tm-button theme="light-blue" :dense="true" :shadow="0" size="m" @click="fnToComment(null)">抢沙发</tm-button> <tm-button theme="light-blue" :dense="true" :shadow="0" size="m"
@click="fnToComment(null)">抢沙发</tm-button>
</tm-empty> </tm-empty>
</view> </view>
<block v-else> <block v-else>
<!-- 评论内容 : 目前仅支持二级评论 --> <!-- 评论内容 : 目前仅支持二级评论 -->
<block v-for="(comment, index) in dataList" :key="comment.id"> <block v-for="(comment, index) in dataList" :key="comment.metadata.name">
<comment-item <comment-item :useContentBg="false" :isChild="false" :comment="comment" :postName="postName"
:useContentBg="false" :disallowComment="disallowComment" @on-copy="fnCopyContent" @on-comment="fnToComment"
:isChild="false" @on-todo="fnToDo" @on-detail="fnShowCommetnDetail"></comment-item>
:comment="comment"
:postId="postId"
:disallowComment="disallowComment"
@on-copy="fnCopyContent"
@on-comment="fnToComment"
@on-todo="fnToDo"
@on-detail="fnShowCommetnDetail"
></comment-item>
<!-- 二级评论 --> <!-- 二级评论 -->
<block v-if="comment.children && comment.children.length != 0"> <block v-if="comment.replies && comment.replies.items.length != 0">
<block v-for="(childComment, childIndex) in comment.children" :key="childComment.id"> <block v-for="(childComment, childIndex) in comment.replies.items"
<comment-item :key="childComment.metadata.name">
:useContentBg="false" <comment-item :useContentBg="false" :isChild="true" :comment="childComment"
:isChild="true" :postName="postName" :disallowComment="disallowComment" @on-copy="fnCopyContent"
:comment="childComment" @on-comment="fnToComment" @on-todo="fnToDo"
:postId="postId" @on-detail="fnShowCommetnDetail"></comment-item>
:disallowComment="disallowComment"
@on-copy="fnCopyContent"
@on-comment="fnToComment"
@on-todo="fnToDo"
@on-detail="fnShowCommetnDetail"
></comment-item>
</block> </block>
</block> </block>
</block> </block>
<view v-if="false" class="to-more-comment"> <view v-if="false" class="to-more-comment">
<tm-button item-class="btn" :block="true" width="90vw" theme="bg-gradient-light-blue-lighten" size="m">点击查看全部评论</tm-button> <tm-button item-class="btn" :block="true" width="90vw" theme="bg-gradient-light-blue-lighten"
size="m">点击查看全部评论</tm-button>
</view> </view>
</block> </block>
</block> </block>
@@ -85,198 +62,211 @@
</template> </template>
<script> <script>
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue'; import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import tmAlerts from '@/tm-vuetify/components/tm-alerts/tm-alerts.vue'; import tmAlerts from '@/tm-vuetify/components/tm-alerts/tm-alerts.vue';
export default { export default {
name: 'comment-list', name: 'comment-list',
components: { tmEmpty, tmButton, tmAlerts }, components: {
props: { tmEmpty,
// 是否禁用评论 tmButton,
disallowComment: { tmAlerts
type: Boolean,
default: false
}, },
postId: { props: {
type: Number, // 是否禁用评论
default: null disallowComment: {
}, type: Boolean,
post: { default: false
type: Object,
default: () => {}
}
},
data() {
return {
loading: 'loading',
sort: 0,
queryParams: {
sort: '',
more: true
}, },
api: 'getPostCommentTree', postName: {
result: {}, type: String,
dataList: [] default: ""
}; },
}, post: {
created() { type: Object,
this.fnGetData(); default: () => {}
uni.$on('comment_list_refresh', () => { }
this.fnOnSort(this.sort, true);
});
},
methods: {
fnOnSort(type, refresh = false) {
if (this.sort == type && refresh == false) return;
const _api = ['getPostCommentTree', 'getPostTopCommentList'];
this.sort = type;
this.api = _api[type];
this.fnGetData();
}, },
fnGetData() { data() {
this.loading = 'loading'; return {
this.$httpApi[this.api](this.postId, {}) loading: 'loading',
.then(res => { queryParams: {
if (res.status == 200) { group: "content.halo.run",
this.result = res.data; kind: "Post",
this.dataList = res.data.content; version: "v1alpha1",
name: "",
page: 1,
size: 50,
withReplies: true,
replySize: 10
},
result: null,
dataList: []
};
},
created() {
this.queryParams.name = this.postName;
this.fnGetData();
uni.$on('comment_list_refresh', () => {
this.fnOnSort(true);
});
},
methods: {
fnOnSort(refresh = false) {
if (refresh == false) return;
this.fnGetData();
},
fnGetData() {
this.loading = 'loading';
this.$httpApi.v2.getPostCommentList(this.queryParams)
.then(res => {
console.log("日志:", res)
this.result = res;
this.dataList = res.items;
this.loading = 'success'; this.loading = 'success';
this.$emit('on-loaded', this.dataList); this.$emit('on-loaded', this.dataList);
} else { })
.catch(err => {
this.loading = 'error'; this.loading = 'error';
} })
}) .finally(() => {
.catch(err => { uni.hideLoading();
this.loading = 'error'; });
}) },
.finally(() => { fnToDo() {
uni.hideLoading(); uni.$tm.toast('Halo暂未支持!');
},
fnToComment(data) {
if (this.disallowComment) {
return uni.$tm.toast('文章已禁止评论!');
}
console.log('data', data);
let _comment = {};
if (data) {
let {
type,
comment
} = data;
// 来自用户
_comment = {
isComment: false,
postName: comment.metadata.name,
title: comment.owner.displayName,
from: 'posts',
formPage: 'comment_list',
type: 'user'
};
} else {
// 来自文章
_comment = {
isComment: true,
postName: this.post.metadata.name,
title: '评论文章:' + this.post.spec.title,
formPage: 'comment_list',
from: 'posts',
type: 'post'
};
}
uni.$tm.vx.commit('comment/setCommentInfo', _comment);
this.$Router.push({
path: '/pagesA/comment/comment',
query: _comment
}); });
}, },
fnToDo() { fnCopyContent(content) {
uni.$tm.toast('Halo暂未支持!'); uni.$tm.u.setClipboardData(content);
}, uni.$tm.toast('内容已复制成功!');
fnToComment(data) { },
if (this.disallowComment) {
return uni.$tm.toast('文章已禁止评论!');
}
console.log(data);
let _comment = {};
if (data) {
let { type, comment } = data;
// 来自用户
_comment = {
id: this.post.id,
parentId: comment.id,
title: comment.author,
from: 'posts',
formPage: 'comment_list',
type: 'user'
};
} else {
// 来自文章
_comment = {
id: this.post.id,
parentId: 0,
title: '评论文章:' + this.post.title,
formPage: 'comment_list',
from: 'posts',
type: 'post'
};
}
uni.$tm.vx.commit('comment/setCommentInfo', _comment); fnShowCommetnDetail(comment) {
this.$Router.push({ this.$emit('on-comment-detail', {
path: '/pagesA/comment/comment', postName: this.postName,
query: _comment comment: comment
}); });
}, }
fnCopyContent(content) {
uni.$tm.u.setClipboardData(content);
uni.$tm.toast('内容已复制成功!');
},
fnShowCommetnDetail(comment) {
this.$emit('on-comment-detail', {
postId: this.postId,
comment: comment
});
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.comment-list { .comment-list {
&_head { &_head {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
position: relative; position: relative;
box-sizing: border-box; box-sizing: border-box;
padding-left: 24rpx; padding-left: 24rpx;
font-size: 30rpx; font-size: 30rpx;
font-weight: bold; font-weight: bold;
&:before { &:before {
content: ''; content: '';
position: absolute; position: absolute;
left: 0rpx; left: 0rpx;
top: 8rpx; top: 8rpx;
width: 8rpx; width: 8rpx;
height: 26rpx; height: 26rpx;
background-color: rgb(3, 174, 252); background-color: rgb(3, 174, 252);
border-radius: 6rpx; border-radius: 6rpx;
}
.title {
.count {
font-size: 28rpx;
font-weight: normal;
} }
}
.filter {
font-size: 26rpx;
font-weight: normal;
&-item { .title {
margin-left: 20rpx; .count {
color: #666; font-size: 28rpx;
&.active { font-weight: normal;
font-weight: bold; }
color: rgb(255, 152, 0); }
font-size: 26rpx;
.filter {
font-size: 26rpx;
font-weight: normal;
&-item {
margin-left: 20rpx;
color: #666;
&.active {
font-weight: bold;
color: rgb(255, 152, 0);
font-size: 26rpx;
}
} }
} }
} }
}
&_content {
margin-top: 24rpx;
padding-bottom: 36rpx;
}
}
.loading-wrap {
width: 100%;
height: 506rpx;
.loading {
width: 100%;
}
.e-loading-icon { &_content {
font-size: 100rpx; margin-top: 24rpx;
} padding-bottom: 36rpx;
}
.to-more-comment {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
margin-top: 80rpx;
::v-deep {
.tm-button .tm-button-btn uni-button {
height: 70rpx;
} }
} }
}
</style> .loading-wrap {
width: 100%;
height: 506rpx;
.loading {
width: 100%;
}
.e-loading-icon {
font-size: 100rpx;
}
}
.to-more-comment {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
margin-top: 80rpx;
::v-deep {
.tm-button .tm-button-btn uni-button {
height: 70rpx;
}
}
}
</style>
+120 -133
查看文件
@@ -2,47 +2,31 @@
<!-- 轮播图 --> <!-- 轮播图 -->
<view class="Swiper-mfw-index-box"> <view class="Swiper-mfw-index-box">
<view class="Swiper-mfw-index Swiper-box" :class="[dotPosition]"> <view class="Swiper-mfw-index Swiper-box" :class="[dotPosition]">
<swiper <swiper class="Swiper-mfw" :style="{ height: height }" :circular="true" :indicator-dots="false"
class="Swiper-mfw" :autoplay="autoplay" :interval="3000" :duration="1000" :current="currentIndex"
:style="{ height: height }" :disable-touch="disable_touch" @change="change">
:circular="true"
:indicator-dots="false"
:autoplay="autoplay"
:interval="3000"
:duration="1000"
:current="currentIndex"
:disable-touch="disable_touch"
@change="change"
>
<!-- 只需要前5条数据 --> <!-- 只需要前5条数据 -->
<swiper-item class="swiper-mfw-item" v-if="index <= (dotPosition == 'right' ? 3 : 4)" v-for="(item, index) in list" :key="index"> <block v-for="(item, index) in list" :key="index">
<!-- /* <swiper-item class="swiper-mfw-item" v-if="index <= 4">
<!-- /*
1. 这里不需要用api控制暂停视频 1. 这里不需要用api控制暂停视频
2. 因为video标签上加了v-if="current==index" 2. 因为video标签上加了v-if="current==index"
3. 当current == index时才会创建视频组件 3. 当current == index时才会创建视频组件
4. 否current != index则就销毁视频 4. 否current != index则就销毁视频
*/ --> */ -->
<!-- 如果有视频则显示视频--> <!-- 如果有视频则显示视频-->
<template v-if="item.mp4 && current == index"> <template v-if="item.mp4 && current == index">
<video <video class="ImageVideo" :id="'ImageVideo' + index" :ref="'ImageVideo' + index"
class="ImageVideo" :src="item.mp4" :loop="true" :muted="false" :autoplay="current == index ? true : false"
:id="'ImageVideo' + index" :controls="false" :show-fullscreen-btn="false" :show-play-btn="false"
:ref="'ImageVideo' + index" :enable-progress-gesture="false" :play-strategy="0"
:src="item.mp4" :poster="item.image || item.src"></video>
:loop="true" </template>
:muted="false" <!-- 否则显示图片 -->
:autoplay="current == index ? true : false" <image v-else :src="item.image || item.src" class="Image" mode="aspectFill"
:controls="false" @click.stop="$emit('on-click', item)"></image>
:show-fullscreen-btn="false" </swiper-item>
:show-play-btn="false" </block>
:enable-progress-gesture="false"
:play-strategy="0"
:poster="item.image || item.src"
></video>
</template>
<!-- 否则显示图片 -->
<image v-else :src="item.image || item.src" class="Image" mode="aspectFill" @click.stop="$emit('on-click', item)"></image>
</swiper-item>
</swiper> </swiper>
<!-- 指示器 [Top] --> <!-- 指示器 [Top] -->
<view v-if="useTop" class="Swiper-indicator-box indicator-Top-box"> <view v-if="useTop" class="Swiper-indicator-box indicator-Top-box">
@@ -84,12 +68,15 @@
<!-- 用户信息 --> <!-- 用户信息 -->
<view class="Bottom-UserInfo"> <view class="Bottom-UserInfo">
<!-- 头像 --> <!-- 头像 -->
<view class="UserImage-box"><image :src="item.avatar" class="Image" mode="aspectFill"></image></view> <view class="UserImage-box">
<image :src="item.avatar" class="Image" mode="aspectFill"></image>
</view>
<!-- 用户名 --> <!-- 用户名 -->
<view class="textbox UserName-box"> <view class="textbox UserName-box">
<text class="text UserInfo">{{ item.nickname }}</text> <text class="text UserInfo">{{ item.nickname }}</text>
</view> </view>
<view v-if="item.createTime" class="jiange-box"><text class="text jiange-text"></text></view> <view v-if="item.createTime" class="jiange-box"><text class="text jiange-text"></text>
</view>
<view v-if="item.createTime" class="textbox UserGPS-box"> <view v-if="item.createTime" class="textbox UserGPS-box">
<text class="text UserInfo">发布于 {{ item.createTime }}</text> <text class="text UserInfo">发布于 {{ item.createTime }}</text>
</view> </view>
@@ -106,18 +93,14 @@
<!-- 左边 --> <!-- 左边 -->
<view class="Bottom-left-Imagelist"> <view class="Bottom-left-Imagelist">
<block v-for="(item, index) in list" :key="index"> <block v-for="(item, index) in list" :key="index">
<view <view class="Bottom-item" v-if="Number(index) <= 4"
class="Bottom-item" :class="currentIndex == index ? 'current' : 'no'" @click="SwiperIndTap(index)">
v-if="Number(index) <= (dotPosition == 'right' ? 3 : 4)"
:class="currentIndex == index ? 'current' : 'no'"
@click="SwiperIndTap(index)"
>
<image :src="item.image || item.src" class="Image" mode="aspectFill"></image> <image :src="item.image || item.src" class="Image" mode="aspectFill"></image>
</view> </view>
</block> </block>
</view> </view>
<!-- 右边 --> <!-- 右边 -->
<view class="Bottom-right-lili-btn"> <view v-if="false" class="Bottom-right-lili-btn">
<view class="Bottom-item is-more"> <view class="Bottom-item is-more">
<view class="more" @click.stop="$emit('on-more')"> <view class="more" @click.stop="$emit('on-more')">
MORE MORE
@@ -132,102 +115,106 @@
</template> </template>
<script> <script>
export default { export default {
name: 'e-swiper', name: 'e-swiper',
props: { props: {
title: { title: {
type: String, type: String,
default: '' default: ''
}, },
height: { height: {
type: String, type: String,
default: '450rpx' default: '450rpx'
}, },
dotPosition: { dotPosition: {
type: String, type: String,
default: 'bottom' default: 'bottom'
}, },
useTop: { useTop: {
type: Boolean, type: Boolean,
default: true default: true
}, },
useDot: { useDot: {
type: Boolean, type: Boolean,
default: true default: true
}, },
useTitle: { useTitle: {
type: Boolean, type: Boolean,
default: true default: true
}, },
useUser: { useUser: {
type: Boolean, type: Boolean,
default: true default: true
}, },
// 轮播图 数据列表 // 轮播图 数据列表
list: { list: {
type: Array, type: Array,
default: () => [] default: () => []
}, },
// 当前选中的项(指示器坐标位置) // 当前选中的项(指示器坐标位置)
current: { current: {
type: Number, type: Number,
default: 0 default: 0
}, },
// 是否自动轮播 // 是否自动轮播
autoplay: { autoplay: {
type: Boolean, type: Boolean,
default: false default: false
}
},
data() {
return {
// 是否禁止用户 touch 操作
currentIndex: 0,
disable_touch: false, //touch 用户划动引起swiper变化。
date: {
year: '-',
monthEn: '-',
month: '-'
} }
}; },
}, data() {
created() { return {
this.currentIndex = this.current; // 是否禁止用户 touch 操作
const date = new Date(); currentIndex: 0,
//将月份名称存储在数组中 disable_touch: false, //touch 用户划动引起swiper变化。
const monthArray = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); date: {
year: '-',
monthEn: '-',
month: '-'
}
};
},
created() {
this.currentIndex = this.current;
const date = new Date();
//将月份名称存储在数组中
const monthArray = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov',
'Dec');
this.date.year = date.getFullYear(); this.date.year = date.getFullYear();
let month = date.getMonth() + 1; let month = date.getMonth() + 1;
this.date.month = month < 10 ? '0' + month : month; this.date.month = month < 10 ? '0' + month : month;
this.date.monthEn = monthArray[date.getMonth()].toUpperCase(); this.date.monthEn = monthArray[date.getMonth()].toUpperCase();
}, },
methods: { methods: {
// current 改变时会触发 change 事件,event.detail = {current: current, source: source} // current 改变时会触发 change 事件,event.detail = {current: current, source: source}
change(e) { change(e) {
let { current, source } = e.detail; let {
//只有页面自动切换,手动切换时才轮播,其他不允许 current,
if (source === 'autoplay' || source === 'touch') { source
} = e.detail;
//只有页面自动切换,手动切换时才轮播,其他不允许
if (source === 'autoplay' || source === 'touch') {
let event = {
current: current
};
this.currentIndex = current;
this.$emit('change', event);
}
},
// 手动点击了指示器[小图模式]
SwiperIndTap(e) {
let index = e;
let event = { let event = {
current: current current: index
}; };
this.currentIndex = current; this.currentIndex = index;
this.$emit('change', event); this.$emit('change', event);
} }
},
// 手动点击了指示器[小图模式]
SwiperIndTap(e) {
let index = e;
let event = {
current: index
};
this.currentIndex = index;
this.$emit('change', event);
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import './e-swiper.scss'; @import './e-swiper.scss';
</style> </style>
+5 -22
查看文件
@@ -2,29 +2,12 @@
* 广告配置 * 广告配置
*/ */
export default { export default {
adpid: '', // uni-AD App广告位id,在uni-AD官网申请广告位
unitId: '', // 广告单元id,可在小程序管理后台的流量主模块新建 (非个人资质,小程序后台广告主开通申请)
frequency: 8, // 列表中,广告出现的频率(8=每8条数据出现一次广告)
// 首页广告
home: {
use: false,
},
// 文章列表广告
articles: {
use: false,
},
// 文章详情广告 // 文章详情广告
articleDetail: { articleDetail: {
// 微信广告/dclound申请的广告
use: true, use: true,
cover: 'https://b.925i.cn/uni_halo/uni_halo_ad_cover.png',
// 自定义广告 title: 'uni-halo 正式开源啦,欢迎来使用和体验!',
custom: { content: '基于 uni-app + halo1.x API 实现一款现代化的开源博客 / CMS 系统API开发的多端应用。功能包括:前台博客系统 和 后台管理系统,同时满足浏览和管理两端合一的需求,真正实现一个应用实现博客浏览和后台管理。',
use: true, url: 'https://uni-halo.925i.cn'
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'
}
} }
} }
+7 -46
查看文件
@@ -13,10 +13,7 @@ export default {
showCopyright: true, // 显示开源版权信息 showCopyright: true, // 显示开源版权信息
showAbout: true, // 显示关于项目入口 showAbout: true, // 显示关于项目入口
uni_halo_logo: 'https://b.925i.cn/uni_halo/uni_halo_logo.png', // uni-halo的logo uni_halo_logo: 'https://b.925i.cn/uni_halo/uni_halo_logo.png', // uni-halo的logo
apiUrl: '', // Api基础域名 [必填] :你的Halo博客基础域名
apiAuthorization: '', // Api认证key [必填]: Halo中-系统-博客设置-切换到高级选项-API设置-Access key
title: '', // 博客标题 [建议必填]:在某些页面没有设置具体的页面名称时候,使用该值显示 title: '', // 博客标题 [建议必填]:在某些页面没有设置具体的页面名称时候,使用该值显示
miniCodeImageUrl: '', // 小程序的太阳码/二维码的图片地址 [建议必填] miniCodeImageUrl: '', // 小程序的太阳码/二维码的图片地址 [建议必填]
@@ -25,12 +22,12 @@ export default {
// 启动页面的配置(页面地址`/pagesA/start/start`) // 启动页面的配置(页面地址`/pagesA/start/start`)
start: { start: {
use: true, // 是否使用首次启动页:用户第一次使用你的应用会显示否则不显示 use: true, // 是否使用首次启动页:用户第一次使用你的应用会显示否则不显示
title: 'uni-halo', // 启动页面中的文字标题 title: 'uni-halo2.0', // 标题
bg: '', // 留空则使用默认 开屏首页背景,可以是颜色值或者图片图片地址 bg: '', // 留空则使用默认 开屏首页背景,可以是颜色值或者图片图片地址
logo: 'https://b.925i.cn/uni_halo/uni_halo_logo.png', // logo logo: 'https://b.925i.cn/uni_halo/uni_halo_logo.png', // 开屏首页图片
desc1: '全新UI,准备出发', // 描述信息1 desc1: '准备好了吗,即刻就出发', // 描述信息1
desc2: '新触动 新感受 新体验', // 描述信息2 desc2: '新触动 新感受 新体验', // 描述信息2
btnText: '全新触发' // 按钮文字 btnText: '立即体验'
}, },
// 博主信息 // 博主信息
@@ -81,43 +78,7 @@ export default {
list: [], list: [],
}, },
quickNav: { // 快捷导航配置(如不需要恋爱日记,请注释或删除94-101行的代码)
use: true, // 是否在个人中心显示以下页面的入口
list: [{
icon: 'halocoloricon-classify',
text: '文章归档',
iconSize: 60,
color: 'blue',
type: 'page',
path: '/pagesA/archives/archives'
},
{
icon: 'halocoloricon-attent',
text: '恋爱日记',
iconSize: 60,
color: 'blue',
type: 'page',
path: '/pagesA/love/love'
},
{
icon: 'halocoloricon-calendar',
text: '个人日记',
iconSize: 60,
color: 'blue',
type: 'page',
path: '/pagesA/journal/journal'
},
{
icon: 'halocoloricon-message',
text: '留言板',
iconSize: 60,
color: 'blue',
type: 'page',
path: '/pagesA/leaving/leaving'
}
]
},
// 微信分享信息 // 微信分享信息
wxShareConfig: { wxShareConfig: {
title: '', // 小程序分享标题[非必填] title: '', // 小程序分享标题[非必填]
@@ -136,4 +97,4 @@ export default {
'#1CBCB4', '#1CBCB4',
'#6638B5', '#6638B5',
] ]
} }
-7
查看文件
@@ -1,7 +0,0 @@
/**
* 配置key
*/
export default {
SHEET_LEAVING: 'leaving', // 留言板
}
+8 -8
查看文件
@@ -27,13 +27,13 @@ export default {
title: '关于我们', title: '关于我们',
desc: '我们一起度过的那些经历' desc: '我们一起度过的那些经历'
}, },
{ // {
key: 'album', // key: 'album',
use: true, // use: true,
iconImageUrl: 'https://b.925i.cn/uni_halo_love/diandian.png', // iconImageUrl: 'https://b.925i.cn/uni_halo_love/diandian.png',
title: '恋爱相册', // title: '恋爱相册',
desc: '定格了我们的那些小美好' // desc: '定格了我们的那些小美好'
}, // },
{ {
key: 'list', key: 'list',
use: true, use: true,
@@ -145,4 +145,4 @@ export default {
} }
], ],
} }
} }
+1 -9
查看文件
@@ -29,13 +29,6 @@ export default {
title: '关于我们', title: '关于我们',
desc: '我们一起度过的那些经历' desc: '我们一起度过的那些经历'
}, },
{
key: 'album',
use: true,
iconImageUrl: 'https://b.925i.cn/uni_halo_love/diandian.png',
title: '恋爱相册',
desc: '定格了我们的那些小美好'
},
{ {
key: 'list', key: 'list',
use: true, use: true,
@@ -49,8 +42,7 @@ export default {
journey: ` journey: `
<p>有一只马,它的邻居是一只驴。</p><p>有一天,马和驴都被主人牵到外面晒太阳,马和驴聊起了天。</p><p>马说:“我叫马,你呢?”</p><p>驴说:“我叫驴。(哄小宝贝睡觉的甜甜睡前故事)”</p><p>马说:“为什么我俩的名字不一样呢?”</p><p>驴说:“因为我和你不一样。”</p><p>马说:“我们俩什么地方不一样呢?”</p><p>驴说:“我身材小巧,而你却比较粗壮,不如我耐看。”马看了看比自已矮小很多的驴,认为驴说的话有点道理。</p><p>马说:“我们俩除了身材不一样,还有什么不同呢?”</p><p>驴说:“我们俩的声音不一样,我的声音多动听呀!”说着驴伸长脖子叫了两声。“不信,你也叫两声试试。”马也伸长脖子嘶鸣了两声,的确和驴的声音有点不同,马不好意思地低下了头。</p><p>过了一会儿,马又说:“我们俩除了身材和声音不一样外,还有什么不同呢?”</p><p>驴说:“我的步伐多么优雅呀。”说着,驴迈开蹄子走了两步,“而你呢,却昂首阔步,一点儿也不优雅,(如何哄女朋友睡觉的睡前故事爱情浪漫)不信你走两步试试。”</p><p>马听驴这么一说,就高昂着头走了两步,旋即,马飞奔了起来,转了一圈回来后,驴得意地说:“怎么样,我没说错罢,你就是急性子,和优雅不沾边。”马听了驴的话,有点感到惭愧。</p><p>最后,马又鼓起勇气说:“我们俩还有什么不同呢?”</p><p>驴说:“我的家庭意识比你强,主人抽我一鞭子,我就跟着主人回家,而你呢?恐怕不会吧……”</p><p>马还没有来得及回答,马和驴的主人同时来到了马和驴的身边。只见驴的主人抽了驴一鞭子后,驴乖乖地跟着主人回家了。马把这一切都看在了眼里,它为自已和驴的诸多不同而感到惭愧,只见马的主人也抽了马一鞭子,马犹豫了一下,终于象驴一样乖乖地跟着主人回了家。</p><p>一个伯乐站在远处看到了这一幕后,叹口气离开了。</p> <p>有一只马,它的邻居是一只驴。</p><p>有一天,马和驴都被主人牵到外面晒太阳,马和驴聊起了天。</p><p>马说:“我叫马,你呢?”</p><p>驴说:“我叫驴。(哄小宝贝睡觉的甜甜睡前故事)”</p><p>马说:“为什么我俩的名字不一样呢?”</p><p>驴说:“因为我和你不一样。”</p><p>马说:“我们俩什么地方不一样呢?”</p><p>驴说:“我身材小巧,而你却比较粗壮,不如我耐看。”马看了看比自已矮小很多的驴,认为驴说的话有点道理。</p><p>马说:“我们俩除了身材不一样,还有什么不同呢?”</p><p>驴说:“我们俩的声音不一样,我的声音多动听呀!”说着驴伸长脖子叫了两声。“不信,你也叫两声试试。”马也伸长脖子嘶鸣了两声,的确和驴的声音有点不同,马不好意思地低下了头。</p><p>过了一会儿,马又说:“我们俩除了身材和声音不一样外,还有什么不同呢?”</p><p>驴说:“我的步伐多么优雅呀。”说着,驴迈开蹄子走了两步,“而你呢,却昂首阔步,一点儿也不优雅,(如何哄女朋友睡觉的睡前故事爱情浪漫)不信你走两步试试。”</p><p>马听驴这么一说,就高昂着头走了两步,旋即,马飞奔了起来,转了一圈回来后,驴得意地说:“怎么样,我没说错罢,你就是急性子,和优雅不沾边。”马听了驴的话,有点感到惭愧。</p><p>最后,马又鼓起勇气说:“我们俩还有什么不同呢?”</p><p>驴说:“我的家庭意识比你强,主人抽我一鞭子,我就跟着主人回家,而你呢?恐怕不会吧……”</p><p>马还没有来得及回答,马和驴的主人同时来到了马和驴的身边。只见驴的主人抽了驴一鞭子后,驴乖乖地跟着主人回家了。马把这一切都看在了眼里,它为自已和驴的诸多不同而感到惭愧,只见马的主人也抽了马一鞭子,马犹豫了一下,终于象驴一样乖乖地跟着主人回了家。</p><p>一个伯乐站在远处看到了这一幕后,叹口气离开了。</p>
`, `,
// 恋爱相册
albumKeyName: '恋爱相册', // 对应后台的图库分组名称
// 恋爱清单 // 恋爱清单
loveList: { loveList: {
useApi: false, // 是否启用api接口 useApi: false, // 是否启用api接口
-8
查看文件
@@ -1,8 +0,0 @@
/**
* 页面配置
*/
import AppKeys from './keys.js'
export default {
[AppKeys.SHEET_LEAVING]: 65, // 留言板页面ID
}
+16
查看文件
@@ -0,0 +1,16 @@
/** 配置后台管理员token */
const HaloTokenConfig = Object.freeze({
/** 基础请求域名:你的Halo博客基础域名 */
BASE_API: "https://demo.halo.run",
// BASE_API: "https://blog.925i.cn",
/** 管理员token */
systemToken: ``,
/** 匿名用户token */
anonymousToken: ``
})
export default HaloTokenConfig;
+2 -1
查看文件
@@ -63,8 +63,9 @@ import ApiManager from '@/api/index.js'
Vue.use(ApiManager); Vue.use(ApiManager);
import HaloConfig from '@/config/halo.config.js' import HaloConfig from '@/config/halo.config.js'
import HaloTokenConfig from '@/config/token.config.js'
Vue.prototype.$haloConfig = HaloConfig Vue.prototype.$haloConfig = HaloConfig
Vue.prototype.$baseApiUrl = HaloConfig.apiUrl Vue.prototype.$baseApiUrl = HaloTokenConfig.BASE_API
import HaloAdConfig from '@/config/ad.config.js' import HaloAdConfig from '@/config/ad.config.js'
Vue.prototype.$haloAdConfig = HaloAdConfig Vue.prototype.$haloAdConfig = HaloAdConfig
+3 -3
查看文件
@@ -157,12 +157,12 @@
"devServer" : { "devServer" : {
"disableHostCheck" : true, "disableHostCheck" : true,
"proxy" : { "proxy" : {
"/api" : { "/apis" : {
"target" : "https://b.925i.cn", "target" : "https://demo.halo.run",
"changeOrigin" : true, "changeOrigin" : true,
"secure" : false, "secure" : false,
"pathRewrite" : { "pathRewrite" : {
"^/api" : "/api" "^/apis" : "/apis"
} }
} }
} }
+17 -18
查看文件
@@ -24,7 +24,7 @@
"path": "pages/tabbar/category/category", "path": "pages/tabbar/category/category",
"style": { "style": {
"navigationBarTitleText": "分类", "navigationBarTitleText": "分类",
"enablePullDownRefresh": false, "enablePullDownRefresh": true,
"app-plus": { "app-plus": {
"pullToRefresh": { "pullToRefresh": {
"color": "#03a9f4", "color": "#03a9f4",
@@ -45,9 +45,9 @@
} }
} }
}, { }, {
"path": "pages/tabbar/links/links", "path": "pages/tabbar/moments/moments",
"style": { "style": {
"navigationBarTitleText": "友链", "navigationBarTitleText": "瞬间",
"enablePullDownRefresh": true, "enablePullDownRefresh": true,
"app-plus": { "app-plus": {
"pullToRefresh": { "pullToRefresh": {
@@ -160,6 +160,18 @@
} }
} }
}, {
"path": "friend-links/friend-links",
"style": {
"navigationBarTitleText": "友情链接",
"enablePullDownRefresh": true,
"app-plus": {
"pullToRefresh": {
"color": "#03a9f4",
"style": "circle"
}
}
}
}, { }, {
"path": "journal/journal", "path": "journal/journal",
"style": { "style": {
@@ -172,19 +184,6 @@
} }
} }
} }
}, {
"path": "leaving/leaving",
"style": {
"navigationBarTitleText": "留言板",
"enablePullDownRefresh": true,
"app-plus": {
"pullToRefresh": {
"color": "#03a9f4",
"style": "circle"
}
}
}
}, { }, {
"path": "articles/articles", "path": "articles/articles",
"style": { "style": {
@@ -572,8 +571,8 @@
}, { }, {
"iconPath": "static/tabbar/select_links.png", "iconPath": "static/tabbar/select_links.png",
"selectedIconPath": "static/tabbar/select_links_active.png", "selectedIconPath": "static/tabbar/select_links_active.png",
"pagePath": "pages/tabbar/links/links", "pagePath": "pages/tabbar/moments/moments",
"text": "友链" "text": "瞬间"
}, { }, {
"iconPath": "static/tabbar/select_mine.png", "iconPath": "static/tabbar/select_mine.png",
"selectedIconPath": "static/tabbar/select_mine_active.png", "selectedIconPath": "static/tabbar/select_mine_active.png",
+29 -24
查看文件
@@ -3,29 +3,34 @@
</template> </template>
<script> <script>
export default { export default {
onLoad() { onLoad() {
this.fnCheckShowStarted(); this.fnCheckShowStarted();
}, },
methods: { methods: {
// 检查是否需要跳转到启动页 // 检查是否需要跳转到启动页
fnCheckShowStarted() { fnCheckShowStarted() {
if (!getApp().globalData.start.use) { if (!getApp().globalData.start.use) {
uni.switchTab({ uni.switchTab({
url: '/pages/tabbar/home/home' // url: '/pages/tabbar/home/home'
}); url: '/pages/tabbar/moments/moments'
return; });
} return;
if (uni.getStorageSync('APP_HAS_STARTED')) { }
uni.switchTab({ if (uni.getStorageSync('APP_HAS_STARTED')) {
url: '/pages/tabbar/home/home' uni.switchTab({
}); // url: '/pages/tabbar/home/home'
} else { url: '/pages/tabbar/moments/moments'
uni.redirectTo({ });
url: '/pagesA/start/start' // uni.navigateTo({
}); // url: '/pagesA/friend-links/friend-links'
// });
} else {
uni.redirectTo({
url: '/pagesA/start/start'
});
}
} }
} }
} };
}; </script>
</script>
檔案差異因為檔案過大而無法顯示 載入差異
+131 -156
查看文件
@@ -4,89 +4,86 @@
<tm-skeleton model="listAvatr"></tm-skeleton> <tm-skeleton model="listAvatr"></tm-skeleton>
<tm-skeleton model="listAvatr"></tm-skeleton> <tm-skeleton model="listAvatr"></tm-skeleton>
<tm-skeleton model="listAvatr"></tm-skeleton> <tm-skeleton model="listAvatr"></tm-skeleton>
<tm-skeleton model="listAvatr"></tm-skeleton>
</view> </view>
<view v-else class="content flex"> <!-- 内容区域 -->
<view v-if="categoryList.length == 0" class="category-empty flex flex-center"> <view v-else class="app-page-content">
<tm-empty icon="icon-shiliangzhinengduixiang-" label="博主还没有文章分类~"></tm-empty> <view v-if="dataList.length == 0" class="content-empty flex flex-center">
<!-- 空布局 -->
<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无数据"></tm-empty>
</view> </view>
<block v-else> <block v-else>
<tm-sliderNav :list="categoryList" bg-color="white" color="light-blue" rang-key="name" @change="fnOnCategoryChange"></tm-sliderNav> <block v-for="(item, index) in dataList" :key="index">
<scroll-view class="right-content pt-12 pb-12" :scroll-y="true" :scroll-top="scrollTop" :scroll-with-animation="true" :refresher-enabled="true" :refresher-triggered="triggered" :refresher-threshold="60" refresher-background="#fafafa" @refresherrefresh="fnGetData(true)" @scrolltolower="fnGetData(false)" @scroll="fnOnScroll" @touchmove.stop @touchstart="fnOnTouchStart" @touchend="fnOnTouchEnd" @touchcancel="fnOnTouchEnd"> <!-- 卡片 -->
<view v-if="dataList.length == 0" class="article-empty flex flex-center"> <tm-translate style="box-sizing: border-box;width: 50%;padding: 0 8rpx;" animation-name="fadeUp"
<tm-empty icon="icon-shiliangzhinengduixiang-" label="该分类下暂无文章~"></tm-empty> :wait="calcAniWait()">
</view> <view class="catgory-card" :style="{backgroundImage:`url(${item.spec.cover})`}">
<view class="content">
<block v-else> <view style="font-size: 32rpx;color: #ffffff;">{{item.spec.displayName}}</view>
<block v-for="(article, index) in dataList" :key="article.createTime"> <view style="font-size: 24rpx;color: #ffffff;margin-top: 6rpx;">
<!-- 文章卡片 --> {{item.postCount}} 篇文章
<tm-translate animation-name="fadeUp" :wait="calcAniWait(index)"> </view>
<article-min-card :article="article" @on-click="fnToArticleDetail"></article-min-card> </view>
</tm-translate> </view>
</block> </tm-translate>
<view class="load-text">{{ loadMoreText }}</view> </block>
</block> <tm-flotbutton @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton>
</scroll-view> <view class="load-text">{{ loadMoreText }}</view>
</block> </block>
</view> </view>
<tm-flotbutton v-if="dataList.length > 10" color="light-blue" @click="fnToTopScroll" size="m" icon="icon-angle-up"></tm-flotbutton>
</view> </view>
</template> </template>
<script> <script>
import throttle from '@/utils/throttle.js';
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmFlowLayout from '@/tm-vuetify/components/tm-flowLayout/tm-flowLayout.vue';
import tmSliderNav from '@/tm-vuetify/components/tm-sliderNav/tm-sliderNav.vue';
import ArticleMinCard from '@/components/article-min-card/article-min-card.vue'; import MarkdownConfig from '@/common/markdown/markdown.config.js';
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmTranslate,
tmFlotbutton, tmFlotbutton,
tmTranslate,
tmEmpty, tmEmpty,
tmFlowLayout, mpHtml
tmSliderNav,
ArticleMinCard
}, },
data() { data() {
return { return {
markdownConfig: MarkdownConfig,
loading: 'loading', loading: 'loading',
queryParams: { queryParams: {
size: 10, size: 10,
page: 0, page: 1
slug: ''
}, },
categoryList: [],
result: null, result: null,
dataList: [], dataList: [],
isLoadMore: false, isLoadMore: false,
loadMoreText: '', loadMoreText: '加载中...'
scrollTop: 0,
tempScrollTop: 0,
scrollTimeout: null,
triggered: false
}; };
}, },
onLoad() { computed: {
this.fnSetPageTitle('文章分类'); bloggerInfo() {
this.fnGetAllCategory(); return this.$tm.vx.getters().getBlogger;
},
}, },
onPullDownRefresh() {
this.queryParams.page = 0; onLoad() {
this.isLoadMore = false;
this.fnGetData(); this.fnGetData();
}, },
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
onReachBottom(e) { onReachBottom(e) {
if (this.result.hasNext) { if (this.result.hasNext) {
this.queryParams.page += 1; this.queryParams.page += 1;
this.isLoadMore = true; this.isLoadMore = true;
this.fnGetData(false); this.fnGetData();
} else { } else {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
@@ -95,101 +92,55 @@
} }
}, },
methods: { methods: {
fnOnCategoryChange(e) { fnGetData() {
this.fnResetSetAniWaitIndex(); uni.showLoading({
this.queryParams.slug = this.categoryList[e].slug; mask: true,
this.fnToTopScroll(); title: '加载中...'
this.dataList = []; });
this.fnGetData(); // 设置状态为加载中
}, if (!this.isLoadMore) {
this.loading = 'loading';
fnGetAllCategory() { }
this.loading = 'loading'; this.loadMoreText = '加载中...';
// uni.showLoading({ this.$httpApi.v2
// mask: true, .getCategoryList(this.queryParams)
// title: '加载中...'
// });
this.$httpApi
.getCategoryList({ more: true })
.then(res => { .then(res => {
this.categoryList = res.data; console.log('请求结果:');
if (res.data.length != 0) { console.log(res);
this.queryParams.slug = res.data[0].slug;
this.triggered = false; this.loading = 'success';
this.loading = 'success'; this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
this.fnGetData(true, false); // 处理数据
this.result = res;
const tempItems = res.items.map(item => {
item.spec.cover = this.$utils.checkThumbnailUrl(item.spec.cover, true)
return item;
})
if (this.isLoadMore) {
this.dataList = this.dataList.concat(tempItems);
} else {
this.dataList = tempItems;
} }
}) })
.catch(err => { .catch(err => {
console.error(err); console.error(err);
this.loading = 'error'; this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
}) })
.finally(() => { .finally(() => {
uni.hideLoading(); setTimeout(() => {
uni.stopPullDownRefresh(); uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
}); });
}, },
fnGetData(isPulldownRefresh = true, triggered = true) { handlePreview(index, list) {
if (!isPulldownRefresh) { uni.previewImage({
if (this.result.hasNext) { current: index,
this.queryParams.page += 1; urls: list.map(item => item.url)
} else { })
return uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
} else {
this.queryParams.page = 0;
if (triggered) {
this.triggered = true;
}
}
this.$httpApi
.getCategoryPostList(this.queryParams.slug, this.queryParams)
.then(res => {
this.result = res.data;
if (!isPulldownRefresh) {
this.dataList = this.dataList.concat(res.data.content);
} else {
this.dataList = res.data.content;
}
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
})
.catch(err => {
this.loadMoreText = '加载失败!';
})
.finally(() => {
this.triggered = false;
});
},
//跳转文章详情
fnToArticleDetail(article) {
uni.navigateTo({
url: '/pagesA/article-detail/article-detail?articleId=' + article.id,
animationType: 'slide-in-right'
});
},
fnOnScroll(e) {
this.tempScrollTop = e.detail.scrollTop;
},
fnToTopScroll() {
uni.pageScrollTo({
scrollTop: 0,
duration: 500
});
this.scrollTop = 0;
this.tempScrollTop = 0;
},
fnOnTouchStart() {
clearTimeout(this.scrollTimeout);
},
fnOnTouchEnd() {
this.scrollTimeout = setTimeout(() => {
this.scrollTop = this.tempScrollTop;
}, 500);
} }
} }
}; };
@@ -198,37 +149,61 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background-color: #fff; padding: 24rpx 0;
}
.content {
height: 100vh;
background-color: #fafafa;
}
.category-empty {
width: 100%;
height: 70vh;
}
.article-empty {
width: 100%;
height: 70vh;
}
.right-content {
// width: calc(100vw - 144rpx);
width: calc(100vw - 190rpx);
height: 100vh;
background-color: #fff;
white-space: nowrap;
background-color: #fafafa;
} }
.loading-wrap { .loading-wrap {
padding: 24rpx; padding: 24rpx;
} }
.app-page-content {
display: flex;
flex-wrap: wrap;
padding: 0 12rpx;
gap: 20rpx 0;
}
.catgory-card {
width: 100%;
height: 200rpx;
position: relative;
display: flex;
flex-direction: column;
box-sizing: border-box;
border-radius: 12rpx;
background-color: #ffff;
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
overflow: hidden;
background-repeat: no-repeat;
background-size: cover;
&:before {
content: '';
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.15);
z-index: 1;
}
}
.content {
width: 100%;
height: 100%;
position: relative;
z-index: 2;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.load-text {
width: 100%;
text-align: center;
}
</style> </style>
+51 -117
查看文件
@@ -2,7 +2,8 @@
<view class="app-page"> <view class="app-page">
<!-- 顶部切换 --> <!-- 顶部切换 -->
<view class="e-fixed" v-if="category.list.length > 2"> <view class="e-fixed" v-if="category.list.length > 2">
<tm-tabs color="light-blue" v-model="category.activeIndex" :list="category.list" align="left" @change="fnOnCategoryChange"></tm-tabs> <tm-tabs color="light-blue" v-model="category.activeIndex" range-key="displayName" :list="category.list"
align="left" @change="fnOnCategoryChange"></tm-tabs>
</view> </view>
<!-- 占位区域 --> <!-- 占位区域 -->
<view style="width: 100vw;height: 90rpx;"></view> <view style="width: 100vw;height: 90rpx;"></view>
@@ -24,50 +25,16 @@
<template v-slot:left="{ hdata }"> <template v-slot:left="{ hdata }">
<tm-translate animation-name="fadeUp"> <tm-translate animation-name="fadeUp">
<view class="card round-3 overflow white"> <view class="card round-3 overflow white">
<tm-images :previmage="false" :src="hdata.item.image" @click="fnPreview(hdata.item)"></tm-images> <tm-images :previmage="false" :src="hdata.item.spec.cover"
<view class="pa-10 text-size-s"> @click="fnPreview(hdata.item)"></tm-images>
<view class="text-overflow-2">
<tm-tags color="bg-gradient-amber-accent" :shadow="0" :dense="true" size="s" model="fill">{{ hdata.item.team }}</tm-tags>
<text class="pl-6">{{ hdata.item.name }}</text>
</view>
<view v-if="hdata.item.description" class="ma-10">{{ hdata.item.description }}</view>
<view v-if="hdata.item.location" class="mt-10 text-grey-lighten-1">
<tm-icons name="icon-position-fill"></tm-icons>
<text class="pl-5">{{ hdata.item.location }}</text>
</view>
<view class="flex-between mt-12 flex-center">
<view>
<text class="text-size-xs text-red ml-5">{{ hdata.item.likes }}</text>
<text class="text-size-xs text-red ml-5">喜欢</text>
</view>
<view class="pl-10 text-size-xs text-grey-lighten-1">{{ hdata.item.takeTime }}</view>
</view>
</view>
</view> </view>
</tm-translate> </tm-translate>
</template> </template>
<template v-slot:right="{ hdata }"> <template v-slot:right="{ hdata }">
<tm-translate animation-name="fadeUp"> <tm-translate animation-name="fadeUp">
<view class="card round-3 overflow white"> <view class="card round-3 overflow white">
<tm-images :previmage="false" :src="hdata.item.image" @click="fnPreview(hdata.item)"></tm-images> <tm-images :previmage="false" :src="hdata.item.spec.cover"
<view class="pa-10 text-size-s"> @click="fnPreview(hdata.item)"></tm-images>
<view class="text-overflow-2">
<tm-tags :shadow="0" :dense="true" color="bg-gradient-amber-accent" size="s" model="fill">{{ hdata.item.team }}</tm-tags>
<text class="pl-6">{{ hdata.item.name }}</text>
</view>
<view v-if="hdata.item.description" class="ma-10">{{ hdata.item.description }}</view>
<view v-if="hdata.item.location" class="mt-10 text-grey-lighten-1">
<tm-icons name="icon-position-fill"></tm-icons>
<text class="pl-5">{{ hdata.item.location }}</text>
</view>
<view class="flex-between mt-12 flex-center">
<view>
<text class="text-size-xs text-red ml-5">{{ hdata.item.likes }}</text>
<text class="text-size-xs text-red ml-5">喜欢</text>
</view>
<view class="pl-10 text-size-xs text-grey-lighten-1">{{ hdata.item.takeTime }}</view>
</view>
</view>
</view> </view>
</tm-translate> </tm-translate>
</template> </template>
@@ -76,25 +43,8 @@
<block v-for="(item, index) in dataList" :key="index"> <block v-for="(item, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="calcAniWait(index)"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<view class="round-3 shadow-2 overflow white mb-24"> <view class="round-3 shadow-2 overflow white mb-24">
<tm-images :previmage="false" :src="item.image" @click="fnPreview(item)"></tm-images> <tm-images :previmage="false" :src="item.spec.cover"
<view class="pa-24 text-size-m"> @click="fnPreview(item)"></tm-images>
<view class="text-overflow-2">
<tm-tags :shadow="0" :dense="true" color="bg-gradient-amber-accent" size="s" model="fill">{{ item.team }}</tm-tags>
<text class="pl-6">{{ item.name }}</text>
</view>
<view v-if="item.description" class="ma-10">{{ item.description }}</view>
<view v-if="item.location" class="mt-10 text-grey-lighten-1">
<tm-icons name="icon-position-fill"></tm-icons>
<text class="pl-5">{{ item.location }}</text>
</view>
<view class="flex-between mt-12 flex-center">
<view>
<text class="text-size-m text-red ml-5">{{ item.likes }}</text>
<text class="text-size-m text-red ml-5">喜欢</text>
</view>
<view class="pl-10 text-size-m text-grey-lighten-1">{{ item.takeTime }}</view>
</view>
</view>
</view> </view>
</tm-translate> </tm-translate>
</block> </block>
@@ -140,9 +90,8 @@
}, },
queryParams: { queryParams: {
size: 10, size: 10,
page: 0, page: 1,
team: null, group: ""
keyword: ''
}, },
cache: { cache: {
dataList: [], dataList: [],
@@ -159,28 +108,14 @@
return uni.$tm.dayjs(val).format('DD/MM/YYYY'); return uni.$tm.dayjs(val).format('DD/MM/YYYY');
} }
}, },
watch: {
globalAppSettings: {
deep: true,
handler() {
// this.isLoadMore = false;
// this.queryParams.page = 0;
// this.dataList = [];
// this.cache.list = [];
// this.cache.total = 0;
}
}
},
onLoad() { onLoad() {
this.fnSetPageTitle('个人图库'); this.fnSetPageTitle('个人图库');
this.fnGetCategory(); this.fnGetCategory();
}, },
created() {
this.fnGetData();
},
onPullDownRefresh() { onPullDownRefresh() {
this.dataList = []
this.isLoadMore = false; this.isLoadMore = false;
this.queryParams.page = 0; this.queryParams.page = 1;
this.fnGetData(); this.fnGetData();
}, },
onReachBottom(e) { onReachBottom(e) {
@@ -199,59 +134,58 @@
fnOnCategoryChange(index) { fnOnCategoryChange(index) {
this.fnResetSetAniWaitIndex(); this.fnResetSetAniWaitIndex();
this.dataList = []; this.dataList = [];
if (index == 0) { this.queryParams.group = this.category.list[index].name;
this.queryParams.team = null; this.queryParams.page = 1;
} else {
this.queryParams.team = this.category.list[index];
}
this.queryParams.page = 0;
this.fnToTopPage(); this.fnToTopPage();
this.fnGetData(); this.fnGetData();
}, },
fnGetCategory() { fnGetCategory() {
this.$httpApi.getPhotoTeams().then(res => { this.$httpApi.v2.getPhotoGroupList({
this.category.list = ['全部', ...res.data]; page: 1,
size: 9999
}).then(res => {
this.category.list = res.items.map(item => {
return {
name: item.metadata.name,
displayName: item.spec.displayName
}
});
if (this.category.list.length !== 0) {
this.queryParams.group = this.category.list[0].name;
this.fnGetData();
}
}); });
}, },
fnGetData() { fnGetData() {
// uni.showLoading({
// mask: true,
// title: '加载中...'
// });
// 设置状态为加载中 // 设置状态为加载中
if (!this.isLoadMore) { if (!this.isLoadMore) {
this.loading = 'loading'; this.loading = 'loading';
} }
this.loadMoreText = ''; this.loadMoreText = '';
this.$httpApi this.$httpApi.v2
.getPhotoListByPage(this.queryParams) .getPhotoListByGroupName(this.queryParams)
.then(res => { .then(res => {
if (res.status == 200) { console.log("相册 res", res)
this.loading = 'success'; this.result = res;
this.result = res.data; this.loading = 'success';
if (res.data.content.length != 0) { if (res.items.length != 0) {
const _list = res.data.content.map((item, index) => { const _list = res.items.map((item, index) => {
item['image'] = this.$utils.checkImageUrl(item.thumbnail); item.spec.cover = this.$utils.checkImageUrl(item.spec.cover);
item['model'] = 'text'; return item;
item['takeTime'] = this.$tm.dayjs(item['takeTime']).format('DD/MM/YYYY'); });
return item; this.fnCacheDataList(_list);
if (this.globalAppSettings.gallery.useWaterfull) {
this.dataList = _list;
this.$nextTick(() => {
this.$refs.wafll.pushData(_list);
}); });
this.fnCacheDataList(_list); } else {
if (this.globalAppSettings.gallery.useWaterfull) { this.dataList = this.dataList.concat(_list);
this.dataList = _list;
this.$nextTick(() => {
this.$refs.wafll.pushData(_list);
});
} else {
this.dataList = this.dataList.concat(_list);
}
} }
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
} else {
this.loading = 'error';
this.waterfall.loading = 'finish';
this.loadMoreText = '';
} }
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
}) })
.catch(err => { .catch(err => {
console.error(err); console.error(err);
@@ -268,7 +202,7 @@
}, },
// 缓存数据 // 缓存数据
fnCacheDataList(dataList) { fnCacheDataList(dataList) {
if (this.queryParams.page == 0) { if (this.queryParams.page == 1) {
this.cache.dataList = dataList; this.cache.dataList = dataList;
} else { } else {
this.cache.dataList = [...this.cache.dataList, ...dataList]; this.cache.dataList = [...this.cache.dataList, ...dataList];
@@ -281,10 +215,10 @@
}, },
// 预览 // 预览
fnPreview(item) { fnPreview(item) {
const index = this.cache.dataList.findIndex(x => x.id == item.id); const index = this.cache.dataList.findIndex(x => x.spec.cover == x.spec.cover);
uni.previewImage({ uni.previewImage({
current: index, current: index,
urls: this.cache.dataList.map(x => x.image), urls: this.cache.dataList.map(x => x.spec.cover),
indicator: 'number', indicator: 'number',
loop: true loop: true
}); });
+55 -54
查看文件
@@ -1,7 +1,8 @@
<template> <template>
<view class="app-page"> <view class="app-page">
<tm-menubars iconColor="white" color="white" :flat="true" :showback="false"> <tm-menubars iconColor="white" color="white" :flat="true" :showback="false">
<image slot="left" class="logo ml-24 round-24" :src="bloggerInfo.avatar" mode="scaleToFill" @click="$tm.toast('以后会放一个彩蛋~')"></image> <image slot="left" class="logo ml-24 round-24" :src="bloggerInfo.avatar" mode="scaleToFill"
@click="$tm.toast('以后会放一个彩蛋~')"></image>
<view class="search-input round-12 pt-12 pb-12 flex pl-24" @click="fnToSearch"> <view class="search-input round-12 pt-12 pb-12 flex pl-24" @click="fnToSearch">
<text class="search-input_icon iconfont text-size-m icon-search text-grey"></text> <text class="search-input_icon iconfont text-size-m icon-search text-grey"></text>
<view class="search-input_text pl-12 text-size-m text-grey">搜索文章...</view> <view class="search-input_text pl-12 text-size-m text-grey">搜索文章...</view>
@@ -22,15 +23,10 @@
<view class="bg-white pb-24"> <view 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="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> <e-swiper :dotPosition="globalAppSettings.banner.dotPosition" :autoplay="true"
</view> :useDot="globalAppSettings.banner.useDot" :list="bannerList"
<!-- 快捷导航 --> @on-click="fnOnBannerClick"></e-swiper>
<!-- <view v-if="useQuickNav" class="quick-nav flex-between round-3 flex mt-12 ml-12 mr-12 pa-24"> </view>
<view class="quick-nav-item flex flex-col flex-center" v-for="(nav, index) in quickNavList" :key="index" @click="fnToNavPage(nav)">
<tm-icons :size="120" :name="nav.icon"></tm-icons>
<view class="name text-size-s mt-4">{{ nav.text }}</view>
</view>
</view> -->
</view> </view>
<!-- 精品分类 --> <!-- 精品分类 -->
<view class="flex flex-between mt-16 mb-24 pl-24 pr-24"> <view class="flex flex-between mt-16 mb-24 pl-24 pr-24">
@@ -44,9 +40,11 @@
</view> </view>
</view> </view>
<scroll-view class="category" scroll-x="true"> <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> <view v-if="categoryList.length == 0" class="cate-empty round-3 mr-5 flex flex-center text-grey">
还没有任何文章分类~</view>
<block v-else> <block v-else>
<view class="content" v-for="(category, index) in categoryList" :key="category.createTime" @click="fnToCategoryBy(category)"> <view class="content" v-for="(category, index) in categoryList" :key="category.metadata.name"
@click="fnToCategoryBy(category)">
<category-mini-card :category="category"></category-mini-card> <category-mini-card :category="category"></category-mini-card>
</view> </view>
</block> </block>
@@ -54,7 +52,7 @@
<!-- 最新文章 --> <!-- 最新文章 -->
<view 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="page-item_title text-weight-b">文章列表</view>
<view class="show-more flex flex-center bg-white round-3" @click="fnToArticlesPage"> <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> <text class="iconfont icon-angle-right text-size-s text-grey-darken-1"></text>
</view> </view>
@@ -63,14 +61,16 @@
<text class="iconfont icon-angle-right text-size-s "></text> <text class="iconfont icon-angle-right text-size-s "></text>
</view> </view>
</view> </view>
<view v-if="articleList.length == 0" class="article-empty"><tm-empty icon="icon-shiliangzhinengduixiang-" label="博主还没有发表任何文章~"></tm-empty></view> <view v-if="articleList.length == 0" class="article-empty"><tm-empty icon="icon-shiliangzhinengduixiang-"
label="博主还没有发表任何文章~"></tm-empty></view>
<block v-else> <block v-else>
<view :class="globalAppSettings.layout.home"> <view :class="globalAppSettings.layout.home">
<block v-for="(article, index) in articleList" :key="article.createTime"> <block v-for="(article, index) in articleList" :key="article.spec.slug">
<tm-translate class="ani-item" animation-name="fadeUp" :wait="calcAniWait(index)"> <tm-translate class="ani-item" animation-name="fadeUp" :wait="calcAniWait(index)">
<article-card from="home" :article="article" @on-click="fnToArticleDetail"></article-card> <article-card from="home" :article="article" @on-click="fnToArticleDetail"></article-card>
<!-- 广告区域 --> <!-- 广告区域 -->
<view v-if="haloAdConfig.home.use && (index + 1) % haloAdConfig.frequency == 0" class="ad-wrap ma-24"> <view v-if="haloAdConfig.home.use && (index + 1) % haloAdConfig.frequency == 0"
class="ad-wrap ma-24">
<!-- #ifdef MP-WEIXIN --> <!-- #ifdef MP-WEIXIN -->
<ad v-if="haloAdConfig.unitId" :unit-id="haloAdConfig.unitId"></ad> <ad v-if="haloAdConfig.unitId" :unit-id="haloAdConfig.unitId"></ad>
<!-- #endif --> <!-- #endif -->
@@ -82,7 +82,8 @@
</block> </block>
</view> </view>
<view class="load-text mt-12">{{ loadMoreText }}</view> <view class="load-text mt-12">{{ loadMoreText }}</view>
<tm-flotbutton v-if="articleList.length > 10" color="light-blue" @click="fnToTopPage" size="m" icon="icon-angle-up"></tm-flotbutton> <tm-flotbutton v-if="articleList.length > 10" color="light-blue" @click="fnToTopPage" size="m"
icon="icon-angle-up"></tm-flotbutton>
</block> </block>
</block> </block>
<!-- <tm-flotbutton @click="fnChangeMode" size="m" color="light-blue" :icon="$tm.vx.state().tmVuetify.black ? 'icon-lightbulb' : 'icon-lightbulb-fill'"></tm-flotbutton> --> <!-- <tm-flotbutton @click="fnChangeMode" size="m" color="light-blue" :icon="$tm.vx.state().tmVuetify.black ? 'icon-lightbulb' : 'icon-lightbulb-fill'"></tm-flotbutton> -->
@@ -113,8 +114,8 @@
return { return {
loading: 'loading', loading: 'loading',
queryParams: { queryParams: {
size: 10, size: 5,
page: 0 page: 1
}, },
result: {}, result: {},
isLoadMore: false, isLoadMore: false,
@@ -124,8 +125,7 @@
noticeList: [], noticeList: [],
articleList: [], articleList: [],
categoryList: [], categoryList: [],
useQuickNav: false,
quickNavList: []
}; };
}, },
@@ -138,8 +138,7 @@
}, },
onLoad() { onLoad() {
this.fnSetPageTitle(); this.fnSetPageTitle();
this.useQuickNav = this.$haloConfig.quickNav.use;
}, },
created() { created() {
@@ -147,7 +146,7 @@
}, },
onPullDownRefresh() { onPullDownRefresh() {
this.isLoadMore = false; this.isLoadMore = false;
this.queryParams.page = 0; this.queryParams.page = 1;
this.fnQuery(); this.fnQuery();
}, },
@@ -167,22 +166,15 @@
fnQuery() { fnQuery() {
this.fnGetBanner(); this.fnGetBanner();
this.fnGetArticleList(); this.fnGetArticleList();
this.fnGetCategoryList(); this.fnGetCategoryList();
this.fnGetQuickNavList();
},
fnGetQuickNavList() {
this.useQuickNav = this.$haloConfig.quickNav.use;
if (!this.$haloConfig.quickNav.use) return;
const _quickNavList = this.$haloConfig.quickNav.list;
this.quickNavList = _quickNavList.map(item => {
return item;
});
}, },
fnGetCategoryList() { fnGetCategoryList() {
this.$httpApi this.$httpApi.v2
.getCategoryList({ more: true }) .getCategoryList({})
.then(res => { .then(res => {
this.categoryList = res.data.sort((a, b) => { console.log('查询分类成功:', res);
this.categoryList = res.items.sort((a, b) => {
return b.postCount - a.postCount; return b.postCount - a.postCount;
}); });
@@ -205,6 +197,7 @@
fnGetBanner() { fnGetBanner() {
const _this = this; const _this = this;
const _format = function(list, type) { const _format = function(list, type) {
console.log("list", list)
return list.map((item, index) => { return list.map((item, index) => {
switch (type) { switch (type) {
case 'list': case 'list':
@@ -219,14 +212,14 @@
case 'article': case 'article':
return { return {
mp4: '', mp4: '',
id: item.id, id: item.metadata.name,
nickname: _this.bloggerInfo.nickname, nickname: item.owner.displayName,
avatar: _this.bloggerInfo.avatar, avatar: _this.$utils.checkImageUrl(item.owner.avatar),
address: '', address: '',
createTime: uni.$tm.dayjs(item.createTime).fromNow(), createTime: uni.$tm.dayjs(item.spec.publishTime).fromNow(),
title: item.title, title: item.spec.title,
src: _this.$utils.checkImageUrl(item.thumbnail), src: _this.$utils.checkImageUrl(item.spec.cover),
image: _this.$utils.checkImageUrl(item.thumbnail) image: _this.$utils.checkImageUrl(item.spec.cover)
}; };
case 'banner': case 'banner':
return { return {
@@ -241,8 +234,11 @@
this.bannerList = _format(this.$haloConfig.banner.list, 'list'); this.bannerList = _format(this.$haloConfig.banner.list, 'list');
break; break;
case 'article': // 来自热门文章的封面 case 'article': // 来自热门文章的封面
this.$httpApi.getPostList({ page: 0, size: 6, sort: 'topPriority,visits,desc' }).then(res => { this.$httpApi.getPostList({
this.bannerList = _format(res.data.content, 'article'); page: 0,
size: 6
}).then(res => {
this.bannerList = _format(res.items, 'article');
if (this.bannerList.length == 0) { if (this.bannerList.length == 0) {
this.bannerList = _format(this.$haloConfig.banner.list, 'list'); this.bannerList = _format(this.$haloConfig.banner.list, 'list');
} }
@@ -258,7 +254,11 @@
}, },
fnOnBannerClick(item) { fnOnBannerClick(item) {
if (item.id == '') return; if (item.id == '') return;
this.fnToArticleDetail(item); this.fnToArticleDetail({
metadata: {
name: item.id
}
});
}, },
// 文章列表 // 文章列表
fnGetArticleList() { fnGetArticleList() {
@@ -271,16 +271,17 @@
this.loading = 'loading'; this.loading = 'loading';
} }
this.loadMoreText = '加载中...'; this.loadMoreText = '加载中...';
this.$httpApi this.$httpApi.v2
.getPostList(this.queryParams) .getPostList(this.queryParams)
.then(res => { .then(res => {
console.log('加载成功', res);
this.loading = 'success'; this.loading = 'success';
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
this.result = res.data; this.result = res;
if (this.isLoadMore) { if (this.isLoadMore) {
this.articleList = this.articleList.concat(res.data.content); this.articleList = this.articleList.concat(res.items);
} else { } else {
this.articleList = res.data.content; this.articleList = res.items;
} }
this.loading = 'success'; this.loading = 'success';
}) })
@@ -298,7 +299,7 @@
//跳转文章详情 //跳转文章详情
fnToArticleDetail(article) { fnToArticleDetail(article) {
uni.navigateTo({ uni.navigateTo({
url: '/pagesA/article-detail/article-detail?articleId=' + article.id, url: '/pagesA/article-detail/article-detail?name=' + article.metadata.name,
animationType: 'slide-in-right' animationType: 'slide-in-right'
}); });
}, },
@@ -333,7 +334,7 @@
// 根据slug查询分类下的文章 // 根据slug查询分类下的文章
fnToCategoryBy(category) { fnToCategoryBy(category) {
uni.navigateTo({ uni.navigateTo({
url: `/pagesA/category-detail/category-detail?slug=${category.slug}&name=${category.name}` url: `/pagesA/category-detail/category-detail?name=${category.metadata.name}&title=${category.spec.displayName}`
}); });
}, },
+237
查看文件
@@ -0,0 +1,237 @@
<template>
<view class="app-page">
<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">
<!-- 空布局 -->
<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无数据"></tm-empty>
</view>
<block v-else>
<block v-for="(moment, index) in dataList" :key="index">
<!-- 卡片 -->
<tm-translate animation-name="fadeUp" :wait="calcAniWait()">
<view class="moment-card">
<view class="head" style="display: flex;align-items: center;">
<view class="avatar" style="flex-shrink: 0;">
<image style="width: 66rpx;height: 66rpx;border-radius: 50%;"
:src="moment.spec.user.avatar" />
</view>
<view class="nickname" style="margin-left: 12rpx;">
<view style="font-size: 30rpx;font-weight: bold;color: #333333;">
{{moment.spec.user.displayName}}
</view>
<view style="margin-top: 6rpx;font-size: 24rpx;color: #666;">
{{ { d: moment.spec.releaseTime, f: 'yyyy年MM月dd日 星期w' } | formatTime }}
</view>
</view>
</view>
<view class="content">
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain"
:loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true"
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
:content="moment.spec.content.html" :markdown="true" :showLineNumber="true"
:showLanguageName="true" :copyByLongPress="true" />
</view>
<view v-if="moment.spec.content.medium.length!==0" class="images"
:class="['images-'+moment.spec.content.medium.length]">
<view class="image-item" v-for="(image,index) in moment.spec.content.medium"
:key="index">
<image mode="aspectFill" style="width: 100%;height: 100%;border-radius: 6rpx;"
:src="image.url" @click="handlePreview(index,moment.spec.content.medium)" />
</view>
</view>
</view>
</tm-translate>
</block>
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton>
<view class="load-text">{{ loadMoreText }}</view>
</block>
</view>
</view>
</template>
<script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import MarkdownConfig from '@/common/markdown/markdown.config.js';
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
export default {
components: {
tmSkeleton,
tmFlotbutton,
tmTranslate,
tmEmpty,
mpHtml
},
data() {
return {
markdownConfig: MarkdownConfig,
loading: 'loading',
queryParams: {
size: 10,
page: 1
},
result: null,
dataList: [],
isLoadMore: false,
loadMoreText: '加载中...'
};
},
computed: {
bloggerInfo() {
return this.$tm.vx.getters().getBlogger;
},
},
onLoad() {
this.fnGetData();
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi.v2
.getMomentList(this.queryParams)
.then(res => {
console.log('请求结果:');
console.log(res);
this.loading = 'success';
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
// 处理数据
this.result = res;
const tempItems = res.items.map(item => {
item.spec.user = {
displayName: this.bloggerInfo.nickname,
avatar: this.$utils.checkAvatarUrl(this.bloggerInfo.avatar)
}
item.spec.content.medium
.filter(x => x.type === 'PHOTO')
.map(medium => {
medium.url = this.$utils.checkThumbnailUrl(medium.url, true)
})
return item;
})
if (this.isLoadMore) {
this.dataList = this.dataList.concat(tempItems);
} else {
this.dataList = tempItems;
}
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
},
handlePreview(index, list) {
uni.previewImage({
current: index,
urls: list.map(item => item.url)
})
}
}
};
</script>
<style lang="scss" scoped>
.app-page {
width: 100vw;
display: flex;
flex-direction: column;
padding: 24rpx 0;
}
.loading-wrap {
padding: 24rpx;
}
.moment-card {
display: flex;
flex-direction: column;
box-sizing: border-box;
margin: 0 24rpx;
border-radius: 12rpx;
background-color: #ffff;
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
overflow: hidden;
margin-bottom: 24rpx;
}
.head {
padding: 24rpx;
padding-bottom: 0;
}
.images {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
padding: 24rpx;
padding-top: 0;
.image-item {
box-sizing: border-box;
border-radius: 24rpx;
padding: 6rpx;
width: 33%;
height: 200rpx
}
&-1 {
>.image-item {
width: 100%;
height: 350rpx
}
}
&-2 {
>.image-item {
width: 50%;
height: 250rpx
}
}
}
</style>
+148 -118
查看文件
@@ -8,33 +8,33 @@
<block v-else> <block v-else>
<!-- 顶部信息 --> <!-- 顶部信息 -->
<view class="head ma-24"> <view class="head ma-24">
<view class="title">{{ result.title }}</view> <view class="title">{{ result.spec.title }}</view>
<view class="detail"> <view class="detail">
<view class="author"> <view class="author">
<text class="author-name">博主{{ author.nickname }}</text> <text class="author-name">作者{{ result.owner.displayName }}</text>
<text class="author-time"> <text class="author-time">
时间{{ { d: result.createTime, f: 'yyyy年MM月dd日 星期w' } | formatTime }} 时间{{ { d: result.spec.publishTime, f: 'yyyy年MM月dd日 星期w' } | formatTime }}
</text> </text>
</view> </view>
<view class="cover" v-if="result.thumbnail"> <view class="cover" v-if="result.spec.cover">
<image class="cover-img" mode="aspectFill" :src="calcUrl(result.thumbnail)"></image> <image class="cover-img" mode="aspectFill" :src="calcUrl(result.spec.cover)"></image>
</view> </view>
<view class="count" :class="{ 'no-thumbnail': !result.thumbnail }"> <view class="count" :class="{ 'no-thumbnail': !result.spec.cover }">
<view class="count-item"> <view class="count-item">
<text class="value">{{ result.visits }}</text> <text class="value">{{ result.stats.visit }}</text>
<text class="label">阅读</text> <text class="label">阅读</text>
</view> </view>
<view class="count-item"> <view class="count-item">
<text class="value">{{ result.likes }}</text> <text class="value">{{ result.stats.upvote }}</text>
<text class="label">喜欢</text> <text class="label">喜欢</text>
</view> </view>
<view class="count-item"> <view class="count-item">
<text class="value">{{ result.commentCount }}</text> <text class="value">{{ result.stats.comment }}</text>
<text class="label">评论</text> <text class="label">评论</text>
</view> </view>
<view class="count-item"> <view class="count-item">
<text class="value">{{ result.wordCount }}</text> <text class="value">{{ result.content.raw.length }}</text>
<text class="label">字数</text> <text class="label">字数</text>
</view> </view>
</view> </view>
@@ -46,8 +46,9 @@
<text class="text-weight-b">分类</text> <text class="text-weight-b">分类</text>
<text v-if="result.categories.length == 0" class="category-tag is-empty">未选择分类</text> <text v-if="result.categories.length == 0" class="category-tag is-empty">未选择分类</text>
<block v-else> <block v-else>
<text class="category-tag" v-for="(item, index) in result.categories" :key="index" @click="fnToCate(item)"> <text class="category-tag" v-for="(item, index) in result.categories" :key="index"
{{ item.name }} @click="fnToCate(item)">
{{ item.spec.displayName }}
</text> </text>
</block> </block>
</view> </view>
@@ -55,21 +56,25 @@
<text class="text-weight-b">标签</text> <text class="text-weight-b">标签</text>
<text v-if="result.tags.length == 0" class="category-tag is-empty">未选择标签</text> <text v-if="result.tags.length == 0" class="category-tag is-empty">未选择标签</text>
<block v-else> <block v-else>
<text class="category-tag" :style="{ backgroundColor: item.color }" v-for="(item, index) in result.tags" :key="index" @click="fnToTag(item)"> <text class="category-tag" :style="{ backgroundColor: item.color }"
{{ item.name }} v-for="(item, index) in result.tags" :key="index" @click="fnToTag(item)">
{{ item.spec.displayName }}
</text> </text>
</block> </block>
</view> </view>
<view v-if="originalURL" class="mt-18 category-type original-url"> <view v-if="originalURL" class="mt-18 category-type original-url">
<view class="original-url_left text-weight-b">原文</view> <view class="original-url_left text-weight-b">原文</view>
<view class="original-url_right text-grey"> <view class="original-url_right text-grey">
<text class="original-url_right__link" @click.stop="fnToOriginal(originalURL)">{{ originalURL }}</text> <text class="original-url_right__link"
<text class="original-url_right__btn" @click.stop="fnToOriginal(originalURL)">阅读原文<text class="iconfont icon-angle-right ml-5 text-size-s"></text> </text> @click.stop="fnToOriginal(originalURL)">{{ originalURL }}</text>
<text class="original-url_right__btn" @click.stop="fnToOriginal(originalURL)">阅读原文<text
class="iconfont icon-angle-right ml-5 text-size-s"></text> </text>
</view> </view>
</view> </view>
</view> </view>
<!-- 广告区域 --> <!-- 广告区域 -->
<view v-if="haloAdConfig.articleDetail.use && (haloAdConfig.unitId || haloAdConfig.adpid)" class="ad-wrap ma-24 mb-0"> <view v-if="haloAdConfig.articleDetail.use && (haloAdConfig.unitId || haloAdConfig.adpid)"
class="ad-wrap ma-24 mb-0">
<!-- #ifdef MP-WEIXIN --> <!-- #ifdef MP-WEIXIN -->
<ad v-if="haloAdConfig.unitId" :unit-id="haloAdConfig.unitId"></ad> <ad v-if="haloAdConfig.unitId" :unit-id="haloAdConfig.unitId"></ad>
<!-- #endif --> <!-- #endif -->
@@ -81,8 +86,13 @@
<view class="content ml-24 mr-24"> <view class="content ml-24 mr-24">
<!-- markdown渲染 --> <!-- markdown渲染 -->
<view class="markdown-wrap"> <view class="markdown-wrap">
<tm-more :disabled="true" :maxHeight="1500" :isRemovBar="true" :open="showValidVisitMore" @click="fnOnShowValidVisitMore"> <tm-more :disabled="true" :maxHeight="1500" :isRemovBar="true" :open="showValidVisitMore"
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain" :loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true" :tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle" :content="result.content || result.formatContent" :markdown="true" :showLineNumber="true" :showLanguageName="true" :copyByLongPress="true" /> @click="fnOnShowValidVisitMore">
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain"
:loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true"
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
:content="result.content.raw" :markdown="true" :showLineNumber="true"
:showLanguageName="true" :copyByLongPress="true" />
<template v-slot:more="{ data }"> <template v-slot:more="{ data }">
<view class=""> <view class="">
<text class="text-blue text-size-m text-weight-b">文章部分内容已加密点击解锁</text> <text class="text-blue text-size-m text-weight-b">文章部分内容已加密点击解锁</text>
@@ -92,7 +102,8 @@
</tm-more> </tm-more>
</view> </view>
<!-- 广告区域微信/decloud申请 --> <!-- 广告区域微信/decloud申请 -->
<view v-if="haloAdConfig.articleDetail.use && (haloAdConfig.unitId || haloAdConfig.adpid)" class="ad-wrap mt-24 mb-24 "> <view v-if="haloAdConfig.articleDetail.use && (haloAdConfig.unitId || haloAdConfig.adpid)"
class="ad-wrap mt-24 mb-24 ">
<!-- #ifdef MP-WEIXIN --> <!-- #ifdef MP-WEIXIN -->
<ad v-if="haloAdConfig.unitId" :unit-id="haloAdConfig.unitId"></ad> <ad v-if="haloAdConfig.unitId" :unit-id="haloAdConfig.unitId"></ad>
<!-- #endif --> <!-- #endif -->
@@ -104,11 +115,13 @@
<!-- 广告区域自定义广告位 --> <!-- 广告区域自定义广告位 -->
<view class="ad-card mt-24" v-if="haloAdConfig.articleDetail.custom.use"> <view class="ad-card mt-24" v-if="haloAdConfig.articleDetail.custom.use">
<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> <image class="ad-card_cover" :src="haloAdConfig.articleDetail.custom.cover" mode="scaleToFill">
</image>
<view class="ad-card_info"> <view class="ad-card_info">
<view class="ad-card_info-title">{{ haloAdConfig.articleDetail.custom.title }}</view> <view class="ad-card_info-title">{{ haloAdConfig.articleDetail.custom.title }}</view>
<view class="ad-card_info-desc">{{ haloAdConfig.articleDetail.custom.content }}</view> <view class="ad-card_info-desc">{{ haloAdConfig.articleDetail.custom.content }}</view>
<view v-if="haloAdConfig.articleDetail.custom.url" class="ad-card_info-link" @click="fnToWebview(haloAdConfig.articleDetail.custom)"> <view v-if="haloAdConfig.articleDetail.custom.url" class="ad-card_info-link"
@click="fnToWebview(haloAdConfig.articleDetail.custom)">
立即查看 立即查看
</view> </view>
</view> </view>
@@ -117,7 +130,8 @@
<!-- 版权声明 --> <!-- 版权声明 -->
<view v-if="copyright.use" class="copyright-wrap bg-white mt-24 pa-24 round-4"> <view v-if="copyright.use" class="copyright-wrap bg-white mt-24 pa-24 round-4">
<view class="copyright-title text-weight-b">版权声明</view> <view class="copyright-title text-weight-b">版权声明</view>
<view class="copyright-content mt-12 grey-lighten-5 text-grey-darken-2 round-4 pt-12 pb-12 pl-24 pr-24 "> <view
class="copyright-content mt-12 grey-lighten-5 text-grey-darken-2 round-4 pt-12 pb-12 pl-24 pr-24 ">
<view v-if="copyright.author" class="copyright-text text-size-s "> <view v-if="copyright.author" class="copyright-text text-size-s ">
版权归属{{ copyright.author }} 版权归属{{ copyright.author }}
</view> </view>
@@ -131,24 +145,29 @@
</view> </view>
<!-- 评论展示区域 --> <!-- 评论展示区域 -->
<view class="comment-wrap bg-white mt-24 pa-24 round-4"> <view v-if="result" class="comment-wrap bg-white mt-24 pa-24 round-4">
<commentList :disallowComment="result.disallowComment" :postId="result.id" :post="result" @on-comment-detail="fnOnShowCommentDetail" @on-loaded="fnOnCommentLoaded"></commentList> <commentList :disallowComment="!result.spec.allowComment" :postName="result.metadata.name"
:post="result" @on-comment-detail="fnOnShowCommentDetail" @on-loaded="fnOnCommentLoaded">
</commentList>
</view> </view>
</view> </view>
<!-- 弹幕效果 --> <!-- 弹幕效果 -->
<barrage ref="barrage" :maxTop="240" :type="globalAppSettings.barrage.type"></barrage> <barrage ref="barrage" :maxTop="240" :type="globalAppSettings.barrage.type"></barrage>
<!-- 返回顶部 --> <!-- 返回顶部 -->
<tm-flotbutton :offset="[16, 80]" icon="icon-angle-up" color="bg-gradient-light-blue-accent" @click="fnToTopPage()"></tm-flotbutton> <tm-flotbutton :offset="[16, 80]" icon="icon-angle-up" color="bg-gradient-light-blue-accent"
<tm-flotbutton :actions="btnOption.actions" actions-pos="left" :show-text="true" color="bg-gradient-orange-accent" @change="fnOnFlotButtonChange"></tm-flotbutton> @click="fnToTopPage()"></tm-flotbutton>
<tm-flotbutton :actions="btnOption.actions" actions-pos="left" :show-text="true"
color="bg-gradient-orange-accent" @change="fnOnFlotButtonChange"></tm-flotbutton>
</block> </block>
<!-- 评论详情 --> <!-- 评论详情 -->
<tm-poup v-model="commentDetail.show" height="auto" :round="6" :over-close="true" position="bottom"> <tm-poup v-model="commentDetail.show" height="auto" :round="6" :over-close="true" position="bottom">
<view class="pa-24"> <view v-if="result" class="pa-24">
<view class="poup-head pb-24"> <view class="poup-head pb-24">
<view class="poup-title text-align-center text-size-g text-weight-b mb-32">评论详情</view> <view class="poup-title text-align-center text-size-g text-weight-b mb-32">评论详情</view>
<comment-item :useContentBg="false" :useActions="false" :isChild="false" :comment="commentDetail.comment" :postId="result.id"></comment-item> <comment-item :useContentBg="false" :useActions="false" :isChild="false"
:comment="commentDetail.comment" :postName="result.metadata.name"></comment-item>
</view> </view>
<scroll-view :scroll-y="true" class="poup-body"> <scroll-view :scroll-y="true" class="poup-body">
@@ -159,7 +178,7 @@
</view> </view>
<view v-else-if="commentDetail.loading == 'error'" class="error"> <view v-else-if="commentDetail.loading == 'error'" class="error">
<tm-empty icon="icon-wind-cry" label="加载失败"> <tm-empty icon="icon-wind-cry" label="加载失败">
<tm-button theme="bg-gradient-light-blue-accent" size="m" v-if="!disallowComment" @click="fnGetChildComments()"> <tm-button theme="bg-gradient-light-blue-accent" size="m" @click="fnGetChildComments()">
刷新试试 刷新试试
</tm-button> </tm-button>
</tm-empty> </tm-empty>
@@ -171,7 +190,9 @@
</view> </view>
<block v-else> <block v-else>
<comment-item v-for="(comment, index) in commentDetail.list" :useContentBg="false" :useSolid="false" :useActions="false" :key="index" :isChild="false" :comment="comment" :postId="result.id"></comment-item> <comment-item v-for="(comment, index) in commentDetail.list" :useContentBg="false"
:useSolid="false" :useActions="false" :key="index" :isChild="false" :comment="comment"
:postName="result.metadata.name"></comment-item>
</block> </block>
</block> </block>
</scroll-view> </scroll-view>
@@ -203,7 +224,10 @@
</tm-poup> </tm-poup>
<!-- 密码访问解密弹窗 --> <!-- 密码访问解密弹窗 -->
<tm-dialog :disabled="true" :input-val.sync="validVisitModal.value" title="验证提示" confirmText="立即验证" :showCancel="validVisitModal.useCancel" model="confirm" v-model="validVisitModal.show" content="博主设置了需要密码才能查看该文章内容,请输入文章密码进行验证" theme="split" confirmColor="blue shadow-blue-0" @cancel="fnOnValidVisitCancel" @confirm="fnOnValidVisitConfirm"></tm-dialog> <tm-dialog :disabled="true" :input-val.sync="validVisitModal.value" title="验证提示" confirmText="立即验证"
:showCancel="validVisitModal.useCancel" model="confirm" v-model="validVisitModal.show"
content="博主设置了需要密码才能查看该文章内容,请输入文章密码进行验证" theme="split" confirmColor="blue shadow-blue-0"
@cancel="fnOnValidVisitCancel" @confirm="fnOnValidVisitConfirm"></tm-dialog>
</view> </view>
</template> </template>
@@ -226,7 +250,9 @@
import rCanvas from '@/components/r-canvas/r-canvas.vue'; import rCanvas from '@/components/r-canvas/r-canvas.vue';
import barrage from '@/components/barrage/barrage.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 { export default {
components: { components: {
tmSkeleton, tmSkeleton,
@@ -248,10 +274,11 @@
loading: 'loading', loading: 'loading',
markdownConfig: MarkdownConfig, markdownConfig: MarkdownConfig,
btnOption: { btnOption: {
actions: [{ actions: [
icon: 'icon-like', // {
color: 'bg-gradient-orange-accent' // icon: 'icon-like',
}, // color: 'bg-gradient-orange-accent'
// },
{ {
icon: 'icon-commentdots-fill', icon: 'icon-commentdots-fill',
color: 'bg-gradient-green-accent' color: 'bg-gradient-green-accent'
@@ -263,15 +290,15 @@
] ]
}, },
queryParams: { queryParams: {
articleId: null name: null
}, },
result: {}, result: null,
commentDetail: { commentDetail: {
loading: 'loading', loading: 'loading',
show: false, show: false,
comment: {}, comment: {},
postId: undefined, postName: undefined,
list: [] list: []
}, },
poster: { poster: {
@@ -354,7 +381,7 @@
}, },
onLoad(e) { onLoad(e) {
this.fnSetPageTitle('文章加载中...'); this.fnSetPageTitle('文章加载中...');
this.queryParams.articleId = e.articleId; this.queryParams.name = e.name;
this.fnGetData(); this.fnGetData();
}, },
@@ -364,31 +391,27 @@
methods: { methods: {
fnGetData() { fnGetData() {
this.loading = 'loading'; this.loading = 'loading';
// uni.showLoading({ this.$httpApi.v2
// mask: true, .getPostByName(this.queryParams.name)
// title: '加载中...'
// });
this.$httpApi
.getArticleDetail(this.queryParams.articleId)
.then(res => { .then(res => {
if (res.status == 200) { console.log('详情', res);
this.result = res.data;
this.metas = res.data.metas; this.result = res;
this.fnSetPageTitle('文章详情'); this.metas = [];
this.loading = 'success'; this.fnSetPageTitle('文章详情');
this.fnSetWxShareConfig({ this.loading = 'success';
title: this.result.title, this.fnSetWxShareConfig({
desc: this.result.summary, title: this.result.spec.title,
imageUrl: this.$utils.checkThumbnailUrl(this.result.thumbnail), desc: this.result.content.raw,
path: `/pagesA/article-detail/article-detail?articleId=${this.queryParams.articleId}`, imageUrl: this.$utils.checkThumbnailUrl(this.result.spec.cover),
copyLink: this.$haloConfig.apiUrl, path: `/pagesA/article-detail/article-detail?name=${this.result.metadata.name}`,
query: {} copyLink: this.$baseApiUrl,
}); query: {}
} else { });
this.loading = 'error';
}
}) })
.catch(err => { .catch(err => {
console.log("错误", err)
this.loading = 'error'; this.loading = 'error';
}) })
.finally(() => { .finally(() => {
@@ -400,28 +423,28 @@
// 浮动按钮点击 // 浮动按钮点击
fnOnFlotButtonChange(index) { fnOnFlotButtonChange(index) {
switch (index) { switch (index) {
// case 0:
// this.fnDoLikes();
// break;
case 0: case 0:
this.fnDoLikes();
break;
case 1:
this.fnToComment(); this.fnToComment();
break; break;
case 2: case 1:
this.fnShowShare(); this.fnShowShare();
break; break;
} }
}, },
fnToComment() { fnToComment() {
if (this.result.disallowComment) { if (!this.result.spec.allowComment) {
return uni.$tm.toast('文章已开启禁止评论!'); return uni.$tm.toast('文章已开启禁止评论!');
} }
this.$Router.push({ this.$Router.push({
path: '/pagesA/comment/comment', path: '/pagesA/comment/comment',
query: { query: {
id: this.result.id, isComment: true,
parentId: 0, postName: this.result.metadata.name,
title: this.result.title, title: this.result.spec.title,
from: 'posts', from: 'posts',
formPage: 'comment_list', formPage: 'comment_list',
type: 'post' type: 'post'
@@ -474,7 +497,7 @@
this.$nextTick(async () => { this.$nextTick(async () => {
const systemInfo = await uni.getSystemInfoSync(); const systemInfo = await uni.getSystemInfoSync();
const _bloggerAvatar = this.$utils.checkAvatarUrl(this.bloggerInfo.avatar, true); const _bloggerAvatar = this.$utils.checkAvatarUrl(this.bloggerInfo.avatar, true);
const _articleCover = this.$utils.checkThumbnailUrl(this.result.thumbnail, true); const _articleCover = this.$utils.checkThumbnailUrl(this.result.spec.cover, true);
// 初始化 // 初始化
await this.$refs.rCanvas.init({ await this.$refs.rCanvas.init({
canvas_id: 'rCanvas', canvas_id: 'rCanvas',
@@ -566,7 +589,7 @@
// 文章标题 // 文章标题
await this.$refs.rCanvas await this.$refs.rCanvas
.drawText({ .drawText({
text: this.result.title, text: this.result.spec.title,
max_width: 312, max_width: 312,
line_clamp: 1, line_clamp: 1,
x: 12, x: 12,
@@ -583,7 +606,7 @@
}); });
await this.$refs.rCanvas await this.$refs.rCanvas
.drawText({ .drawText({
text: this.result.summary, text: this.result.content.raw,
max_width: 312, max_width: 312,
line_clamp: 2, line_clamp: 2,
x: 12, x: 12,
@@ -674,9 +697,9 @@
provider: 'weixin', provider: 'weixin',
scene: 'WXSceneSession', scene: 'WXSceneSession',
type: 0, type: 0,
href: this.$haloConfig.apiUrl, href: this.$baseApiUrl,
title: this.result.title, title: this.result.spec.title,
summary: this.result.summary, summary: this.result.content.raw,
imageUrl: this.poster.res.tempFilePath, imageUrl: this.poster.res.tempFilePath,
success: function(res) { success: function(res) {
console.log('success:' + JSON.stringify(res)); console.log('success:' + JSON.stringify(res));
@@ -688,41 +711,45 @@
// #endif // #endif
}, },
fnOnShowCommentDetail(data) { fnOnShowCommentDetail(data) {
const { postId, comment } = data; const {
postName,
comment
} = data;
this.commentDetail.comment = comment; this.commentDetail.comment = comment;
this.commentDetail.postId = postId; this.commentDetail.postName = postName;
this.commentDetail.list = []; this.commentDetail.list = [];
this.commentDetail.show = true; this.commentDetail.show = true;
this.fnGetChildComments(); this.fnGetChildComments();
}, },
fnGetChildComments() { fnGetChildComments() {
this.commentDetail.loading = 'loading'; this.commentDetail.loading = 'loading';
this.$httpApi this.$httpApi.v2
.getPostChildrenCommentList(this.commentDetail.postId, this.commentDetail.comment.id, {}) .getPostCommentReplyList(this.commentDetail.postName, {
page: 1,
size: 100
})
.then(res => { .then(res => {
if (res.status == 200) { console.log('getPostChildrenCommentList res', res);
this.commentDetail.loading = 'success'; this.commentDetail.loading = 'success';
this.commentDetail.list = res.data; this.commentDetail.list = res.items;
} else {
this.commentDetail.loading = 'error';
}
console.log('getPostChildrenCommentList', res);
}) })
.catch(err => { .catch(err => {
console.log('getPostChildrenCommentList err', error);
this.commentDetail.loading = 'error'; this.commentDetail.loading = 'error';
}); });
}, },
fnToCate(category) { fnToCate(category) {
uni.navigateTo({ uni.navigateTo({
url: `/pagesA/category-detail/category-detail?slug=${category.slug}&name=${category.name}` url: `/pagesA/category-detail/category-detail?name=${category.metadata.name}&title=${category.spec.displayName}`
}); });
}, },
fnToTag(tag) { fnToTag(tag) {
uni.navigateTo({ uni.navigateTo({
url: `/pagesA/tag-detail/tag-detail?id=${tag.id}&slug=${tag.slug}&name=${tag.name}` url: `/pagesA/tag-detail/tag-detail?name=${tag.metadata.name}&title=${tag.spec.displayName}`
}); });
}, },
async fnOnCommentLoaded(data) { async fnOnCommentLoaded(data) {
console.log("data", data)
const _list = []; const _list = [];
const _handleData = list => { const _handleData = list => {
return new Promise(resolve => { return new Promise(resolve => {
@@ -731,8 +758,8 @@
} else { } else {
list.forEach(item => { list.forEach(item => {
_list.push(item); _list.push(item);
if (item.children && item.children.length != 0) { if (item.replies && item.replies.length != 0) {
_handleData(item.children); _handleData(item.replies.items);
} }
resolve(); resolve();
}); });
@@ -740,31 +767,31 @@
}); });
}; };
await _handleData(data); await _handleData(data);
if (this.globalAppSettings.barrage.use) { // if (this.globalAppSettings.barrage.use) {
this.$nextTick(() => { // this.$nextTick(() => {
if (_list.length != 0) { // if (_list.length != 0) {
_handleAddBarrage(); // _handleAddBarrage();
} // }
}); // });
} // }
const _handleRemove = () => { // const _handleRemove = () => {
this.$refs['barrage'] && this.$refs['barrage'].remove({ // this.$refs['barrage'] && this.$refs['barrage'].remove({
duration: 5000, // 延迟关闭的时间 // duration: 5000, // 延迟关闭的时间
speed: 600 // 弹幕消失的速度 // speed: 600 // 弹幕消失的速度
}); // });
}; // };
let index = 0; // let index = 0;
const _handleAddBarrage = () => { // const _handleAddBarrage = () => {
setTimeout(() => { // setTimeout(() => {
this.$refs['barrage'] && this.$refs['barrage'].add(_list[index]); // this.$refs['barrage'] && this.$refs['barrage'].add(_list[index]);
index += 1; // index += 1;
if (index < _list.length - 1) { // if (index < _list.length - 1) {
_handleAddBarrage(); // _handleAddBarrage();
} else { // } else {
_handleRemove(); // _handleRemove();
} // }
}, 1000); // }, 1000);
}; // };
}, },
fnToWebview(data) { fnToWebview(data) {
uni.navigateTo({ uni.navigateTo({
@@ -776,7 +803,10 @@
}); });
}, },
fnToOriginal(originalURL) { fnToOriginal(originalURL) {
this.fnToWebview({ title: this.result.title, url: originalURL }); this.fnToWebview({
title: this.result.title,
url: originalURL
});
}, },
// 查看密码验证确认 // 查看密码验证确认
fnOnValidVisitConfirm() { fnOnValidVisitConfirm() {
+56 -49
查看文件
@@ -2,11 +2,13 @@
<view class="app-page" :class="{ 'is-balck grey-darken-6': isBlackTheme }"> <view class="app-page" :class="{ 'is-balck grey-darken-6': isBlackTheme }">
<!-- 顶部切换 --> <!-- 顶部切换 -->
<view class="e-fixed shadow-2"> <view class="e-fixed shadow-2">
<tm-search v-model="queryParams.keyword" :round="24" :shadow="0" color="light-blue" insert-color="light-blue" :clear="true" @confirm="fnOnSearch"></tm-search> <tm-search v-model="queryParams.keyword" :round="24" :shadow="0" color="light-blue"
<tm-tabs color="light-blue" :shadow="0" v-model="tab.activeIndex" :list="tab.list" align="center" @change="fnOnTabChange"></tm-tabs> insert-color="light-blue" :clear="true" @input="fnOnSearch" @confirm="fnOnSearch"></tm-search>
<tm-tabs v-if="false" color="light-blue" :shadow="0" v-model="tab.activeIndex" :list="tab.list"
align="center" @change="fnOnTabChange"></tm-tabs>
</view> </view>
<!-- 占位区域 --> <!-- 占位区域 -->
<view style="width: 100vw;height: 184rpx;"></view> <view style="width: 100vw;height: 100rpx;"></view>
<!-- 加载区域 --> <!-- 加载区域 -->
<view v-if="loading != 'success'" class="loading-wrap pa-24"> <view v-if="loading != 'success'" class="loading-wrap pa-24">
<tm-skeleton model="listAvatr"></tm-skeleton> <tm-skeleton model="listAvatr"></tm-skeleton>
@@ -18,24 +20,23 @@
<view v-else class="content"> <view v-else class="content">
<view v-if="dataList.length == 0" class="content-empty flex flex-center"> <view v-if="dataList.length == 0" class="content-empty flex flex-center">
<!-- 空布局 --> <!-- 空布局 -->
<tm-empty icon="icon-shiliangzhinengduixiang-" label="该分类下暂无数据"></tm-empty> <tm-empty v-if="!queryParams.keyword" icon="icon-shiliangzhinengduixiang-" label="请输入关键词搜索"></tm-empty>
<tm-empty v-else icon="icon-shiliangzhinengduixiang-"
:label="`未搜到 ${queryParams.keyword} 相关文章`"></tm-empty>
</view> </view>
<block v-else> <block v-else>
<block v-for="(article, index) in dataList" :key="article.id"> <!-- 文章卡片 -->
<!-- 文章卡片 --> <tm-translate v-for="(article, index) in dataList" :key="article.name" animation-name="fadeUp"
<tm-translate animation-name="fadeUp" :wait="calcAniWait(index)"> :wait="calcAniWait(index)">
<article-card :article="article" @on-click="fnToArticleDetail"></article-card> <view class="article-card" @click="fnToArticleDetail(article)">
<!-- 广告区域 --> <text style="font-size: 32rpx;font-weight: bold;color: #333;" v-html="article.title">{{article.title}}</text>
<view v-if="haloAdConfig.articles.use && (index + 1) % haloAdConfig.frequency == 0" class="ad-wrap ma-24"> <text style="font-size: 28rpx;margin-top: 16rpx;color: #555;" v-html="article.content">{{article.content}}
<!-- #ifdef MP-WEIXIN --> </text>
<ad v-if="haloAdConfig.unitId" :unit-id="haloAdConfig.unitId"></ad> <text style="font-size: 24rpx;margin-top: 24rpx;color:#888">
<!-- #endif --> 发布日期{{ { d: article.publishTimestamp, f: 'yyyy年MM月dd日' } | formatTime }}
<!-- #ifndef MP-WEIXIN --> </text>
<ad v-if="haloAdConfig.adpid" :adpid="haloAdConfig.adpid"></ad> </view>
<!-- #endif --> </tm-translate>
</view>
</tm-translate>
</block>
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton> <tm-flotbutton @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton>
<view class="load-text">{{ loadMoreText }}</view> <view class="load-text">{{ loadMoreText }}</view>
@@ -70,10 +71,10 @@
list: ['全部', '最新文章', '热门文章', '最近更新', '最多点赞'] list: ['全部', '最新文章', '热门文章', '最近更新', '最多点赞']
}, },
queryParams: { queryParams: {
size: 10, keyword: "",
page: 0, limit: 5,
sort: 'topPriority,createTime,desc', highlightPreTag: "<text>",
keyword: '' highlightPostTag: "</text>"
}, },
cache: { cache: {
dataList: [], dataList: [],
@@ -88,27 +89,19 @@
onLoad() { onLoad() {
this.fnSetPageTitle('文章列表'); this.fnSetPageTitle('文章列表');
}, },
created() { created() {
this.fnGetData(); if (!this.queryParams.keyword) {
this.loading = 'success'
} else {
this.fnGetData();
}
}, },
onPullDownRefresh() { onPullDownRefresh() {
this.fnResetSetAniWaitIndex();
this.isLoadMore = false; this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData(); this.fnGetData();
}, },
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: { methods: {
fnOnTabChange(index) { fnOnTabChange(index) {
this.fnResetSetAniWaitIndex(); this.fnResetSetAniWaitIndex();
@@ -121,16 +114,18 @@
4: 'topPriority,likes,desc' 4: 'topPriority,likes,desc'
}; };
this.queryParams.sort = _sorts[index]; this.queryParams.sort = _sorts[index];
this.queryParams.page = 0;
this.dataList = []; this.dataList = [];
this.fnToTopPage(); this.fnToTopPage();
this.fnGetData(); this.fnGetData();
}, },
fnOnSearch() { fnOnSearch() {
this.fnResetSetAniWaitIndex(); this.fnResetSetAniWaitIndex();
this.queryParams.page = 0;
this.isLoadMore = false; this.isLoadMore = false;
this.fnGetData(); if (!this.queryParams.keyword) {
this.dataList = []
} else {
this.fnGetData();
}
}, },
fnGetData() { fnGetData() {
// uni.showLoading({ // uni.showLoading({
@@ -142,20 +137,19 @@
this.loading = 'loading'; this.loading = 'loading';
} }
this.loadMoreText = '加载中...'; this.loadMoreText = '加载中...';
this.$httpApi this.$httpApi.v2
.getPostList(this.queryParams) .getPostListByKeyword(this.queryParams)
.then(res => { .then(res => {
console.log('请求结果:'); console.log('请求结果:');
console.log(res); console.log(res);
this.loading = 'success'; this.loading = 'success';
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
// 处理数据 this.result = res;
this.result = res.data;
if (this.isLoadMore) { if (this.isLoadMore) {
this.dataList = this.dataList.concat(res.data.content); this.dataList = this.dataList.concat(res.hits);
} else { } else {
this.dataList = res.data.content; this.dataList = res.hits;
} }
}) })
.catch(err => { .catch(err => {
@@ -174,7 +168,7 @@
//跳转文章详情 //跳转文章详情
fnToArticleDetail(article) { fnToArticleDetail(article) {
uni.navigateTo({ uni.navigateTo({
url: '/pagesA/article-detail/article-detail?articleId=' + article.id, url: '/pagesA/article-detail/article-detail?name=' + article.name,
animationType: 'slide-in-right' animationType: 'slide-in-right'
}); });
} }
@@ -203,4 +197,17 @@
height: 60vh; height: 60vh;
} }
} }
.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;
}
</style> </style>
+11 -10
查看文件
@@ -42,7 +42,7 @@
size: 10, size: 10,
page: 0 page: 0
}, },
slug: '', name: '',
pageTitle: '加载中...', pageTitle: '加载中...',
result: null, result: null,
dataList: [], dataList: [],
@@ -52,8 +52,8 @@
}, },
onLoad(e) { onLoad(e) {
this.slug = e.slug; this.name = e.name;
this.pageTitle = e.name; this.pageTitle = e.title;
this.fnGetData(); this.fnGetData();
}, },
onPullDownRefresh() { onPullDownRefresh() {
@@ -85,16 +85,17 @@
} }
this.loadMoreText = '加载中...'; this.loadMoreText = '加载中...';
this.$httpApi this.$httpApi
.getCategoryPostList(this.slug, this.queryParams) .getCategoryPostList(this.name, this.queryParams)
.then(res => { .then(res => {
this.fnSetPageTitle(`分类:${this.pageTitle} (共${res.data.total}篇)`); console.log("请求成功:",res)
this.result = res.data; this.fnSetPageTitle(`${this.pageTitle} (共${res.total}篇)`);
this.result = res;
if (this.isLoadMore) { if (this.isLoadMore) {
this.dataList = this.dataList.concat(res.data.content); this.dataList = this.dataList.concat(res.items);
} else { } else {
this.dataList = res.data.content; this.dataList = res.items;
} }
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
setTimeout(() => { setTimeout(() => {
this.loading = 'success'; this.loading = 'success';
}, 500); }, 500);
@@ -114,7 +115,7 @@
//跳转文章详情 //跳转文章详情
fnToArticleDetail(article) { fnToArticleDetail(article) {
uni.navigateTo({ uni.navigateTo({
url: '/pagesA/article-detail/article-detail?articleId=' + article.id, url: '/pagesA/article-detail/article-detail?name=' + article.metadata.name,
animationType: 'slide-in-right' animationType: 'slide-in-right'
}); });
} }
+97 -53
查看文件
@@ -3,15 +3,19 @@
<view class="content pt-24 pb-24 round-4"> <view class="content pt-24 pb-24 round-4">
<!-- 表单区域 --> <!-- 表单区域 -->
<tm-form @submit="fnOnSubmit"> <tm-form @submit="fnOnSubmit">
<tm-input :auto-focus="true" name="content" :vertical="true" required :height="220" input-type="textarea" bg-color="grey-lighten-5" :maxlength="200" :borderBottom="false" placeholder="请输入内容,不超过200字符..." v-model="form.content"></tm-input> <tm-input :auto-focus="true" name="content" :vertical="true" required :height="220"
<tm-input name="author" align="right" required title="我的昵称" placeholder="请输入您的昵称..." v-model="form.author"></tm-input> input-type="textarea" bg-color="grey-lighten-5" :maxlength="200" :borderBottom="false"
<tm-input name="email" align="right" title="邮箱地址" placeholder="请输入您的邮箱..." v-model="form.email"></tm-input> placeholder="请输入内容,不超过200字符..." v-model="form.content"></tm-input>
<tm-input name="authorUrl" align="right" title="我的网站" placeholder="请输入您的网址..." v-model="form.authorUrl"></tm-input> <tm-input name="author" align="right" required title="我的昵称" placeholder="请输入您的昵称..."
<view class="mx-32 my-24 border-b-1 pb-24 flex-between"> v-model="form.author"></tm-input>
<text class="text-size-n ">接收提醒</text> <tm-input name="avatar" align="right" required title="我的头像" placeholder="请输入您的头像..."
<view><tm-switch :text="['是', '否']" v-model="form.allowNotification" color="bg-gradient-blue-accent"></tm-switch></view> v-model="form.avatar"></tm-input>
</view> <tm-input name="email" align="right" required title="邮箱地址" placeholder="请输入您的邮箱..."
<view class="pa-24 pl-30 pr-30"><tm-button navtie-type="form" theme="bg-gradient-blue-accent" block>提交</tm-button></view> v-model="form.email"></tm-input>
<tm-input name="authorUrl" align="right" required title="我的网站" placeholder="请输入您的网址..."
v-model="form.authorUrl"></tm-input>
<view class="pa-24 pl-30 pr-30"><tm-button navtie-type="form" theme="bg-gradient-blue-accent"
block>提交</tm-button></view>
</tm-form> </tm-form>
</view> </view>
</view> </view>
@@ -32,9 +36,9 @@
}, },
data() { data() {
return { return {
isComment: true,
params: { params: {
postId: '', postName: '',
parentId: '',
title: '', // 被回复的标题 type=user =用户名 否则为文章标题 title: '', // 被回复的标题 type=user =用户名 否则为文章标题
form: '', form: '',
formPage: '', // 来自哪个页面 formPage: '', // 来自哪个页面
@@ -46,40 +50,39 @@
avatar: '', avatar: '',
authorUrl: '', // 作者主页 authorUrl: '', // 作者主页
content: '', // 评论内容 content: '', // 评论内容
email: '', // 邮件 email: '', // 邮件
parentId: 0, postName: ""
postId: 0
} }
}; };
}, },
computed: {
// 评论游客信息
wxLoginVisitorUser() {
return uni.$tm.vx.getters().getWxLoginInfo;
}
},
onLoad() { onLoad() {
this.params = this.$Route.query; this.params = this.$Route.query;
this.form.postId = this.params.id; this.isComment = this.params.isComment;
if (this.params.type == 'user') { this.form.postName = this.params.postName;
this.form.parentId = this.params.parentId;
if (!this.isComment) {
this.fnSetPageTitle('回复用户:' + this.params.title); this.fnSetPageTitle('回复用户:' + this.params.title);
} else { } else {
this.form.parentId = 0;
this.fnSetPageTitle(this.params.title); this.fnSetPageTitle(this.params.title);
} }
this.form.author = this.wxLoginVisitorUser.nickName;
this.form.avatar = this.wxLoginVisitorUser.avatarUrl; try {
this.form.email = this.wxLoginVisitorUser.email; let visitor = uni.getStorageSync('Visitor')
this.form.authorUrl = this.wxLoginVisitorUser.url; if (visitor) {
visitor = JSON.parse(visitor)
this.form.author = visitor.author;
this.form.avatar = visitor.avatar;
this.form.email = visitor.email;
this.form.authorUrl = visitor.authorUrl;
}
} catch (e) {}
}, },
methods: { methods: {
fnOnSubmit(e) { fnOnSubmit(e) {
console.log('提交评论');
if (e === false) { if (e === false) {
return uni.$tm.toast('请检查所有的必填项是否填写完整!'); return uni.$tm.toast('请检查所有的必填项是否填写完整!');
} }
if (this.form.allowNotification && !this.form.email) { if (!this.form.email) {
return uni.$tm.toast('未填写邮箱地址,将无法接收提醒!'); return uni.$tm.toast('未填写邮箱地址,将无法接收提醒!');
} }
if (this.form.email && !uni.$tm.test.email(this.form.email)) { if (this.form.email && !uni.$tm.test.email(this.form.email)) {
@@ -90,36 +93,77 @@
} }
this.fnHandle(); this.fnHandle();
}, },
handleSetVisitor() {
uni.setStorageSync('Visitor', JSON.stringify({
author: this.form.author,
avatar: this.form.avatar,
email: this.form.email,
authorUrl: this.form.authorUrl,
}))
},
fnHandle() { fnHandle() {
uni.showLoading({ uni.showLoading({
title: '正在提交...' title: '正在提交...'
}); });
const _api = {
sheets: this.$httpApi.postSheetsComments, // 评论
posts: this.$httpApi.postCommentPost if (this.isComment) {
}; const commentForm = {
_api[this.params.from](this.form) allowNotification: true,
.then(res => { raw: this.form.content,
if (res.status == 200) { content: this.form.content,
uni.$tm.toast('提交成功,待博主审核通过后即可展示!'); owner: {
// 更新评论者信息 avatar: this.form.avatarUrl,
uni.$tm.vx.commit('user/setWxLoginInfo', { displayName: this.form.author,
avatarUrl: this.wxLoginVisitorUser.avatarUrl, email: this.form.email,
nickName: this.form.author, website: this.form.authorUrl,
email: this.form.email, },
url: this.form.authorUrl subjectRef: {
}); group: "content.halo.run",
// 清空评论内容 kind: "Post",
this.form.content = ''; name: this.form.postName,
// 触发刷新评论(可能需要评论审核不会有改变) version: "v1alpha1",
// uni.$emit(this.params.formPage + '_refresh');
} else {
uni.$tm.toast('操作失败,请重试!');
} }
}
this.$httpApi.v2.addPostComment(commentForm)
.then(res => {
uni.$tm.toast('日志:提交成功!');
// 更新评论者信息
this.handleSetVisitor();
setTimeout(() => {
uni.navigateBack()
}, 1500)
})
.catch(err => {
uni.$tm.toast("提示:评论失败");
});
return;
}
// 回复
const replyForm = {
allowNotification: true,
raw: this.form.content,
content: this.form.content,
owner: {
avatar: this.form.avatarUrl,
displayName: this.form.author,
email: this.form.email,
website: this.form.authorUrl,
},
quoteReply: this.form.postName
}
this.$httpApi.v2.addPostCommentReply(this.form.postName, replyForm)
.then(res => {
uni.$tm.toast('提示:提交成功!');
// 更新评论者信息
this.handleSetVisitor();
setTimeout(() => {
uni.navigateBack()
}, 1500)
}) })
.catch(err => { .catch(err => {
uni.$tm.toast(err.message); uni.$tm.toast("提示:回复失败");
}); });
} }
} }
+129 -79
查看文件
@@ -7,45 +7,55 @@
<tm-skeleton model="listAvatr"></tm-skeleton> <tm-skeleton model="listAvatr"></tm-skeleton>
<tm-skeleton model="listAvatr"></tm-skeleton> <tm-skeleton model="listAvatr"></tm-skeleton>
</view> </view>
<view v-else class="content" :class="{ 'bg-white': result.length !== 0 }"> <view v-else class="content" :class="{ 'bg-white': dataList.length !== 0 }">
<!-- 空数据 --> <!-- 空数据 -->
<view v-if="result.length == 0" class="content-empty flex flex-center"> <view v-if="dataList.length == 0" class="content-empty flex flex-center">
<tm-empty icon="icon-shiliangzhinengduixiang-" label="啊偶,博主还没有朋友呢~"></tm-empty> <tm-empty icon="icon-shiliangzhinengduixiang-" label="啊偶,博主还没有朋友呢~"></tm-empty>
</view> </view>
<!-- 如果只有一个分组使用列表的形式 result.length == 1 --> <!-- 如果只有一个分组使用列表的形式 dataList.length == 1 -->
<view v-else-if="result.length == 1" class="flex flex-col pb-24"> <view v-else class="flex flex-col pb-24">
<block v-for="(link, index) in result[0].children" :key="index"> <block v-for="(link, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="calcAniWait(index)"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<!-- 色彩版本 --> <!-- 色彩版本 -->
<view v-if="!globalAppSettings.links.useSimple" class="info flex pt-24 pb-24 pl-12 pr-12" :class="{ 'border-b-1': index != result[0].children.length - 1 }" @click="fnOnLinkEvent(link)"> <view v-if="!globalAppSettings.links.useSimple" class="info flex pt-24 pb-24 pl-12 pr-12"
:class="{ 'border-b-1': index != dataList.length - 1 }" @click="fnCopyLink(link)">
<view class="link-logo"> <view class="link-logo">
<cache-image class="link-logo_img" radius="12rpx" :url="link.logo" :fileMd5="link.logo" mode="aspectFill"></cache-image> <cache-image class="link-logo_img" radius="12rpx" :url="link.spec.logo"
:fileMd5="link.spec.logo" mode="aspectFill"></cache-image>
</view> </view>
<view class="flex flex-col pl-30 info-detail"> <view class="flex flex-col pl-30 info-detail">
<view class="link-card_name text-size-l text-weight-b text-red">{{ link.name }}</view> <view class="link-card_name text-size-l text-weight-b text-red">
<view class="poup-tag ml--10 mt-6"> <tm-tags style="margin-right: 12rpx;margin-left: -2rpx;" color="bg-gradient-light-blue-lighten"
<tm-tags color="bg-gradient-amber-accent" :shadow="0" size="s" model="fill"> :shadow="0" size="s" model="fill">
ID{{ link.id }} {{ link.spec.groupName || '暂未分组' }}
</tm-tags>
{{ link.spec.displayName }}
</view>
<view class="poup-tag mt-6" style="font-size: 28rpx;">
站点地址{{ link.spec.url }}
<!-- <tm-tags color="bg-gradient-amber-accent" :shadow="0" size="s" model="fill">
URL{{ link.spec.url }}
</tm-tags> </tm-tags>
<tm-tags color=" bg-gradient-light-blue-lighten" :shadow="0" size="s" model="fill"> <tm-tags color=" bg-gradient-light-blue-lighten" :shadow="0" size="s" model="fill">
{{ link.team || '暂未分组' }} {{ link.spec.groupName || '暂未分组' }}
</tm-tags> </tm-tags> -->
</view> </view>
<view class="link-card_desc text-overflow text-size-s mt-4"> <view class="link-card_desc text-overflow mt-4" style="font-size: 28rpx;">
博客简介{{ link.description || '这个博主很懒,没写简介~' }} 博客简介{{ link.spec.description || '这个博主很懒,没写简介~' }}
</view> </view>
</view> </view>
</view> </view>
<!-- 简洁版本 --> <!-- 简洁版本 -->
<view v-else class="link-card flex ml-24 mr-24 pt-24 pb-24" @click="fnOnLinkEvent(link)"> <view v-else class="link-card flex ml-24 mr-24 pt-24 pb-24" @click="fnCopyLink(link)">
<image class="logo shadow-6" :src="link.logo" mode="aspectFill"></image> <image class="logo shadow-6" :src="link.spec.logo" mode="aspectFill"></image>
<view class="info pl-24"> <view class="info pl-24">
<view class="name text-size-g">{{ link.name }}</view> <view class="name text-size-g">{{ link.spec.displayName }}</view>
<view class="desc mt-12 text-size-s text-grey-darken-1">{{ link.description }}</view> <view class="desc mt-12 text-size-s text-grey-darken-1">{{ link.spec.description }}
</view>
<view v-if="false" class="link mt-12 text-size-m text-grey-darken-1"> <view v-if="false" class="link mt-12 text-size-m text-grey-darken-1">
<text class="iconfont icon-link mr-6 text-size-s"></text> <text class="iconfont icon-link mr-6 text-size-s"></text>
{{ link.url }} {{ link.spec.url }}
</view> </view>
</view> </view>
</view> </view>
@@ -53,49 +63,52 @@
</block> </block>
</view> </view>
<!-- 如果大于一个分组使用联系人的索引形式 result.length > 1 --> <!-- 如果大于一个分组使用联系人的索引形式 dataList.length > 1 -->
<block v-else> <block v-if="false">
<block v-for="(team, index) in result" :key="index"> <block v-for="(team, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="calcAniWait(index)"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<view class="grey-lighten-4 text text-size-s text-weight-b px-32 py-12">{{ team.title }}</view> <view class="grey-lighten-4 text text-size-s text-weight-b px-32 py-12">{{ team.title }}</view>
<block v-for="(link, linkIndex) in team.children" :key="link.id"> <block v-for="(link, linkIndex) in team.children" :key="link.metadata.name">
<tm-translate animation-name="fadeUp" :wait="calcAniWait(linkIndex)"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(linkIndex)">
<!-- 色彩版本 --> <!-- 色彩版本 -->
<view v-if="!globalAppSettings.links.useSimple" class="info flex pt-24 pb-24 pl-12 pr-12" :class="{ <view v-if="!globalAppSettings.links.useSimple"
class="info flex pt-24 pb-24 pl-12 pr-12" :class="{
'border-b-1': 'border-b-1':
linkIndex != team.children.length - 1 || index == result.length - 1 linkIndex != team.children.length - 1 || index == dataList.length - 1
}" @click="fnOnLinkEvent(link)"> }" @click="fnCopyLink(link)">
<view class="link-logo"> <view class="link-logo">
<cache-image class="link-logo_img" radius="12rpx" :url="link.logo" :fileMd5="link.logo" mode="aspectFill"></cache-image> <cache-image class="link-logo_img" radius="12rpx" :url="link.spec.logo"
:fileMd5="link.spec.logo" mode="aspectFill"></cache-image>
</view> </view>
<view class="flex flex-col pl-30 info-detail"> <view class="flex flex-col pl-30 info-detail">
<view class="link-card_name text-size-l text-weight-b text-red"> <view class="link-card_name text-size-l text-weight-b text-red">
{{ link.name }} {{ link.spec.displayName }}
</view> </view>
<view class="poup-tag ml--10 mt-6"> <view class="poup-tag ml--10 mt-6">
<tm-tags color="bg-gradient-amber-accent" :shadow="0" size="s" model="fill"> <tm-tags color="bg-gradient-amber-accent" :shadow="0" size="s" model="fill">
ID{{ link.id }} ID{{ link.metadata.name }}
</tm-tags> </tm-tags>
<tm-tags color=" bg-gradient-light-blue-lighten" :shadow="0" size="s" model="fill"> <tm-tags color=" bg-gradient-light-blue-lighten" :shadow="0" size="s"
{{ link.team || '暂未分组' }} model="fill">
{{ link.spec.groupName || '暂未分组' }}
</tm-tags> </tm-tags>
</view> </view>
<view class="link-card_desc text-overflow text-size-s mt-4"> <view class="link-card_desc text-overflow text-size-s mt-4">
博客简介{{ link.description || '这个博主很懒,没写简介~' }} 博客简介{{ link.spec.description || '这个博主很懒,没写简介~' }}
</view> </view>
</view> </view>
</view> </view>
<!-- 简洁版本 --> <!-- 简洁版本 -->
<view v-else class="link-card flex ml-24 mr-24 pt-24 pb-24" @click="fnOnLinkEvent(link)"> <view v-else class="link-card flex ml-24 mr-24 pt-24 pb-24" @click="fnCopyLink(link)">
<image class="logo shadow-6" :src="link.logo" mode="aspectFill"></image> <image class="logo shadow-6" :src="link.spec.logo" mode="aspectFill"></image>
<view class="info pl-24"> <view class="info pl-24">
<view class="name text-size-g">{{ link.name }}</view> <view class="name text-size-g">{{ link.spec.displayName }}</view>
<view class="desc mt-12 text-size-s text-grey-darken-1"> <view class="desc mt-12 text-size-s text-grey-darken-1">
{{ link.description }} {{ link.spec.description }}
</view> </view>
<view v-if="false" class="link mt-12 text-size-m text-grey-darken-1"> <view v-if="false" class="link mt-12 text-size-m text-grey-darken-1">
<text class="iconfont icon-link mr-6 text-size-s"></text> <text class="iconfont icon-link mr-6 text-size-s"></text>
{{ link.url }} {{ link.spec.url }}
</view> </view>
</view> </view>
</view> </view>
@@ -106,7 +119,7 @@
</block> </block>
<!-- 返回顶部 --> <!-- 返回顶部 -->
<tm-flotbutton v-if="linkTotal > 10" color="light-blue" @click="fnToTopPage" size="m" icon="icon-angle-up"></tm-flotbutton> <tm-flotbutton color="light-blue" @click="fnToTopPage" size="m" icon="icon-angle-up"></tm-flotbutton>
<!-- 详情弹窗 --> <!-- 详情弹窗 -->
<tm-poup v-model="detail.show" :width="640" height="auto" position="center" :round="6"> <tm-poup v-model="detail.show" :width="640" height="auto" position="center" :round="6">
@@ -138,10 +151,13 @@
<!-- 博客预览图 --> <!-- 博客预览图 -->
<view class="mt-24"> <view class="mt-24">
<tm-images :width="568" :round="2" :src="caclSiteThumbnail(detail.data.url)" mode="aspectFill"></tm-images> <tm-images :width="568" :round="2" :src="caclSiteThumbnail(detail.data.url)"
mode="aspectFill"></tm-images>
</view> </view>
</view> </view>
</tm-poup> </tm-poup>
<view class="load-text">{{ loadMoreText }}</view>
</view> </view>
</view> </view>
</template> </template>
@@ -155,7 +171,9 @@
import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue'; import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue';
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue'; import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
import { GetRandomNumberByRange } from '@/utils/random.js'; import {
GetRandomNumberByRange
} from '@/utils/random.js';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
@@ -171,15 +189,17 @@
loading: 'loading', loading: 'loading',
queryParams: { queryParams: {
size: 10, size: 10,
page: 0, page: 1
sort: ''
}, },
result: [], result: {},
detail: { detail: {
show: false, show: false,
data: {} data: {}
}, },
linkTotal: 0 isLoadMore: false,
loadMoreText: '',
dataList: [],
cacheDataList: []
}; };
}, },
computed: { computed: {
@@ -195,56 +215,62 @@
}, },
onLoad() { onLoad() {
this.fnSetPageTitle('朋友圈'); this.fnSetPageTitle('朋友圈');
},
created() {
this.fnGetData(); this.fnGetData();
}, },
onPullDownRefresh() { onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 1;
this.dataList = []
this.cacheDataList = []
this.fnGetData(); this.fnGetData();
}, },
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: { methods: {
fnRandomColor() { fnRandomColor() {
const _r = GetRandomNumberByRange(0, this.$haloConfig.colors.length - 1); const _r = GetRandomNumberByRange(0, this.$haloConfig.colors.length - 1);
return this.$haloConfig.colors[_r]; return this.$haloConfig.colors[_r];
}, },
fnGetData() { fnGetData() {
this.linkTotal = 0; if (!this.isLoadMore) {
this.loading = 'loading'; this.loading = 'loading';
// uni.showLoading({ }
// mask: true, this.loadMoreText = '';
// title: '...'
// }); this.$httpApi.v2
this.$httpApi .getFriendLinkList(this.queryParams)
.getLinkListByTeam() .then(res => {
.then(res => { console.log('请求结果:');
if (res.status == 200) { console.log(res);
console.log('请求结果:'); this.result = res;
console.log(res); const list = res.items.map(item => {
// item.spec.logo = this.$utils.checkAvatarUrl(item.spec.logo)
const _result = res.data.map(item => { return item;
const _team = item.team || '未分组'; })
const _links = item.links.map(link => { this.dataList = this.dataList.concat(list);
this.linkTotal += 1;
link.logo = this.$utils.checkAvatarUrl(link.logo); // this.cacheDataList = this.cacheDataList.concat(list);
return link; // this.dataList = this.handleGroup(this.cacheDataList).reverse();
}); setTimeout(() => {
return { this.loading = 'success';
title: _team, this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
children: _links }, 500);
};
});
this.result = _result.reverse();
setTimeout(() => {
this.loading = 'success';
}, 500);
} else {
this.loading = 'error';
}
}) })
.catch(err => { .catch(err => {
console.error(err); console.error(err);
this.loading = 'error'; this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
}) })
.finally(() => { .finally(() => {
setTimeout(() => { setTimeout(() => {
@@ -254,6 +280,30 @@
}); });
}, },
handleGroup(list) {
const group = {}
list.forEach(item => {
if (group[item.spec.groupName]) {
group[item.spec.groupName].children.push(item)
} else {
group[item.spec.groupName] = {
title: item.spec.groupName,
children: [item]
}
}
})
return Object.keys(group).map(key => {
const {
title,
children = []
} = group[key]
return {
title,
children
}
})
},
fnOnLinkEvent(link) { fnOnLinkEvent(link) {
this.detail.data = link; this.detail.data = link;
this.detail.show = true; this.detail.show = true;
-257
查看文件
@@ -1,257 +0,0 @@
<template>
<view class="app-page">
<view v-if="loading != 'success'" class="loading-wrap pa-24">
<tm-skeleton model="listAvatr"></tm-skeleton>
<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 pa-24" :class="{ 'bg-white': dataList.length !== 0 }">
<view v-if="dataList.length == 0" class="content-empty flex flex-center">
<!-- 空布局 -->
<tm-empty icon="icon-shiliangzhinengduixiang-" label="啊偶,博主还没有留言~"></tm-empty>
</view>
<block v-else>
<block v-for="(item, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<!-- 列表项 -->
<comment-item class="mb-12" :isChild="false" :comment="item" :postId="sheetId" :useSolid="false" @on-copy="fnCopyContent" @on-comment="fnToComment" @on-detail="fnOnShowCommentDetail"></comment-item>
</tm-translate>
</block>
<tm-flotbutton :offset="[16, 80]" @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton>
<view class="load-text">{{ loadMoreText }}</view>
</block>
<tm-flotbutton actions-pos="left" :show-text="true" color="bg-gradient-orange-accent" @click="fnToComment(null)"></tm-flotbutton>
</view>
<!-- 评论详情 -->
<tm-poup v-model="commentDetail.show" height="auto" :round="6" :over-close="true" position="bottom">
<view class="pa-24">
<view class="poup-head pb-24">
<view class="poup-title text-align-center text-size-g text-weight-b mb-32">留言详情</view>
<comment-item :useActions="false" :isChild="false" :comment="commentDetail.comment" :postId="sheetId"></comment-item>
</view>
<scroll-view :scroll-y="true" class="poup-body">
<view v-if="commentDetail.loading != 'success'" class="poup-loading-wrap flex flex-center">
<view v-if="commentDetail.loading == 'loading'" class="loading flex flex-center flex-col">
<text class="e-loading-icon iconfont icon-loading text-blue"></text>
<view class="text-size-n text-grey-lighten-1 py-12 mt-12">加载中请稍等...</view>
</view>
<view v-else-if="commentDetail.loading == 'error'" class="error">
<tm-empty icon="icon-wind-cry" label="加载失败">
<tm-button theme="bg-gradient-light-blue-accent" size="m" @click="fnGetChildComments()">刷新试试</tm-button>
</tm-empty>
</view>
</view>
<block v-else>
<view v-if="commentDetail.list.length == 0" class="poup-empty flex flex-center">
<tm-empty icon="icon-shiliangzhinengduixiang-" label="没有更多评论啦~"></tm-empty>
</view>
<block v-else>
<comment-item v-for="(comment, index) in commentDetail.list" :useSolid="false" :useActions="false" :key="index" :isChild="false" :comment="comment" :postId="sheetId"></comment-item>
</block>
</block>
</scroll-view>
</view>
</tm-poup>
</view>
</template>
<script>
import AppKeys from '@/config/keys.js';
import SheetConfig from '@/config/sheets.config.js';
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import commentItem from '@/components/comment-item/comment-item.vue';
export default {
components: {
tmSkeleton,
tmFlotbutton,
tmTranslate,
tmEmpty,
tmPoup,
tmButton,
commentItem
},
data() {
return {
loading: 'loading',
queryParams: {
size: 10,
page: 0
},
result: null,
dataList: [],
isLoadMore: false,
loadMoreText: '加载中...',
sheetId: SheetConfig[AppKeys.SHEET_LEAVING],
commentDetail: {
loading: 'loading',
show: false,
comment: {},
postId: undefined,
list: []
}
};
},
onLoad() {
this.fnSetPageTitle('留言板');
},
created() {
this.fnGetData();
uni.$on('leaving_refresh', () => {
this.fnGetData();
});
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
fnGetData() {
// uni.showLoading({
// mask: true,
// title: '加载中...'
// });
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi
.getSheetsCommentsTreeBySheetId(this.sheetId, this.queryParams)
.then(res => {
if (res.status == 200) {
this.loading = 'success';
// return;
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
// 处理数据
this.result = res.data;
if (this.isLoadMore) {
this.dataList = this.dataList.concat(res.data.content);
} else {
this.dataList = res.data.content;
}
} else {
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
}
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
},
fnToComment(data) {
let _comment = {};
if (data) {
_comment = {
id: this.sheetId,
parentId: data.comment.id,
title: data.comment.author,
from: 'sheets',
formPage: 'leaving',
type: 'user'
};
} else {
_comment = {
id: this.sheetId,
parentId: 0,
title: '留言板留言',
from: 'sheets',
formPage: 'leaving',
type: 'post'
};
}
uni.$tm.vx.commit('comment/setCommentInfo', _comment);
this.$Router.push({
path: '/pagesA/comment/comment',
query: _comment
});
},
fnCopyContent(content) {
uni.$tm.u.setClipboardData(content);
uni.$tm.toast('内容已复制成功!');
},
fnOnShowCommentDetail(comment) {
this.commentDetail.comment = comment;
this.commentDetail.list = [];
this.commentDetail.show = true;
this.fnGetChildComments();
},
fnGetChildComments() {
this.commentDetail.loading = 'loading';
this.$httpApi
.getSheetsChildrenCommentList(this.sheetId, this.commentDetail.comment.id, {})
.then(res => {
if (res.status == 200) {
this.commentDetail.loading = 'success';
this.commentDetail.list = res.data;
} else {
this.commentDetail.loading = 'error';
}
})
.catch(err => {
this.commentDetail.loading = 'error';
});
}
}
};
</script>
<style lang="scss" scoped>
.app-page {
width: 100vw;
display: flex;
flex-direction: column;
background-color: #fafafd;
}
.app-page-content {
box-sizing: border-box;
// box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.05);
}
.content-empty {
width: 100%;
height: 60vh;
}
.loading-wrap {
box-sizing: border-box;
padding: 24rpx;
}
</style>
+270 -259
查看文件
@@ -14,43 +14,16 @@
<text class="text-grey text-size-xs px-10 ml-12">应用以及文章列表布局设置</text> <text class="text-grey text-size-xs px-10 ml-12">应用以及文章列表布局设置</text>
</view> </view>
<view class="sheet-content"> <view class="sheet-content">
<tm-pickers <tm-pickers title="请选择首页布局" btn-color="light-blue" :default-value.sync="homeLayout.selectDefault"
title="请选择首页布局" rang-key="name" :list="homeLayout.list" @confirm="fnOnHomeLayoutConfirm">
btn-color="light-blue" <tm-input name="status" required title="首页文章布局" placeholder="请选择首页文章布局" disabled align="right"
:default-value.sync="homeLayout.selectDefault" :value="homeLayout.selectLabel" right-icon="icon-angle-right"></tm-input>
rang-key="name"
:list="homeLayout.list"
@confirm="fnOnHomeLayoutConfirm"
>
<tm-input
name="status"
required
title="首页文章布局"
placeholder="请选择首页文章布局"
disabled
align="right"
:value="homeLayout.selectLabel"
right-icon="icon-angle-right"
></tm-input>
</tm-pickers> </tm-pickers>
<tm-pickers <tm-pickers title="请选择文章卡片样式" btn-color="light-blue"
title="请选择文章卡片样式" :default-value.sync="articleCardStyle.selectDefault" rang-key="name"
btn-color="light-blue" :list="articleCardStyle.list" @confirm="fnOnArticleCardStyleConfirm">
:default-value.sync="articleCardStyle.selectDefault" <tm-input name="status" required title="文章卡片样式" placeholder="请选择文章卡片样式" disabled align="right"
rang-key="name" :value="articleCardStyle.selectLabel" right-icon="icon-angle-right"></tm-input>
:list="articleCardStyle.list"
@confirm="fnOnArticleCardStyleConfirm"
>
<tm-input
name="status"
required
title="文章卡片样式"
placeholder="请选择文章卡片样式"
disabled
align="right"
:value="articleCardStyle.selectLabel"
right-icon="icon-angle-right"
></tm-input>
</tm-pickers> </tm-pickers>
</view> </view>
</tm-sheet> </tm-sheet>
@@ -73,14 +46,16 @@
</view> </view>
<view class="sheet-content"> <view class="sheet-content">
<view class="mx-32 my-24 border-b-1 pb-24 flex-between"> <view class="mx-32 my-24 border-b-1 pb-24 flex-between">
<text class="text-size-m ">图库瀑布流模式</text> <text class="text-size-m">图库瀑布流模式</text>
<tm-switch v-model="appSettings.gallery.useWaterfull" color="light-blue" :text="['是', '否']"></tm-switch> <tm-switch v-model="appSettings.gallery.useWaterfull" color="light-blue"
:text="['是', '否']"></tm-switch>
</view> </view>
<view class="mx-32 my-24 border-b-1 pb-24 flex-between"> <view class="mx-32 my-24 border-b-1 pb-24 flex-between">
<text class="text-size-m ">友链简洁模式</text> <text class="text-size-m">友链简洁模式</text>
<tm-switch v-model="appSettings.links.useSimple" color="light-blue" :text="['是', '否']"></tm-switch> <tm-switch v-model="appSettings.links.useSimple" color="light-blue"
:text="['是', '否']"></tm-switch>
</view> </view>
<view class="mx-32 mt-24 mb-0 border-b-1 pb-24 flex-between"> <!-- <view class="mx-32 mt-24 mb-0 border-b-1 pb-24 flex-between">
<text class="text-size-m">启用评论弹幕</text> <text class="text-size-m">启用评论弹幕</text>
<tm-switch v-model="appSettings.barrage.use" color="light-blue" :text="['是', '否']"></tm-switch> <tm-switch v-model="appSettings.barrage.use" color="light-blue" :text="['是', '否']"></tm-switch>
</view> </view>
@@ -102,31 +77,27 @@
:value="barrage.selectLabel" :value="barrage.selectLabel"
right-icon="icon-angle-right" right-icon="icon-angle-right"
></tm-input> ></tm-input>
</tm-pickers> </tm-pickers> -->
<view class="mx-32 my-24 border-b-1 pb-24 flex-between"> <view class="mx-32 my-24 border-b-1 pb-24 flex-between">
<text class="text-size-m">是否圆形头像</text> <text class="text-size-m">是否圆形头像</text>
<tm-switch v-model="appSettings.isAvatarRadius" color="light-blue" :text="['是', '否']"></tm-switch> <tm-switch v-model="appSettings.isAvatarRadius" color="light-blue"
:text="['是', '否']"></tm-switch>
</view> </view>
<view class="mx-32 my-24 border-b-1 pb-24 flex-between"> <view class="mx-32 my-24 border-b-1 pb-24 flex-between">
<text class="text-size-m ">轮播图指示器</text> <text class="text-size-m ">轮播图指示器</text>
<tm-switch v-model="appSettings.banner.useDot" color="light-blue" :text="['是', '否']"></tm-switch> <tm-switch v-model="appSettings.banner.useDot" color="light-blue"
:text="['是', '否']"></tm-switch>
</view> </view>
<view v-if="appSettings.banner.useDot" class="mx-32 my-24 border-b-1 pb-24 flex-between"> <view v-if="appSettings.banner.useDot" class="mx-32 my-24 border-b-1 pb-24 flex-between">
<text class="text-size-m ">轮播图指示器位置</text> <text class="text-size-m ">轮播图指示器位置</text>
<tm-groupradio name="dotPosition" @change="fnOnBannerDotChange"> <tm-groupradio name="dotPosition" @change="fnOnBannerDotChange">
<tm-radio <tm-radio :name="item.name" :size="28" color="light-blue"
:name="item.name" v-for="(item, index) in dotPositionList" :key="index" v-model="item.checked"
:size="28" :label="item.name"></tm-radio>
color="light-blue"
v-for="(item, index) in dotPositionList"
:key="index"
v-model="item.checked"
:label="item.name"
></tm-radio>
</tm-groupradio> </tm-groupradio>
</view> </view>
<view class="mx-32 my-24 border-b-1 pb-24 flex-between"> <!-- <view class="mx-32 my-24 border-b-1 pb-24 flex-between">
<text class="text-size-m">显示完整统计</text> <text class="text-size-m">显示完整统计</text>
<tm-switch v-model="appSettings.about.showAllCount" color="light-blue" :text="['是', '否']"></tm-switch> <tm-switch v-model="appSettings.about.showAllCount" color="light-blue" :text="['是', '否']"></tm-switch>
</view> </view>
@@ -134,10 +105,10 @@
<text class="text-size-m ">链接直接打开</text> <text class="text-size-m ">链接直接打开</text>
<tm-switch v-model="appSettings.contact.isLinkCopy" color="light-blue" :text="['是', '否']"></tm-switch> <tm-switch v-model="appSettings.contact.isLinkCopy" color="light-blue" :text="['是', '否']"></tm-switch>
</view> </view>
<view class="mx-32 my-24 border-b-1 pb-24 flex-between"> <view v-if="false" class="mx-32 my-24 border-b-1 pb-24 flex-between">
<text class="text-size-m ">显示后台入口</text> <text class="text-size-m ">显示后台入口</text>
<tm-switch v-model="appSettings.about.showAdmin" color="light-blue" :text="['是', '否']"></tm-switch> <tm-switch v-model="appSettings.about.showAdmin" color="light-blue" :text="['是', '否']"></tm-switch>
</view> </view> -->
</view> </view>
</tm-sheet> </tm-sheet>
</tm-form> </tm-form>
@@ -152,221 +123,261 @@
</template> </template>
<script> <script>
import { _DefaultAppSettings } from '@/utils/app.js'; import {
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue'; _DefaultAppSettings
import tmForm from '@/tm-vuetify/components/tm-form/tm-form.vue'; } from '@/utils/app.js';
import tmPickers from '@/tm-vuetify/components/tm-pickers/tm-pickers.vue'; import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue'; import tmForm from '@/tm-vuetify/components/tm-form/tm-form.vue';
import tmSwitch from '@/tm-vuetify/components/tm-switch/tm-switch.vue'; import tmPickers from '@/tm-vuetify/components/tm-pickers/tm-pickers.vue';
import tmSheet from '@/tm-vuetify/components/tm-sheet/tm-sheet.vue'; import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue';
import tmGroupradio from '@/tm-vuetify/components/tm-groupradio/tm-groupradio.vue'; import tmSwitch from '@/tm-vuetify/components/tm-switch/tm-switch.vue';
import tmRadio from '@/tm-vuetify/components/tm-radio/tm-radio.vue'; import tmSheet from '@/tm-vuetify/components/tm-sheet/tm-sheet.vue';
import tmGroupradio from '@/tm-vuetify/components/tm-groupradio/tm-groupradio.vue';
import tmRadio from '@/tm-vuetify/components/tm-radio/tm-radio.vue';
export default { export default {
components: { components: {
tmButton, tmButton,
tmForm, tmForm,
tmPickers, tmPickers,
tmInput, tmInput,
tmSwitch, tmSwitch,
tmSheet, tmSheet,
tmGroupradio, tmGroupradio,
tmRadio tmRadio
}, },
data() { data() {
return { return {
isBlackTheme: false, isBlackTheme: false,
loading: true, loading: true,
appSettings: {}, appSettings: {},
isSaved: true, isSaved: true,
firstLoad: true, firstLoad: true,
homeLayout: { homeLayout: {
list: [{ name: '一行一列', value: 'h_row_col1' }, { name: '一行两列', value: 'h_row_col2' }], list: [{
selectDefault: ['一行一列'], name: '一行一列',
selectLabel: '一行一列', value: 'h_row_col1'
selectValue: 'h_row_col1' }, {
}, name: '一行两列',
articleCardStyle: { value: 'h_row_col2'
list: [ }],
{ name: '左图右文', value: 'lr_image_text' }, selectDefault: ['一行一列'],
{ name: '左文右图', value: 'lr_text_image' }, selectLabel: '一行一列',
{ name: '上图下文', value: 'tb_image_text' }, selectValue: 'h_row_col1'
{ name: '上文下图', value: 'tb_text_image' }, },
{ name: '只有文字', value: 'only_text' } articleCardStyle: {
], list: [{
selectDefault: ['左图右文'], name: '左图右文',
selectLabel: '左图右文', value: 'lr_image_text'
selectValue: 'lr_image_text' },
}, {
dotPositionList: [{ name: '右边', value: 'right', checked: true }, { name: '下边', value: 'bottom', checked: false }], name: '左文右图',
barrage: { value: 'lr_text_image'
list: [{ name: '顶部', value: 'rightToLeft' }, { name: '左下', value: 'leftBottom' }], },
selectDefault: ['顶部'], {
selectLabel: '顶部', name: '上图下文',
selectValue: 'rightToLeft' value: 'tb_image_text'
} },
}; {
}, name: '上文下图',
value: 'tb_text_image'
},
{
name: '只有文字',
value: 'only_text'
}
],
selectDefault: ['左图右文'],
selectLabel: '左图右文',
selectValue: 'lr_image_text'
},
dotPositionList: [{
name: '右边',
value: 'right',
checked: true
}, {
name: '下边',
value: 'bottom',
checked: false
}],
barrage: {
list: [{
name: '顶部',
value: 'rightToLeft'
}, {
name: '左下',
value: 'leftBottom'
}],
selectDefault: ['顶部'],
selectLabel: '顶部',
selectValue: 'rightToLeft'
}
};
},
watch: { watch: {
appSettings: { appSettings: {
deep: true, deep: true,
handler() { handler() {
if (this.firstLoad) { if (this.firstLoad) {
this.firstLoad = false; this.firstLoad = false;
} else { } else {
this.isSaved = false; this.isSaved = false;
}
} }
} }
} },
},
onLoad(e) { onLoad(e) {
this.fnSetPageTitle('应用设置'); this.fnSetPageTitle('应用设置');
}, },
created() { created() {
this.appSettings = Object.assign({}, _DefaultAppSettings, uni.$tm.vx.getters().getSettings); this.appSettings = Object.assign({}, _DefaultAppSettings, uni.$tm.vx.getters().getSettings);
this.fnHandleFormatSelect(); this.fnHandleFormatSelect();
uni.showLoading({ uni.showLoading({
title: '加载中...', title: '加载中...',
mask: true mask: true
}); });
setTimeout(() => { setTimeout(() => {
this.loading = false; this.loading = false;
uni.hideLoading(); uni.hideLoading();
}, 500); }, 500);
}, },
methods: { methods: {
// 统一处理选择框的内容 // 统一处理选择框的内容
fnHandleFormatSelect() { fnHandleFormatSelect() {
// 首页布局
const _homeLayout = this.fnFindObjInList(this.homeLayout.list, 'value', this.appSettings.layout.home);
this.homeLayout.selectDefault = [_homeLayout.name];
this.homeLayout.selectLabel = _homeLayout.name;
this.homeLayout.selectValue = _homeLayout.value;
const _articleCardStyle = this.fnFindObjInList(this.articleCardStyle.list, 'value', this.appSettings.layout
.cardType);
this.articleCardStyle.selectDefault = [_articleCardStyle.name];
this.articleCardStyle.selectLabel = _articleCardStyle.name;
this.articleCardStyle.selectValue = _articleCardStyle.value;
const _barrage = this.fnFindObjInList(this.barrage.list, 'value', this.appSettings.barrage.type);
this.barrage.selectDefault = [_barrage.name];
this.barrage.selectLabel = _barrage.name;
this.barrage.selectValue = _barrage.value;
},
// 在集合中找匹配的对象
fnFindObjInList(list, key, value) {
return list.find(x => x[key] == value);
},
fnOnBannerDotChange(e) {
const _select = e[0];
if (_select.index == 0 && _select.checked) {
this.appSettings.banner.dotPosition = 'right';
}
if (_select.index == 1 && _select.checked) {
this.appSettings.banner.dotPosition = 'bottom';
}
},
// 首页布局 // 首页布局
const _homeLayout = this.fnFindObjInList(this.homeLayout.list, 'value', this.appSettings.layout.home); fnOnHomeLayoutConfirm(e) {
this.homeLayout.selectDefault = [_homeLayout.name]; const _select = e[0].data;
this.homeLayout.selectLabel = _homeLayout.name; this.homeLayout.selectDefault = [_select.name];
this.homeLayout.selectValue = _homeLayout.value; this.homeLayout.selectLabel = _select.name;
this.homeLayout.selectValue = _select.value;
const _articleCardStyle = this.fnFindObjInList(this.articleCardStyle.list, 'value', this.appSettings.layout.cardType); this.appSettings.layout.home = _select.value;
this.articleCardStyle.selectDefault = [_articleCardStyle.name]; },
this.articleCardStyle.selectLabel = _articleCardStyle.name; // 文章卡片样式
this.articleCardStyle.selectValue = _articleCardStyle.value; fnOnArticleCardStyleConfirm(e) {
const _select = e[0].data;
const _barrage = this.fnFindObjInList(this.barrage.list, 'value', this.appSettings.barrage.type); this.articleCardStyle.selectDefault = [_select.name];
this.barrage.selectDefault = [_barrage.name]; this.articleCardStyle.selectLabel = _select.name;
this.barrage.selectLabel = _barrage.name; this.articleCardStyle.selectValue = _select.value;
this.barrage.selectValue = _barrage.value; this.appSettings.layout.cardType = _select.value;
}, },
// 在集合中找匹配的对象 // 弹幕设置
fnFindObjInList(list, key, value) { fnOnBarrageConfirm(e) {
return list.find(x => x[key] == value); const _select = e[0].data;
}, this.barrage.selectDefault = [_select.name];
fnOnBannerDotChange(e) { this.barrage.selectLabel = _select.name;
const _select = e[0]; this.barrage.selectValue = _select.value;
if (_select.index == 0 && _select.checked) { this.appSettings.barrage.type = _select.value;
this.appSettings.banner.dotPosition = 'right'; },
} // 保存
if (_select.index == 1 && _select.checked) { fnOnSave() {
this.appSettings.banner.dotPosition = 'bottom'; this.isSaved = true;
} this.$tm.vx.commit('setting/setSettings', this.appSettings);
}, uni.$tm.toast('保存成功,部分设置在重启后生效!');
// 首页布局 },
fnOnHomeLayoutConfirm(e) { // 使用默认配置
const _select = e[0].data; fnOnSaveDefault() {
this.homeLayout.selectDefault = [_select.name]; uni.$eShowModal({
this.homeLayout.selectLabel = _select.name; title: '提示',
this.homeLayout.selectValue = _select.value; content: '您确定要恢复为默认的设置吗?',
this.appSettings.layout.home = _select.value; showCancel: true,
}, cancelText: '否',
// 文章卡片样式 cancelColor: '#999999',
fnOnArticleCardStyleConfirm(e) { confirmText: '是',
const _select = e[0].data; confirmColor: '#03a9f4'
this.articleCardStyle.selectDefault = [_select.name]; })
this.articleCardStyle.selectLabel = _select.name; .then(res => {
this.articleCardStyle.selectValue = _select.value; this.isSaved = true;
this.appSettings.layout.cardType = _select.value; uni.$tm.vx.actions('setting/updateDefaultAppSettings');
}, uni.$tm.toast('系统设置已恢复为默认配置,部分设置在重启后生效!');
// 弹幕设置 })
fnOnBarrageConfirm(e) { .catch(err => {});
const _select = e[0].data; },
this.barrage.selectDefault = [_select.name]; fnOnBack() {
this.barrage.selectLabel = _select.name; if (this.isSaved) {
this.barrage.selectValue = _select.value;
this.appSettings.barrage.type = _select.value;
},
// 保存
fnOnSave() {
this.isSaved = true;
this.$tm.vx.commit('setting/setSettings', this.appSettings);
uni.$tm.toast('保存成功,部分设置在重启后生效!');
},
// 使用默认配置
fnOnSaveDefault() {
uni.$eShowModal({
title: '提示',
content: '您确定要恢复为默认的设置吗?',
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
this.isSaved = true;
uni.$tm.vx.actions('setting/updateDefaultAppSettings');
uni.$tm.toast('系统设置已恢复为默认配置,部分设置在重启后生效!');
})
.catch(err => {});
},
fnOnBack() {
if (this.isSaved) {
uni.navigateBack();
return;
}
uni.$eShowModal({
title: '提示',
content: '您当前可能有未保存的数据,确定返回吗?',
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
uni.navigateBack(); uni.navigateBack();
this.isSaved = true; return;
}) }
.catch(err => {}); uni.$eShowModal({
title: '提示',
content: '您当前可能有未保存的数据,确定返回吗?',
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
uni.navigateBack();
this.isSaved = true;
})
.catch(err => {});
}
} }
} };
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.app-page { .app-page {
box-sizing: border-box;
padding-bottom: 120rpx;
.btn-bar {
width: 100vw;
position: fixed;
left: 0;
bottom: 0;
box-sizing: border-box; box-sizing: border-box;
padding: 24rpx; padding-bottom: 120rpx;
gap: 0 24rpx;
box-shadow: 0rpx -6rpx 24rpx rgba(0, 0, 0, 0.03); .btn-bar {
width: 100vw;
position: fixed;
left: 0;
bottom: 0;
box-sizing: border-box;
padding: 24rpx;
gap: 0 24rpx;
box-shadow: 0rpx -6rpx 24rpx rgba(0, 0, 0, 0.03);
}
} }
}
.required { .required {
position: relative; position: relative;
padding-left: 18rpx; padding-left: 18rpx;
&:before {
content: '*'; &:before {
position: absolute; content: '*';
left: -4rpx; position: absolute;
top: 50%; left: -4rpx;
transform: translateY(-50%); top: 50%;
font-size: 34rpx; transform: translateY(-50%);
color: rgba(244, 67, 54, 1); font-size: 34rpx;
color: rgba(244, 67, 54, 1);
}
} }
} </style>
</style>
+19 -15
查看文件
@@ -7,11 +7,13 @@
<tm-skeleton model="listAvatr"></tm-skeleton> <tm-skeleton model="listAvatr"></tm-skeleton>
</view> </view>
<block v-else> <block v-else>
<view class="empty" v-if="dataList.length == 0"><tm-empty icon="icon-shiliangzhinengduixiang-" label="该标签下暂无文章"></tm-empty></view> <view class="empty" v-if="dataList.length == 0"><tm-empty icon="icon-shiliangzhinengduixiang-"
label="该标签下暂无文章"></tm-empty></view>
<block v-else> <block v-else>
<block v-for="(article, index) in dataList" :key="article.createTime"> <block v-for="(article, index) in dataList" :key="article.metadata.name">
<!-- 文章卡片 --> <!-- 文章卡片 -->
<tm-translate animation-name="fadeUp" :wait="calcAniWait(index)"><article-card :article="article" @on-click="fnToArticleDetail"></article-card></tm-translate> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<article-card :article="article" @on-click="fnToArticleDetail"></article-card></tm-translate>
</block> </block>
<view class="load-text">{{ loadMoreText }}</view> <view class="load-text">{{ loadMoreText }}</view>
</block> </block>
@@ -39,10 +41,11 @@
return { return {
loading: 'loading', loading: 'loading',
queryParams: { queryParams: {
name: "",
size: 10, size: 10,
page: 0 page: 0
}, },
slug: '', name: '',
pageTitle: '加载中...', pageTitle: '加载中...',
result: null, result: null,
dataList: [], dataList: [],
@@ -52,8 +55,9 @@
}, },
onLoad(e) { onLoad(e) {
this.slug = e.slug; this.name = e.name;
this.pageTitle = e.name; this.queryParams.name = this.name;
this.pageTitle = e.title;
this.fnGetData(); this.fnGetData();
}, },
onPullDownRefresh() { onPullDownRefresh() {
@@ -62,7 +66,7 @@
this.fnGetData(); this.fnGetData();
}, },
onReachBottom(e) { onReachBottom(e) {
if (this.result.hasNext) { if (this.result && this.result.hasNext) {
this.queryParams.page += 1; this.queryParams.page += 1;
this.isLoadMore = true; this.isLoadMore = true;
this.fnGetData(); this.fnGetData();
@@ -84,17 +88,17 @@
this.loading = 'loading'; this.loading = 'loading';
} }
this.loadMoreText = '加载中...'; this.loadMoreText = '加载中...';
this.$httpApi this.$httpApi.v2
.getTagPostsList(this.slug, this.queryParams) .getPostByTagName(this.name, this.queryParams)
.then(res => { .then(res => {
this.fnSetPageTitle(`标签:${this.pageTitle} (共${res.data.total}篇)`); this.fnSetPageTitle(`${this.pageTitle} (共${res.total}篇)`);
this.result = res.data; this.result = res;
if (this.isLoadMore) { if (this.isLoadMore) {
this.dataList = this.dataList.concat(res.data.content); this.dataList = this.dataList.concat(res.items);
} else { } else {
this.dataList = res.data.content; this.dataList = res.items;
} }
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
setTimeout(() => { setTimeout(() => {
this.loading = 'success'; this.loading = 'success';
}, 500); }, 500);
@@ -114,7 +118,7 @@
//跳转文章详情 //跳转文章详情
fnToArticleDetail(article) { fnToArticleDetail(article) {
uni.navigateTo({ uni.navigateTo({
url: '/pagesA/article-detail/article-detail?articleId=' + article.id, url: '/pagesA/article-detail/article-detail?name=' + article.metadata.name,
animationType: 'slide-in-right' animationType: 'slide-in-right'
}); });
} }
+1 -1
查看文件
@@ -314,7 +314,7 @@
// 回复评论 // 回复评论
fnReplySubmit() { fnReplySubmit() {
this.reply.form.author = this.bloggerInfo.nickname; this.reply.form.author = this.bloggerInfo.nickname;
this.reply.form.authorUrl = this.$haloConfig.social.blog || this.$haloConfig.apiUrl; this.reply.form.authorUrl = this.$haloConfig.social.blog || this.$baseApiUrl;
this.reply.form.email = this.bloggerInfo.email; this.reply.form.email = this.bloggerInfo.email;
uni.showLoading({ uni.showLoading({
+76
查看文件
@@ -0,0 +1,76 @@
/**
* 功能:登录用户
* 作者:小莫唐尼
* 邮箱:studio@925i.cn
* 时间:2022年07月21日 18:41:44
* 版本:v0.1.0
* 修改记录:
* 修改内容:
* 修改人员:
* 修改时间:
*/
import User from '@/api/admin/user.js'
import HaloConfig from '@/config/halo.config.js';
import {
getWxLoginInfo
} from '@/utils/auth.js'
import {
setCache,
getCache
} from '@/utils/storage.js'
export default {
state: {
// 超管登录
adminToken: getCache('APP_ADMIN_LOGIN_TOKEN'),
// 微信登录的信息
wxLoginInfo: getWxLoginInfo(),
},
getters: {
getAdminToken(state) {
return getCache('APP_ADMIN_LOGIN_TOKEN')
},
getWxLoginInfo(state) {
return state.wxLoginInfo
},
},
mutations: {
setAdminToken(state, data) {
state.adminToken = data
setCache('APP_ADMIN_LOGIN_TOKEN', data, data?.expired_in)
},
setWxLoginInfo(state, data) {
state.wxLoginInfo = data
uni.setStorageSync('APP_WX_LOGIN_INFO', JSON.stringify(data))
},
},
actions: {
adminLogin(context, data) {
return new Promise((resolve, reject) => {
User.login(data).then((res) => {
if (res.status == 200) {
context.commit("setAdminToken", res.data);
resolve(res)
} else {
reject(err)
}
}).catch((err) => {
reject(err)
});
})
},
checkAndSetDefaultUser(context) {
if (!context.state.wxLoginInfo) {
context.commit('setWxLoginInfo', {
avatarUrl: HaloConfig.defaultAvatarUrl,
nickName: '匿名访客',
email: '',
url: ''
})
}
},
adminLogout(context) {
context.commit("setAdminToken", null);
}
},
};
+2 -11
查看文件
@@ -27,16 +27,7 @@ export default {
}, },
actions: { actions: {
fnGetBlogger(context) { fnGetBlogger(context) {
if (HaloConfig.author.use) { context.commit("setBlogger", HaloConfig.author);
context.commit("setBlogger", HaloConfig.author);
} else {
Blogger.getBloggerInfo().then((res) => {
context.commit("setBlogger", res.data);
}).catch((err) => {
// 如果失败,则加载默认配置信息
context.commit("setBlogger", HaloConfig.author);
});
}
}, },
}, },
}; };
+2 -2
查看文件
@@ -37,7 +37,7 @@ export const _DefaultAppSettings = {
}, },
// 评论弹幕(文章详情) // 评论弹幕(文章详情)
barrage: { barrage: {
use: true, // 是否启用 use: false, // 是否启用
type: 'leftBottom' // 弹幕位置(rightToLeft leftBottom) type: 'leftBottom' // 弹幕位置(rightToLeft leftBottom)
}, },
gallery: { gallery: {
@@ -51,7 +51,7 @@ export const _DefaultAppSettings = {
}, },
about: { about: {
showAdmin: false, // 显示后台登录入口 showAdmin: false, // 显示后台登录入口
showAllCount: true, // 默认显示所有的统计信息(关于页面) showAllCount: false, // 默认显示所有的统计信息(关于页面)
}, },
// 文章配置 // 文章配置
article: { article: {
+6 -11
查看文件
@@ -11,6 +11,7 @@
*/ */
import HaloConfig from '@/config/halo.config.js'; import HaloConfig from '@/config/halo.config.js';
import HaloTokenConfig from '@/config/token.config.js'
import { import {
logTypes, logTypes,
logUtils logUtils
@@ -27,22 +28,16 @@ const utils = {
// 检查链接 // 检查链接
checkUrl: function(url) { checkUrl: function(url) {
if (!url) return ''; if (!url) return '';
if (!this.checkIsUrl(url)) return HaloConfig.apiUrl + url; if (!this.checkIsUrl(url)) return HaloTokenConfig.BASE_API + url;
return url return url
}, },
// 检查封面图 // 检查封面图
checkThumbnailUrl: function(thumbnail, mustRealUrl = false) { checkThumbnailUrl: function(thumbnail, mustRealUrl = false) {
console.log("thumbnail",thumbnail)
if (!thumbnail && mustRealUrl) { if (!thumbnail && mustRealUrl) {
return HaloConfig.defaultStaticThumbnailUrl return HaloConfig.defaultStaticThumbnailUrl
} }
if (!HaloConfig.defaultThumbnailUrl) {
// logUtils.saveLog(logTypes.config, {
// path: 'checkThumbnailUrl',
// page: 'checkThumbnailUrl',
// msg: '未配置默认的封面图,配置参数【HaloConfig.defaultThumbnailUrl】'
// })
}
let _url = HaloConfig.defaultThumbnailUrl let _url = HaloConfig.defaultThumbnailUrl
if (_url) { if (_url) {
if (_url.indexOf('?') == -1) { if (_url.indexOf('?') == -1) {
@@ -52,7 +47,7 @@ const utils = {
} }
} }
if (!thumbnail) return _url; if (!thumbnail) return _url;
if (!this.checkIsUrl(thumbnail)) return HaloConfig.apiUrl + thumbnail; if (!this.checkIsUrl(thumbnail)) return HaloTokenConfig.BASE_API + thumbnail;
return thumbnail return thumbnail
}, },
@@ -67,7 +62,7 @@ const utils = {
} }
} }
if (!image) return _url; if (!image) return _url;
if (!this.checkIsUrl(image)) return HaloConfig.apiUrl + image; if (!this.checkIsUrl(image)) return HaloTokenConfig.BASE_API + image;
return image return image
}, },
@@ -85,7 +80,7 @@ const utils = {
} }
return _url; return _url;
} }
if (!this.checkIsUrl(avatar)) return HaloConfig.apiUrl + avatar; if (!this.checkIsUrl(avatar)) return HaloTokenConfig.BASE_API + avatar;
return avatar return avatar
}, },
+3 -3
查看文件
@@ -7,12 +7,12 @@ module.exports = {
devServer: { devServer: {
disableHostCheck: true, disableHostCheck: true,
proxy: { proxy: {
"/api": { "/apis": {
target: 'https://b.925i.cn', target: 'https://demo.halo.run',
changeOrigin: true, changeOrigin: true,
secure: true, secure: true,
pathRewrite: { pathRewrite: {
"^/api": "/api" "^/apis": "/apis"
} }
} }
} }