diff --git a/api/v2/all.api.js b/api/v2/all.api.js index 140ffea..fba1a42 100644 --- a/api/v2/all.api.js +++ b/api/v2/all.api.js @@ -10,6 +10,7 @@ import qs from 'qs' import { getAppConfigs } from '@/config/index.js' +import {getNologinEmail, getOpenid} from "@/utils/auth"; export default { /** @@ -27,7 +28,8 @@ export default { getPostByName: (name) => { return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts/${name}`, {}, { header: { - 'Wechat-Session-Id': uni.getStorageSync('openid'), + 'Wechat-Session-Id': getOpenid(), + 'nologin-email': getNologinEmail() } }) }, @@ -197,7 +199,8 @@ export default { return HttpHandler.Post(`/apis/tools.muyin.site/v1alpha1/restrict-read/check`, params, { header: { 'Authorization': getAppConfigs().pluginConfig.toolsPlugin?.Authorization, - 'Wechat-Session-Id': uni.getStorageSync('openid'), + 'Wechat-Session-Id': getOpenid(), + 'nologin-email': getNologinEmail() } }) }, @@ -209,7 +212,7 @@ export default { return HttpHandler.Get(`/apis/tools.muyin.site/v1alpha1/restrict-read/create`, null, { header: { 'Authorization': getAppConfigs().pluginConfig.toolsPlugin?.Authorization, - 'Wechat-Session-Id': uni.getStorageSync('openid'), + 'Wechat-Session-Id': getOpenid(), } }) }, @@ -221,7 +224,7 @@ export default { return HttpHandler.Post(`/apis/linkssubmit.muyin.site/v1alpha1/submit`, form, { header: { 'Authorization': getAppConfigs().pluginConfig.linksSubmitPlugin?.Authorization, - 'Wechat-Session-Id': uni.getStorageSync('openid'), + 'Wechat-Session-Id': getOpenid(), } }) }, diff --git a/pagesA/article-detail/article-detail.vue b/pagesA/article-detail/article-detail.vue index 46aa188..b9cce5e 100644 --- a/pagesA/article-detail/article-detail.vue +++ b/pagesA/article-detail/article-detail.vue @@ -101,7 +101,7 @@ :loading="true" :lines="3" :tip-text="`此处内容已隐藏,「${getRestrictReadTypeName(result)}可见」`" - button-text="查看更多" + :button-text="`${getRestrictReadTypeName(result)}`" button-color="#1890ff" skeleton-color="#f0f0f0" skeleton-highlight="#e0e0e0" @@ -129,7 +129,7 @@ :loading="true" :lines="3" :tip-text="`此处内容已隐藏,「${getRestrictReadTypeName(result)}可见」`" - button-text="查看更多" + :button-text="`${getRestrictReadTypeName(result)}`" button-color="#1890ff" skeleton-color="#f0f0f0" skeleton-highlight="#e0e0e0" @@ -726,8 +726,10 @@ export default { this.commentModal.show = true; }, fnOnCommentModalClose({ refresh, isSubmit }) { - console.log('refresh', refresh); - console.log('isSubmit', isSubmit); + // 评论后自动刷新 + if (this.result?.metadata?.annotations?.restrictReadEnable === 'comment') { + this.fnGetData(); + } if (refresh && isSubmit && this.$refs.commentListRef) { this.$refs.commentListRef.fnGetData(); } @@ -1236,10 +1238,8 @@ export default { this.verificationCodeModal.show = true; return; } else if (restrictReadEnable === 'comment') { - uni.showToast({ - title: '前往web端评论后访问', - icon: 'none' - }); + this.fnToComment(); + return; } else if (restrictReadEnable === 'login') { uni.showToast({ title: '前往web端登录后访问', diff --git a/utils/auth.js b/utils/auth.js index c3c3ac3..d979ea1 100644 --- a/utils/auth.js +++ b/utils/auth.js @@ -76,3 +76,20 @@ export function checkHasWxLogin() { export function checkHasAdminLogin() { return !!getCache('APP_ADMIN_LOGIN_TOKEN') } + +/** + * 获取openid + */ +export function getOpenid() { + return uni.getStorageSync('openid'); +} + +/** + * 获取nologin-email + */ +export function getNologinEmail() { + let Visitor = uni.getStorageSync('Visitor'); + if (!Visitor) return ''; + Visitor = JSON.parse(Visitor) + return Visitor.email || Visitor.author || ''; +}