From 057a7cf6f0aa4ddd4c520328d882bbcc99e45cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=8E=AB=E5=94=90=E5=B0=BC?= <1431128779@qq.com> Date: Mon, 20 May 2024 01:27:15 +0800 Subject: [PATCH] =?UTF-8?q?release:=20=E5=8F=91=E5=B8=83=20uni-halo=20beta?= =?UTF-8?q?-v2.0=20=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 +- .hbuilderx/launch.json | 53 +- App.vue | 119 +- README.md | 29 +- api/article.js | 11 +- api/category.js | 23 +- api/comment.js | 8 +- api/index.js | 4 + api/post.js | 12 +- api/v2/all.api.js | 143 +++ common/http/index.js | 6 +- common/http/interceptors.js | 8 +- common/markdown/markdown.config.js | 3 +- common/mixins/wxshare.mixin.js | 3 +- components/article-card/article-card.vue | 12 +- .../category-mini-card/category-mini-card.vue | 120 +- components/comment-item/comment-item.vue | 253 ++-- components/comment-list/comment-list.vue | 424 ++++--- components/e-swiper/e-swiper.vue | 253 ++-- config/ad.config.template.js | 27 +- config/halo.config.template.js | 53 +- config/keys.js | 7 - config/love.config.js | 16 +- config/love.config.template.js | 10 +- config/sheets.config.js | 8 - config/token.config.template.js | 16 + main.js | 3 +- manifest.json | 6 +- pages.json | 35 +- pages/index/index.vue | 53 +- pages/tabbar/about/about.vue | 1015 ++++++++--------- pages/tabbar/category/category.vue | 287 +++-- pages/tabbar/gallery/gallery.vue | 168 +-- pages/tabbar/home/home.vue | 109 +- pages/tabbar/moments/moments.vue | 237 ++++ pagesA/article-detail/article-detail.vue | 266 +++-- pagesA/articles/articles.vue | 105 +- pagesA/category-detail/category-detail.vue | 21 +- pagesA/comment/comment.vue | 150 ++- .../friend-links/friend-links.vue | 208 ++-- pagesA/leaving/leaving.vue | 257 ----- pagesA/setting/setting.vue | 529 ++++----- pagesA/tag-detail/tag-detail.vue | 34 +- pagesB/comments/comments.vue | 2 +- store/auth.js | 76 ++ store/blogger.js | 13 +- utils/app.js | 4 +- utils/index.js | 17 +- vue.config.js | 6 +- 49 files changed, 2696 insertions(+), 2531 deletions(-) create mode 100644 api/v2/all.api.js delete mode 100644 config/keys.js delete mode 100644 config/sheets.config.js create mode 100644 config/token.config.template.js create mode 100644 pages/tabbar/moments/moments.vue rename pages/tabbar/links/links.vue => pagesA/friend-links/friend-links.vue (64%) delete mode 100644 pagesA/leaving/leaving.vue create mode 100644 store/auth.js diff --git a/.gitignore b/.gitignore index 16fa6b5..f3ca0d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ node_modules/ unpackage/ +package-lock.json + + config/halo.config.js config/ad.config.js config/love.config.js -package-lock.json \ No newline at end of file +config/token.config.js diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index 14c6b7b..a3135b1 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -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代表前端连云端云函数 - "version": "0.0", - "configurations": [{ - "app-plus" : - { - "launchtype" : "local" - }, - "default" : - { - "launchtype" : "local" - }, - "h5" : - { - "launchtype" : "local" - }, - "mp-qq" : - { - "launchtype" : "local" - }, - "mp-weixin" : - { - "launchtype" : "local" - }, - "type" : "uniCloud" - } +{ + // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/ + // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 + "version" : "0.0", + "configurations" : [ + { + "app-plus" : { + "launchtype" : "local" + }, + "default" : { + "launchtype" : "local" + }, + "h5" : { + "launchtype" : "local" + }, + "mp-qq" : { + "launchtype" : "local" + }, + "mp-weixin" : { + "launchtype" : "local" + }, + "type" : "uniCloud" + }, + { + "playground" : "standard", + "type" : "uni-app:app-android" + } ] } diff --git a/App.vue b/App.vue index 7c9cb1e..69ee5ea 100644 --- a/App.vue +++ b/App.vue @@ -1,73 +1,76 @@ + page { + background-color: #fafafa; + } + \ No newline at end of file diff --git a/README.md b/README.md index b3044da..f83fe05 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,12 @@

-

【uni-halo】 基于 uniapp + Halo API 开发的多端项目,值得一试。

+

【uni-halo v2.0】 基于 Halo API 多端项目,值得一试。


作者博客 - 文档地址 + 文档地址(等待更新v2版本说明) Gitee仓库 Github仓库

@@ -26,10 +26,9 @@ #### 🍻 基础功能 -几乎实现PC端后台的全功能,让您在手机端也可以管理您的博客。 +`重要说明:2.0版本 暂时去掉后台管理功能。` -- 用户端:文章列表、文章分类、文章详情、图库、留言板、友链、个人日记等 -- 管理端:资料修改、密码修改、日记管理、文章管理、分类管理、标签管理、附件管理、友链管理、评论管理、日志管理等 +- 用户端:文章列表、文章分类、文章详情、图库、友链、瞬间等
@@ -42,7 +41,7 @@ ## 😎 文档源码 - 作者博客:[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) - 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/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) |
@@ -119,4 +110,4 @@ uni-halo 得益于以下优秀的技术支撑,我只是站在巨人的肩膀 - [Halo:一款好用又强大的开源建站工具](https://halo.run/) - [uni-app:是一个使用 Vue.js 开发所有前端应用的框架,开发者编写一套代码可编译到多个平台](https://uniapp.dcloud.net.cn/) - [tm-vuetify:是一个为 uni-app 平台定制的颜值也非常高的 UI 框架](https://www.jx2d.cn/) -- [mp-html:一个强大的小程序富文本组件](https://jin-yufeng.gitee.io/mp-html/#/) \ No newline at end of file +- [mp-html:一个强大的小程序富文本组件](https://jin-yufeng.gitee.io/mp-html/#/) diff --git a/api/article.js b/api/article.js index 960ec84..2f4c366 100644 --- a/api/article.js +++ b/api/article.js @@ -14,12 +14,9 @@ export default { /** * 获取文章详情 - * @param {String} articleId 文章id + * @param {String} name 文章 name */ - getArticleDetail: (articleId) => { - return HttpHandler.Get(`/api/content/posts/${articleId}`, { - formatDisabled: false, - sourceDisabled: true - }) + getArticleDetail: (name) => { + return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts/${name}`, {}) }, -} +} \ No newline at end of file diff --git a/api/category.js b/api/category.js index 7edc4a9..7cd997c 100644 --- a/api/category.js +++ b/api/category.js @@ -11,17 +11,26 @@ export default { * @param {Object} 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 查询参数 */ - getCategoryPostList: (slug, params) => { - // 从缓存中根据分类获取密码,如果获取到了说明本分类需要密码,避免多个分类需要密码在输入密码后刷新页面点错了分类 - params.password = getCache('APP_CATEGORY_PWD_' + slug) - return HttpHandler.Get(`/api/content/categories/${slug}/posts`, params) + getCategoryPostList: (name, params) => { + return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/categories/${name}/posts`, params) }, -} + + +} \ No newline at end of file diff --git a/api/comment.js b/api/comment.js index ab3e475..e2cb234 100644 --- a/api/comment.js +++ b/api/comment.js @@ -16,11 +16,11 @@ export default { /** * 获取评论列表接口(列表数据) - * @param {String} postId 文章id + * @param {String} name 文章id * @param {Object} params 查询参数 */ - getPostCommentList: (postId, params) => { - return HttpHandler.Get(`/api/content/posts/${postId}/comments/list_view`, params) + getPostCommentList: (name, params) => { + return HttpHandler.Get(`/apis/content.halo.run/v1alpha1/comments${name}`, params) }, /** @@ -42,4 +42,4 @@ export default { getPostChildrenCommentList: (postId, commentParentId, params) => { return HttpHandler.Get(`/api/content/posts/${postId}/comments/${commentParentId}/children`, params) }, -} +} \ No newline at end of file diff --git a/api/index.js b/api/index.js index d2ce3b1..c4dee13 100644 --- a/api/index.js +++ b/api/index.js @@ -40,7 +40,11 @@ import admin_comments from './admin/comments.js' import admin_posts from './admin/posts.js' import admin_logs from './admin/logs.js' +// 2.0接口 +import v2 from './v2/all.api.js' + const ApiManager = { + v2, ...archive, ...article, ...blogger, diff --git a/api/post.js b/api/post.js index 2e14ea9..7e93cab 100644 --- a/api/post.js +++ b/api/post.js @@ -11,7 +11,15 @@ export default { * @param {Object} 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`) }, -} +} \ No newline at end of file diff --git a/api/v2/all.api.js b/api/v2/all.api.js new file mode 100644 index 0000000..42550df --- /dev/null +++ b/api/v2/all.api.js @@ -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) + }, +} \ No newline at end of file diff --git a/common/http/index.js b/common/http/index.js index 01939a9..e187d38 100644 --- a/common/http/index.js +++ b/common/http/index.js @@ -11,6 +11,7 @@ */ import HaloConfig from '@/config/halo.config.js' +import HaloTokenConfig from '@/config/token.config.js' import { setInterceptors } from "./interceptors.js"; @@ -21,11 +22,10 @@ const http = new Request() http.setConfig((config) => { // 如果是在外部浏览器调试或者编译为h5,请注释该行代码 - config.baseURL = HaloConfig.apiUrl; + config.baseURL = HaloTokenConfig.BASE_API; config.header = { - ...config.header, - 'api-authorization': HaloConfig.apiAuthorization, + ...config.header, ContentType: 'application/json', dataType: 'json' } diff --git a/common/http/interceptors.js b/common/http/interceptors.js index 8d7d281..4699bd8 100644 --- a/common/http/interceptors.js +++ b/common/http/interceptors.js @@ -64,13 +64,15 @@ const showCategoryInputPasswordModal = (response, category) => { export const setInterceptors = (http) => { http.interceptors.request.use( (config) => { + console.log("config", config) + // 可使用async await 做异步操作 config.header = { ...config.header // ... 可以直接加参数 }; - if (getAdminAccessToken()) { - config.header['admin-authorization'] = getAdminAccessToken() + if (config.custom.systemToken) { + config.header['Authorization'] = `Bearer ${config.custom.systemToken}` } return config; }, @@ -138,12 +140,14 @@ export const setInterceptors = (http) => { }) }) } + return Promise.reject(response.data); } else if (response.data.status == 403) { // 如果报403是请求分类文章接口(您没有该分类的访问权限)的话说明是私密分类,需要输入密码请求 if (response.config.url.indexOf('/api/content/categories') >= 0) { const category = getCategoryNameByUrl(response.config.url); showCategoryInputPasswordModal(response, category); } + return Promise.reject(response.data); } else { return Promise.reject(response.data); } diff --git a/common/markdown/markdown.config.js b/common/markdown/markdown.config.js index fa39ea5..36ea730 100644 --- a/common/markdown/markdown.config.js +++ b/common/markdown/markdown.config.js @@ -3,8 +3,9 @@ */ import HaloConfig from '@/config/halo.config.js' +import HaloTokenConfig from '@/config/token.config.js' export default { - domain: HaloConfig.apiUrl, + domain: HaloTokenConfig.BASE_API, tagStyle: { table: ` table-layout: fixed; diff --git a/common/mixins/wxshare.mixin.js b/common/mixins/wxshare.mixin.js index 40126d9..086ee3b 100644 --- a/common/mixins/wxshare.mixin.js +++ b/common/mixins/wxshare.mixin.js @@ -1,5 +1,6 @@ // 微信分享配置 import haloConfig from '@/config/halo.config.js' +import HaloTokenConfig from '@/config/token.config.js' import { jsonToUrlParams2 } from '@/utils/url.params.js' export const haloWxShareMixin = { data() { @@ -55,7 +56,7 @@ export const haloWxShareMixin = { } let _config = Object.assign({}, { path: sharePath, - copyLink: haloConfig.apiUrl, + copyLink: HaloTokenConfig.BASE_API, query: {} }, config) diff --git a/components/article-card/article-card.vue b/components/article-card/article-card.vue index 4f64bd1..44ac59f 100644 --- a/components/article-card/article-card.vue +++ b/components/article-card/article-card.vue @@ -1,24 +1,24 @@ + + .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; + } + } + } + \ No newline at end of file diff --git a/components/e-swiper/e-swiper.vue b/components/e-swiper/e-swiper.vue index bd536df..9ab1ad0 100644 --- a/components/e-swiper/e-swiper.vue +++ b/components/e-swiper/e-swiper.vue @@ -2,47 +2,31 @@ - + - - - - - - - + + + + + + @@ -84,12 +68,15 @@ - + + + {{ item.nickname }} - + + 发布于 {{ item.createTime }} @@ -106,18 +93,14 @@ - + - + MORE @@ -132,102 +115,106 @@ + @import './e-swiper.scss'; + \ No newline at end of file diff --git a/config/ad.config.template.js b/config/ad.config.template.js index ac3dcf9..3aeef49 100644 --- a/config/ad.config.template.js +++ b/config/ad.config.template.js @@ -2,29 +2,12 @@ * 广告配置 */ export default { - adpid: '', // uni-AD App广告位id,在uni-AD官网申请广告位 - unitId: '', // 广告单元id,可在小程序管理后台的流量主模块新建 (非个人资质,小程序后台广告主开通申请) - frequency: 8, // 列表中,广告出现的频率(8=每8条数据出现一次广告) - // 首页广告 - home: { - use: false, - }, - // 文章列表广告 - articles: { - use: false, - }, // 文章详情广告 articleDetail: { - // 微信广告/dclound申请的广告 use: true, - - // 自定义广告 - custom: { - use: true, - cover: 'https://b.925i.cn/uni_halo/uni_halo_ad_cover.png', - title: 'uni-halo 正式开源啦,欢迎来使用和体验!', - content: '基于 uni-app + halo1.x API 实现一款现代化的开源博客 / CMS 系统API开发的多端应用。功能包括:前台博客系统 和 后台管理系统,同时满足浏览和管理两端合一的需求,真正实现一个应用实现博客浏览和后台管理。', - url: 'https://uni-halo.925i.cn' - } + 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' } -} +} \ No newline at end of file diff --git a/config/halo.config.template.js b/config/halo.config.template.js index 5a69ebf..573aa84 100644 --- a/config/halo.config.template.js +++ b/config/halo.config.template.js @@ -13,10 +13,7 @@ export default { showCopyright: true, // 显示开源版权信息 showAbout: true, // 显示关于项目入口 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: '', // 博客标题 [建议必填]:在某些页面没有设置具体的页面名称时候,使用该值显示 miniCodeImageUrl: '', // 小程序的太阳码/二维码的图片地址 [建议必填] @@ -25,12 +22,12 @@ export default { // 启动页面的配置(页面地址`/pagesA/start/start`) start: { use: true, // 是否使用首次启动页:用户第一次使用你的应用会显示否则不显示 - title: 'uni-halo', // 启动页面中的文字标题 + title: 'uni-halo2.0', // 标题 bg: '', // 留空则使用默认 开屏首页背景,可以是颜色值或者图片图片地址 - logo: 'https://b.925i.cn/uni_halo/uni_halo_logo.png', // logo - desc1: '全新UI,准备出发', // 描述信息1 + logo: 'https://b.925i.cn/uni_halo/uni_halo_logo.png', // 开屏首页图片 + desc1: '准备好了吗,即刻就出发', // 描述信息1 desc2: '新触动 新感受 新体验', // 描述信息2 - btnText: '全新触发' // 按钮文字 + btnText: '立即体验' }, // 博主信息 @@ -81,43 +78,7 @@ export default { 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: { title: '', // 小程序分享标题[非必填] @@ -136,4 +97,4 @@ export default { '#1CBCB4', '#6638B5', ] -} +} \ No newline at end of file diff --git a/config/keys.js b/config/keys.js deleted file mode 100644 index c8759d6..0000000 --- a/config/keys.js +++ /dev/null @@ -1,7 +0,0 @@ -/** - * 配置key - */ - -export default { - SHEET_LEAVING: 'leaving', // 留言板 -} diff --git a/config/love.config.js b/config/love.config.js index cc161e3..b381306 100644 --- a/config/love.config.js +++ b/config/love.config.js @@ -27,13 +27,13 @@ export default { title: '关于我们', desc: '我们一起度过的那些经历' }, - { - key: 'album', - use: true, - iconImageUrl: 'https://b.925i.cn/uni_halo_love/diandian.png', - title: '恋爱相册', - desc: '定格了我们的那些小美好' - }, + // { + // key: 'album', + // use: true, + // iconImageUrl: 'https://b.925i.cn/uni_halo_love/diandian.png', + // title: '恋爱相册', + // desc: '定格了我们的那些小美好' + // }, { key: 'list', use: true, @@ -145,4 +145,4 @@ export default { } ], } -} +} \ No newline at end of file diff --git a/config/love.config.template.js b/config/love.config.template.js index 86daecb..2922a85 100644 --- a/config/love.config.template.js +++ b/config/love.config.template.js @@ -29,13 +29,6 @@ export default { title: '关于我们', desc: '我们一起度过的那些经历' }, - { - key: 'album', - use: true, - iconImageUrl: 'https://b.925i.cn/uni_halo_love/diandian.png', - title: '恋爱相册', - desc: '定格了我们的那些小美好' - }, { key: 'list', use: true, @@ -49,8 +42,7 @@ export default { journey: `

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

`, - // 恋爱相册 - albumKeyName: '恋爱相册', // 对应后台的图库分组名称 + // 恋爱清单 loveList: { useApi: false, // 是否启用api接口 diff --git a/config/sheets.config.js b/config/sheets.config.js deleted file mode 100644 index 94c2e19..0000000 --- a/config/sheets.config.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * 页面配置 - */ -import AppKeys from './keys.js' - -export default { - [AppKeys.SHEET_LEAVING]: 65, // 留言板页面ID -} diff --git a/config/token.config.template.js b/config/token.config.template.js new file mode 100644 index 0000000..16a12ef --- /dev/null +++ b/config/token.config.template.js @@ -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; \ No newline at end of file diff --git a/main.js b/main.js index 77455e8..40ecba3 100644 --- a/main.js +++ b/main.js @@ -63,8 +63,9 @@ import ApiManager from '@/api/index.js' Vue.use(ApiManager); import HaloConfig from '@/config/halo.config.js' +import HaloTokenConfig from '@/config/token.config.js' Vue.prototype.$haloConfig = HaloConfig -Vue.prototype.$baseApiUrl = HaloConfig.apiUrl +Vue.prototype.$baseApiUrl = HaloTokenConfig.BASE_API import HaloAdConfig from '@/config/ad.config.js' Vue.prototype.$haloAdConfig = HaloAdConfig diff --git a/manifest.json b/manifest.json index 21ed9cf..a186ee7 100644 --- a/manifest.json +++ b/manifest.json @@ -157,12 +157,12 @@ "devServer" : { "disableHostCheck" : true, "proxy" : { - "/api" : { - "target" : "https://b.925i.cn", + "/apis" : { + "target" : "https://demo.halo.run", "changeOrigin" : true, "secure" : false, "pathRewrite" : { - "^/api" : "/api" + "^/apis" : "/apis" } } } diff --git a/pages.json b/pages.json index a03ed4f..ecea263 100644 --- a/pages.json +++ b/pages.json @@ -24,7 +24,7 @@ "path": "pages/tabbar/category/category", "style": { "navigationBarTitleText": "分类", - "enablePullDownRefresh": false, + "enablePullDownRefresh": true, "app-plus": { "pullToRefresh": { "color": "#03a9f4", @@ -45,9 +45,9 @@ } } }, { - "path": "pages/tabbar/links/links", + "path": "pages/tabbar/moments/moments", "style": { - "navigationBarTitleText": "友链", + "navigationBarTitleText": "瞬间", "enablePullDownRefresh": true, "app-plus": { "pullToRefresh": { @@ -160,6 +160,18 @@ } } + }, { + "path": "friend-links/friend-links", + "style": { + "navigationBarTitleText": "友情链接", + "enablePullDownRefresh": true, + "app-plus": { + "pullToRefresh": { + "color": "#03a9f4", + "style": "circle" + } + } + } }, { "path": "journal/journal", "style": { @@ -172,19 +184,6 @@ } } } - }, { - "path": "leaving/leaving", - "style": { - "navigationBarTitleText": "留言板", - "enablePullDownRefresh": true, - "app-plus": { - "pullToRefresh": { - "color": "#03a9f4", - "style": "circle" - } - } - } - }, { "path": "articles/articles", "style": { @@ -572,8 +571,8 @@ }, { "iconPath": "static/tabbar/select_links.png", "selectedIconPath": "static/tabbar/select_links_active.png", - "pagePath": "pages/tabbar/links/links", - "text": "友链" + "pagePath": "pages/tabbar/moments/moments", + "text": "瞬间" }, { "iconPath": "static/tabbar/select_mine.png", "selectedIconPath": "static/tabbar/select_mine_active.png", diff --git a/pages/index/index.vue b/pages/index/index.vue index ae31e72..3e98f01 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -3,29 +3,34 @@ + }; + \ No newline at end of file diff --git a/pages/tabbar/about/about.vue b/pages/tabbar/about/about.vue index 13fdbf4..5f628e5 100644 --- a/pages/tabbar/about/about.vue +++ b/pages/tabbar/about/about.vue @@ -19,103 +19,53 @@ - + 文章总数 - - + + - 分类总数 + 访客数量 - - + + - 标签总数 + 分类总数 - + 评论数量 + - + - 点赞数量 - - - - - - 访客数量 + 点赞数量 - - - - - - {{ nav.text }} - - - + - + + \ No newline at end of file diff --git a/pages/tabbar/category/category.vue b/pages/tabbar/category/category.vue index 42270de..6b9bc43 100644 --- a/pages/tabbar/category/category.vue +++ b/pages/tabbar/category/category.vue @@ -4,89 +4,86 @@ - - - - + + + + + - - - - - - - - - - - - - - {{ loadMoreText }} - - + + + + + + {{item.spec.displayName}} + 共 + {{item.postCount}} 篇文章 + + + + + + + {{ loadMoreText }} - + + \ No newline at end of file diff --git a/pagesA/article-detail/article-detail.vue b/pagesA/article-detail/article-detail.vue index 06a6fd3..8deeaca 100644 --- a/pagesA/article-detail/article-detail.vue +++ b/pagesA/article-detail/article-detail.vue @@ -8,33 +8,33 @@ - {{ result.title }} + {{ result.spec.title }} - 博主:{{ author.nickname }} + 作者:{{ result.owner.displayName }} - 时间:{{ { d: result.createTime, f: 'yyyy年MM月dd日 星期w' } | formatTime }} + 时间:{{ { d: result.spec.publishTime, f: 'yyyy年MM月dd日 星期w' } | formatTime }} - - + + - + - {{ result.visits }} + {{ result.stats.visit }} 阅读 - {{ result.likes }} + {{ result.stats.upvote }} 喜欢 - {{ result.commentCount }} + {{ result.stats.comment }} 评论 - {{ result.wordCount }} + {{ result.content.raw.length }} 字数 @@ -46,8 +46,9 @@ 分类: 未选择分类 - - {{ item.name }} + + {{ item.spec.displayName }} @@ -55,21 +56,25 @@ 标签: 未选择标签 - - {{ item.name }} + + {{ item.spec.displayName }} 原文: - {{ originalURL }} - 阅读原文 + {{ originalURL }} + 阅读原文 - + @@ -81,8 +86,13 @@ - - + + @@ -226,7 +250,9 @@ import rCanvas from '@/components/r-canvas/r-canvas.vue'; import barrage from '@/components/barrage/barrage.vue'; - import { haloWxShareMixin } from '@/common/mixins/wxshare.mixin.js'; + import { + haloWxShareMixin + } from '@/common/mixins/wxshare.mixin.js'; export default { components: { tmSkeleton, @@ -248,10 +274,11 @@ loading: 'loading', markdownConfig: MarkdownConfig, btnOption: { - actions: [{ - icon: 'icon-like', - color: 'bg-gradient-orange-accent' - }, + actions: [ + // { + // icon: 'icon-like', + // color: 'bg-gradient-orange-accent' + // }, { icon: 'icon-commentdots-fill', color: 'bg-gradient-green-accent' @@ -263,15 +290,15 @@ ] }, queryParams: { - articleId: null + name: null }, - result: {}, + result: null, commentDetail: { loading: 'loading', show: false, comment: {}, - postId: undefined, + postName: undefined, list: [] }, poster: { @@ -354,7 +381,7 @@ }, onLoad(e) { this.fnSetPageTitle('文章加载中...'); - this.queryParams.articleId = e.articleId; + this.queryParams.name = e.name; this.fnGetData(); }, @@ -364,31 +391,27 @@ methods: { fnGetData() { this.loading = 'loading'; - // uni.showLoading({ - // mask: true, - // title: '加载中...' - // }); - this.$httpApi - .getArticleDetail(this.queryParams.articleId) + this.$httpApi.v2 + .getPostByName(this.queryParams.name) .then(res => { - if (res.status == 200) { - this.result = res.data; - this.metas = res.data.metas; - this.fnSetPageTitle('文章详情'); - this.loading = 'success'; - this.fnSetWxShareConfig({ - title: this.result.title, - desc: this.result.summary, - imageUrl: this.$utils.checkThumbnailUrl(this.result.thumbnail), - path: `/pagesA/article-detail/article-detail?articleId=${this.queryParams.articleId}`, - copyLink: this.$haloConfig.apiUrl, - query: {} - }); - } else { - this.loading = 'error'; - } + console.log('详情', res); + + this.result = res; + this.metas = []; + this.fnSetPageTitle('文章详情'); + this.loading = 'success'; + this.fnSetWxShareConfig({ + title: this.result.spec.title, + desc: this.result.content.raw, + imageUrl: this.$utils.checkThumbnailUrl(this.result.spec.cover), + path: `/pagesA/article-detail/article-detail?name=${this.result.metadata.name}`, + copyLink: this.$baseApiUrl, + query: {} + }); + }) .catch(err => { + console.log("错误", err) this.loading = 'error'; }) .finally(() => { @@ -400,28 +423,28 @@ // 浮动按钮点击 fnOnFlotButtonChange(index) { switch (index) { + // case 0: + // this.fnDoLikes(); + // break; case 0: - this.fnDoLikes(); - break; - case 1: this.fnToComment(); break; - case 2: + case 1: this.fnShowShare(); break; } }, fnToComment() { - if (this.result.disallowComment) { + if (!this.result.spec.allowComment) { return uni.$tm.toast('文章已开启禁止评论!'); } this.$Router.push({ path: '/pagesA/comment/comment', query: { - id: this.result.id, - parentId: 0, - title: this.result.title, + isComment: true, + postName: this.result.metadata.name, + title: this.result.spec.title, from: 'posts', formPage: 'comment_list', type: 'post' @@ -474,7 +497,7 @@ this.$nextTick(async () => { const systemInfo = await uni.getSystemInfoSync(); 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({ canvas_id: 'rCanvas', @@ -566,7 +589,7 @@ // 文章标题 await this.$refs.rCanvas .drawText({ - text: this.result.title, + text: this.result.spec.title, max_width: 312, line_clamp: 1, x: 12, @@ -583,7 +606,7 @@ }); await this.$refs.rCanvas .drawText({ - text: this.result.summary, + text: this.result.content.raw, max_width: 312, line_clamp: 2, x: 12, @@ -674,9 +697,9 @@ provider: 'weixin', scene: 'WXSceneSession', type: 0, - href: this.$haloConfig.apiUrl, - title: this.result.title, - summary: this.result.summary, + href: this.$baseApiUrl, + title: this.result.spec.title, + summary: this.result.content.raw, imageUrl: this.poster.res.tempFilePath, success: function(res) { console.log('success:' + JSON.stringify(res)); @@ -688,41 +711,45 @@ // #endif }, fnOnShowCommentDetail(data) { - const { postId, comment } = data; + const { + postName, + comment + } = data; this.commentDetail.comment = comment; - this.commentDetail.postId = postId; + this.commentDetail.postName = postName; this.commentDetail.list = []; this.commentDetail.show = true; this.fnGetChildComments(); }, fnGetChildComments() { this.commentDetail.loading = 'loading'; - this.$httpApi - .getPostChildrenCommentList(this.commentDetail.postId, this.commentDetail.comment.id, {}) + this.$httpApi.v2 + .getPostCommentReplyList(this.commentDetail.postName, { + page: 1, + size: 100 + }) .then(res => { - if (res.status == 200) { - this.commentDetail.loading = 'success'; - this.commentDetail.list = res.data; - } else { - this.commentDetail.loading = 'error'; - } - console.log('getPostChildrenCommentList', res); + console.log('getPostChildrenCommentList res', res); + this.commentDetail.loading = 'success'; + this.commentDetail.list = res.items; }) .catch(err => { + console.log('getPostChildrenCommentList err', error); this.commentDetail.loading = 'error'; }); }, fnToCate(category) { 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) { 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) { + console.log("data", data) const _list = []; const _handleData = list => { return new Promise(resolve => { @@ -731,8 +758,8 @@ } else { list.forEach(item => { _list.push(item); - if (item.children && item.children.length != 0) { - _handleData(item.children); + if (item.replies && item.replies.length != 0) { + _handleData(item.replies.items); } resolve(); }); @@ -740,31 +767,31 @@ }); }; await _handleData(data); - if (this.globalAppSettings.barrage.use) { - this.$nextTick(() => { - if (_list.length != 0) { - _handleAddBarrage(); - } - }); - } - const _handleRemove = () => { - this.$refs['barrage'] && this.$refs['barrage'].remove({ - duration: 5000, // 延迟关闭的时间 - speed: 600 // 弹幕消失的速度 - }); - }; - let index = 0; - const _handleAddBarrage = () => { - setTimeout(() => { - this.$refs['barrage'] && this.$refs['barrage'].add(_list[index]); - index += 1; - if (index < _list.length - 1) { - _handleAddBarrage(); - } else { - _handleRemove(); - } - }, 1000); - }; + // if (this.globalAppSettings.barrage.use) { + // this.$nextTick(() => { + // if (_list.length != 0) { + // _handleAddBarrage(); + // } + // }); + // } + // const _handleRemove = () => { + // this.$refs['barrage'] && this.$refs['barrage'].remove({ + // duration: 5000, // 延迟关闭的时间 + // speed: 600 // 弹幕消失的速度 + // }); + // }; + // let index = 0; + // const _handleAddBarrage = () => { + // setTimeout(() => { + // this.$refs['barrage'] && this.$refs['barrage'].add(_list[index]); + // index += 1; + // if (index < _list.length - 1) { + // _handleAddBarrage(); + // } else { + // _handleRemove(); + // } + // }, 1000); + // }; }, fnToWebview(data) { uni.navigateTo({ @@ -776,7 +803,10 @@ }); }, fnToOriginal(originalURL) { - this.fnToWebview({ title: this.result.title, url: originalURL }); + this.fnToWebview({ + title: this.result.title, + url: originalURL + }); }, // 查看密码验证确认 fnOnValidVisitConfirm() { diff --git a/pagesA/articles/articles.vue b/pagesA/articles/articles.vue index 77f12e2..c852ef1 100644 --- a/pagesA/articles/articles.vue +++ b/pagesA/articles/articles.vue @@ -2,11 +2,13 @@ - - + + - + @@ -18,24 +20,23 @@ - + + - - - - - - - - - - - - - - - + + + + {{article.title}} + {{article.content}} + + + 发布日期:{{ { d: article.publishTimestamp, f: 'yyyy年MM月dd日' } | formatTime }} + + + {{ loadMoreText }} @@ -70,10 +71,10 @@ list: ['全部', '最新文章', '热门文章', '最近更新', '最多点赞'] }, queryParams: { - size: 10, - page: 0, - sort: 'topPriority,createTime,desc', - keyword: '' + keyword: "", + limit: 5, + highlightPreTag: "", + highlightPostTag: "" }, cache: { dataList: [], @@ -88,27 +89,19 @@ onLoad() { this.fnSetPageTitle('文章列表'); }, - created() { - this.fnGetData(); + created() { + if (!this.queryParams.keyword) { + this.loading = 'success' + } else { + this.fnGetData(); + } }, onPullDownRefresh() { + this.fnResetSetAniWaitIndex(); 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: { fnOnTabChange(index) { this.fnResetSetAniWaitIndex(); @@ -121,16 +114,18 @@ 4: 'topPriority,likes,desc' }; this.queryParams.sort = _sorts[index]; - this.queryParams.page = 0; this.dataList = []; this.fnToTopPage(); this.fnGetData(); }, fnOnSearch() { this.fnResetSetAniWaitIndex(); - this.queryParams.page = 0; this.isLoadMore = false; - this.fnGetData(); + if (!this.queryParams.keyword) { + this.dataList = [] + } else { + this.fnGetData(); + } }, fnGetData() { // uni.showLoading({ @@ -142,20 +137,19 @@ this.loading = 'loading'; } this.loadMoreText = '加载中...'; - this.$httpApi - .getPostList(this.queryParams) + this.$httpApi.v2 + .getPostListByKeyword(this.queryParams) .then(res => { console.log('请求结果:'); console.log(res); this.loading = 'success'; - this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; - // 处理数据 - this.result = res.data; + this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; + this.result = res; if (this.isLoadMore) { - this.dataList = this.dataList.concat(res.data.content); + this.dataList = this.dataList.concat(res.hits); } else { - this.dataList = res.data.content; + this.dataList = res.hits; } }) .catch(err => { @@ -174,7 +168,7 @@ //跳转文章详情 fnToArticleDetail(article) { uni.navigateTo({ - url: '/pagesA/article-detail/article-detail?articleId=' + article.id, + url: '/pagesA/article-detail/article-detail?name=' + article.name, animationType: 'slide-in-right' }); } @@ -203,4 +197,17 @@ 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; + } \ No newline at end of file diff --git a/pagesA/category-detail/category-detail.vue b/pagesA/category-detail/category-detail.vue index cb5a697..5a59f24 100644 --- a/pagesA/category-detail/category-detail.vue +++ b/pagesA/category-detail/category-detail.vue @@ -42,7 +42,7 @@ size: 10, page: 0 }, - slug: '', + name: '', pageTitle: '加载中...', result: null, dataList: [], @@ -52,8 +52,8 @@ }, onLoad(e) { - this.slug = e.slug; - this.pageTitle = e.name; + this.name = e.name; + this.pageTitle = e.title; this.fnGetData(); }, onPullDownRefresh() { @@ -85,16 +85,17 @@ } this.loadMoreText = '加载中...'; this.$httpApi - .getCategoryPostList(this.slug, this.queryParams) + .getCategoryPostList(this.name, this.queryParams) .then(res => { - this.fnSetPageTitle(`分类:${this.pageTitle} (共${res.data.total}篇)`); - this.result = res.data; + console.log("请求成功:",res) + this.fnSetPageTitle(`${this.pageTitle} (共${res.total}篇)`); + this.result = res; if (this.isLoadMore) { - this.dataList = this.dataList.concat(res.data.content); + this.dataList = this.dataList.concat(res.items); } else { - this.dataList = res.data.content; + this.dataList = res.items; } - this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; + this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; setTimeout(() => { this.loading = 'success'; }, 500); @@ -114,7 +115,7 @@ //跳转文章详情 fnToArticleDetail(article) { 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' }); } diff --git a/pagesA/comment/comment.vue b/pagesA/comment/comment.vue index 5807245..95e32ce 100644 --- a/pagesA/comment/comment.vue +++ b/pagesA/comment/comment.vue @@ -3,15 +3,19 @@ - - - - - - 接收提醒 - - - 提交 + + + + + + 提交 @@ -32,9 +36,9 @@ }, data() { return { + isComment: true, params: { - postId: '', - parentId: '', + postName: '', title: '', // 被回复的标题 type=user =用户名 否则为文章标题 form: '', formPage: '', // 来自哪个页面 @@ -46,40 +50,39 @@ avatar: '', authorUrl: '', // 作者主页 content: '', // 评论内容 - email: '', // 邮件 - parentId: 0, - postId: 0 + email: '', // 邮件 + postName: "" } }; }, - computed: { - // 评论游客信息 - wxLoginVisitorUser() { - return uni.$tm.vx.getters().getWxLoginInfo; - } - }, onLoad() { this.params = this.$Route.query; - this.form.postId = this.params.id; - if (this.params.type == 'user') { - this.form.parentId = this.params.parentId; + this.isComment = this.params.isComment; + this.form.postName = this.params.postName; + + if (!this.isComment) { this.fnSetPageTitle('回复用户:' + this.params.title); } else { - this.form.parentId = 0; this.fnSetPageTitle(this.params.title); } - this.form.author = this.wxLoginVisitorUser.nickName; - this.form.avatar = this.wxLoginVisitorUser.avatarUrl; - this.form.email = this.wxLoginVisitorUser.email; - this.form.authorUrl = this.wxLoginVisitorUser.url; + + try { + let visitor = uni.getStorageSync('Visitor') + 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: { fnOnSubmit(e) { - console.log('提交评论'); if (e === false) { return uni.$tm.toast('请检查所有的必填项是否填写完整!'); } - if (this.form.allowNotification && !this.form.email) { + if (!this.form.email) { return uni.$tm.toast('未填写邮箱地址,将无法接收提醒!'); } if (this.form.email && !uni.$tm.test.email(this.form.email)) { @@ -90,36 +93,77 @@ } 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() { uni.showLoading({ title: '正在提交...' }); - const _api = { - sheets: this.$httpApi.postSheetsComments, - posts: this.$httpApi.postCommentPost - }; - _api[this.params.from](this.form) - .then(res => { - if (res.status == 200) { - uni.$tm.toast('提交成功,待博主审核通过后即可展示!'); - // 更新评论者信息 - uni.$tm.vx.commit('user/setWxLoginInfo', { - avatarUrl: this.wxLoginVisitorUser.avatarUrl, - nickName: this.form.author, - email: this.form.email, - url: this.form.authorUrl - }); - // 清空评论内容 - this.form.content = ''; - // 触发刷新评论(可能需要评论审核不会有改变) - // uni.$emit(this.params.formPage + '_refresh'); - } else { - uni.$tm.toast('操作失败,请重试!'); + + // 评论 + if (this.isComment) { + const commentForm = { + 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, + }, + subjectRef: { + group: "content.halo.run", + kind: "Post", + name: this.form.postName, + version: "v1alpha1", } + } + 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 => { - uni.$tm.toast(err.message); + uni.$tm.toast("提示:回复失败"); }); } } diff --git a/pages/tabbar/links/links.vue b/pagesA/friend-links/friend-links.vue similarity index 64% rename from pages/tabbar/links/links.vue rename to pagesA/friend-links/friend-links.vue index 869ec1b..bf54cd6 100644 --- a/pages/tabbar/links/links.vue +++ b/pagesA/friend-links/friend-links.vue @@ -7,45 +7,55 @@ - + - + - - - + + + - + - {{ link.name }} - - - ID:{{ link.id }} + + + {{ link.spec.groupName || '暂未分组' }} + + {{ link.spec.displayName }} + + + 站点地址:{{ link.spec.url }} + - - 博客简介:{{ link.description || '这个博主很懒,没写简介~' }} + + 博客简介:{{ link.spec.description || '这个博主很懒,没写简介~' }} - - + + - {{ link.name }} - {{ link.description }} + {{ link.spec.displayName }} + {{ link.spec.description }} + - {{ link.url }} + {{ link.spec.url }} @@ -53,49 +63,52 @@ - - - + + + {{ team.title }} - + - + linkIndex != team.children.length - 1 || index == dataList.length - 1 + }" @click="fnCopyLink(link)"> - {{ link.name }} + {{ link.spec.displayName }} - ID:{{ link.id }} + ID:{{ link.metadata.name }} - - {{ link.team || '暂未分组' }} + + {{ link.spec.groupName || '暂未分组' }} - 博客简介:{{ link.description || '这个博主很懒,没写简介~' }} + 博客简介:{{ link.spec.description || '这个博主很懒,没写简介~' }} - - + + - {{ link.name }} + {{ link.spec.displayName }} - {{ link.description }} + {{ link.spec.description }} - {{ link.url }} + {{ link.spec.url }} @@ -106,7 +119,7 @@ - + @@ -138,10 +151,13 @@ - + + + {{ loadMoreText }} @@ -155,7 +171,9 @@ import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue'; import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue'; - import { GetRandomNumberByRange } from '@/utils/random.js'; + import { + GetRandomNumberByRange + } from '@/utils/random.js'; export default { components: { tmSkeleton, @@ -171,15 +189,17 @@ loading: 'loading', queryParams: { size: 10, - page: 0, - sort: '' + page: 1 }, - result: [], + result: {}, detail: { show: false, data: {} }, - linkTotal: 0 + isLoadMore: false, + loadMoreText: '', + dataList: [], + cacheDataList: [] }; }, computed: { @@ -195,56 +215,62 @@ }, onLoad() { this.fnSetPageTitle('朋友圈'); - }, - created() { this.fnGetData(); }, onPullDownRefresh() { + this.isLoadMore = false; + this.queryParams.page = 1; + this.dataList = [] + this.cacheDataList = [] this.fnGetData(); }, + onReachBottom(e) { + if (this.result.hasNext) { + this.queryParams.page += 1; + this.isLoadMore = true; + this.fnGetData(); + } else { + uni.showToast({ + icon: 'none', + title: '没有更多数据了' + }); + } + }, methods: { fnRandomColor() { const _r = GetRandomNumberByRange(0, this.$haloConfig.colors.length - 1); return this.$haloConfig.colors[_r]; }, fnGetData() { - this.linkTotal = 0; - this.loading = 'loading'; - // uni.showLoading({ - // mask: true, - // title: '加载中...' - // }); - this.$httpApi - .getLinkListByTeam() - .then(res => { - if (res.status == 200) { - console.log('请求结果:'); - console.log(res); - // 处理数据 - const _result = res.data.map(item => { - const _team = item.team || '未分组'; - const _links = item.links.map(link => { - this.linkTotal += 1; - link.logo = this.$utils.checkAvatarUrl(link.logo); - return link; - }); - return { - title: _team, - children: _links - }; - }); + if (!this.isLoadMore) { + this.loading = 'loading'; + } + this.loadMoreText = ''; + + this.$httpApi.v2 + .getFriendLinkList(this.queryParams) + .then(res => { + console.log('请求结果:'); + console.log(res); + this.result = res; + const list = res.items.map(item => { + item.spec.logo = this.$utils.checkAvatarUrl(item.spec.logo) + return item; + }) + this.dataList = this.dataList.concat(list); + + // this.cacheDataList = this.cacheDataList.concat(list); + // this.dataList = this.handleGroup(this.cacheDataList).reverse(); + setTimeout(() => { + this.loading = 'success'; + this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; + }, 500); - this.result = _result.reverse(); - setTimeout(() => { - this.loading = 'success'; - }, 500); - } else { - this.loading = 'error'; - } }) .catch(err => { console.error(err); this.loading = 'error'; + this.loadMoreText = '加载失败,请下拉刷新!'; }) .finally(() => { 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) { this.detail.data = link; this.detail.show = true; diff --git a/pagesA/leaving/leaving.vue b/pagesA/leaving/leaving.vue deleted file mode 100644 index 65c0621..0000000 --- a/pagesA/leaving/leaving.vue +++ /dev/null @@ -1,257 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pagesA/setting/setting.vue b/pagesA/setting/setting.vue index 7ab9da4..0182cf6 100644 --- a/pagesA/setting/setting.vue +++ b/pagesA/setting/setting.vue @@ -14,43 +14,16 @@ 应用以及文章列表布局设置 - - + + - - + + @@ -73,14 +46,16 @@ - 图库瀑布流模式 - + 图库瀑布流模式 + - 友链简洁模式 - + 友链简洁模式 + - + 是否圆形头像 - + 轮播图指示器 - + 轮播图指示器位置 - + - + @@ -152,221 +123,261 @@ + \ No newline at end of file diff --git a/pagesA/tag-detail/tag-detail.vue b/pagesA/tag-detail/tag-detail.vue index dd5bfdc..efa315a 100644 --- a/pagesA/tag-detail/tag-detail.vue +++ b/pagesA/tag-detail/tag-detail.vue @@ -7,11 +7,13 @@ - + - + - + + {{ loadMoreText }} @@ -39,10 +41,11 @@ return { loading: 'loading', queryParams: { + name: "", size: 10, page: 0 }, - slug: '', + name: '', pageTitle: '加载中...', result: null, dataList: [], @@ -52,8 +55,9 @@ }, onLoad(e) { - this.slug = e.slug; - this.pageTitle = e.name; + this.name = e.name; + this.queryParams.name = this.name; + this.pageTitle = e.title; this.fnGetData(); }, onPullDownRefresh() { @@ -62,7 +66,7 @@ this.fnGetData(); }, onReachBottom(e) { - if (this.result.hasNext) { + if (this.result && this.result.hasNext) { this.queryParams.page += 1; this.isLoadMore = true; this.fnGetData(); @@ -84,17 +88,17 @@ this.loading = 'loading'; } this.loadMoreText = '加载中...'; - this.$httpApi - .getTagPostsList(this.slug, this.queryParams) + this.$httpApi.v2 + .getPostByTagName(this.name, this.queryParams) .then(res => { - this.fnSetPageTitle(`标签:${this.pageTitle} (共${res.data.total}篇)`); - this.result = res.data; + this.fnSetPageTitle(`${this.pageTitle} (共${res.total}篇)`); + this.result = res; if (this.isLoadMore) { - this.dataList = this.dataList.concat(res.data.content); + this.dataList = this.dataList.concat(res.items); } else { - this.dataList = res.data.content; + this.dataList = res.items; } - this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; + this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; setTimeout(() => { this.loading = 'success'; }, 500); @@ -114,7 +118,7 @@ //跳转文章详情 fnToArticleDetail(article) { 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' }); } diff --git a/pagesB/comments/comments.vue b/pagesB/comments/comments.vue index cc6bdac..f89ffe1 100644 --- a/pagesB/comments/comments.vue +++ b/pagesB/comments/comments.vue @@ -314,7 +314,7 @@ // 回复评论 fnReplySubmit() { 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; uni.showLoading({ diff --git a/store/auth.js b/store/auth.js new file mode 100644 index 0000000..20a3794 --- /dev/null +++ b/store/auth.js @@ -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); + } + }, +}; diff --git a/store/blogger.js b/store/blogger.js index 0d48148..a3a4542 100644 --- a/store/blogger.js +++ b/store/blogger.js @@ -27,16 +27,7 @@ export default { }, actions: { fnGetBlogger(context) { - if (HaloConfig.author.use) { - context.commit("setBlogger", HaloConfig.author); - } else { - Blogger.getBloggerInfo().then((res) => { - context.commit("setBlogger", res.data); - }).catch((err) => { - // 如果失败,则加载默认配置信息 - context.commit("setBlogger", HaloConfig.author); - }); - } + context.commit("setBlogger", HaloConfig.author); }, }, -}; +}; \ No newline at end of file diff --git a/utils/app.js b/utils/app.js index 519996f..5d47e50 100644 --- a/utils/app.js +++ b/utils/app.js @@ -37,7 +37,7 @@ export const _DefaultAppSettings = { }, // 评论弹幕(文章详情) barrage: { - use: true, // 是否启用 + use: false, // 是否启用 type: 'leftBottom' // 弹幕位置(rightToLeft leftBottom) }, gallery: { @@ -51,7 +51,7 @@ export const _DefaultAppSettings = { }, about: { showAdmin: false, // 显示后台登录入口 - showAllCount: true, // 默认显示所有的统计信息(关于页面) + showAllCount: false, // 默认显示所有的统计信息(关于页面) }, // 文章配置 article: { diff --git a/utils/index.js b/utils/index.js index a99de0b..e3f7d5d 100644 --- a/utils/index.js +++ b/utils/index.js @@ -11,6 +11,7 @@ */ import HaloConfig from '@/config/halo.config.js'; +import HaloTokenConfig from '@/config/token.config.js' import { logTypes, logUtils @@ -27,22 +28,16 @@ const utils = { // 检查链接 checkUrl: function(url) { if (!url) return ''; - if (!this.checkIsUrl(url)) return HaloConfig.apiUrl + url; + if (!this.checkIsUrl(url)) return HaloTokenConfig.BASE_API + url; return url }, // 检查封面图 checkThumbnailUrl: function(thumbnail, mustRealUrl = false) { + console.log("thumbnail",thumbnail) if (!thumbnail && mustRealUrl) { return HaloConfig.defaultStaticThumbnailUrl } - if (!HaloConfig.defaultThumbnailUrl) { - // logUtils.saveLog(logTypes.config, { - // path: 'checkThumbnailUrl', - // page: 'checkThumbnailUrl', - // msg: '未配置默认的封面图,配置参数【HaloConfig.defaultThumbnailUrl】' - // }) - } let _url = HaloConfig.defaultThumbnailUrl if (_url) { if (_url.indexOf('?') == -1) { @@ -52,7 +47,7 @@ const utils = { } } if (!thumbnail) return _url; - if (!this.checkIsUrl(thumbnail)) return HaloConfig.apiUrl + thumbnail; + if (!this.checkIsUrl(thumbnail)) return HaloTokenConfig.BASE_API + thumbnail; return thumbnail }, @@ -67,7 +62,7 @@ const utils = { } } if (!image) return _url; - if (!this.checkIsUrl(image)) return HaloConfig.apiUrl + image; + if (!this.checkIsUrl(image)) return HaloTokenConfig.BASE_API + image; return image }, @@ -85,7 +80,7 @@ const utils = { } return _url; } - if (!this.checkIsUrl(avatar)) return HaloConfig.apiUrl + avatar; + if (!this.checkIsUrl(avatar)) return HaloTokenConfig.BASE_API + avatar; return avatar }, diff --git a/vue.config.js b/vue.config.js index e7aa6b9..ad28b05 100644 --- a/vue.config.js +++ b/vue.config.js @@ -7,12 +7,12 @@ module.exports = { devServer: { disableHostCheck: true, proxy: { - "/api": { - target: 'https://b.925i.cn', + "/apis": { + target: 'https://demo.halo.run', changeOrigin: true, secure: true, pathRewrite: { - "^/api": "/api" + "^/apis": "/apis" } } }