From 959acab9c77c9073844e932c4f5dc6aead945c89 Mon Sep 17 00:00:00 2001 From: liuyiwuqing <1520431201@qq.com> Date: Sat, 15 Jun 2024 18:28:58 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8D=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E8=AE=BF=E9=97=AE=E5=A4=B1=E6=95=88=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/v2/all.api.js | 13 +++++++++++++ pagesA/article-detail/article-detail.vue | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/api/v2/all.api.js b/api/v2/all.api.js index 66e93b2..5fb3beb 100644 --- a/api/v2/all.api.js +++ b/api/v2/all.api.js @@ -161,6 +161,19 @@ export default { }) }, + /** + * 校验文章访问密码 + */ + checkPostPasswordAccess: (password, postId) => { + return HttpHandler.Get(`/apis/tools.muyin.site/v1alpha1/visitPassword/checkPost?password=${password}`, null, { + header: { + 'Authorization': HaloPluginsConfig.toolsPlugin.Authorization, + 'Wechat-Session-Id': uni.getStorageSync('openid'), + 'Post-Id': postId + } + }) + }, + /** * 获取文章验证码 */ diff --git a/pagesA/article-detail/article-detail.vue b/pagesA/article-detail/article-detail.vue index 018a158..a8277b8 100644 --- a/pagesA/article-detail/article-detail.vue +++ b/pagesA/article-detail/article-detail.vue @@ -375,6 +375,9 @@ export default { this.visitType = 3; this.visitPwd = annotationsMap.unihalo_useVisitPwd; this.showValidVisitPop(); + } else if (('restrictReadEnable' in annotationsMap) && annotationsMap.restrictReadEnable === 'password') { + this.visitType = 4; + this.showValidVisitPop(); } else { this.visitType = 0; this.showValidVisitMore = false; @@ -856,6 +859,9 @@ export default { const first30PercentRaw = this.result?.content?.raw?.substring(0, first30PercentLength); this.result.content.raw = first30PercentRaw; return; + case 4: + this.result.content.raw = ""; + return; default: return; } @@ -894,6 +900,22 @@ export default { }); } return; + case 4: + this.$httpApi.v2.checkPostPasswordAccess(this.validVisitModal.value, this.result?.metadata?.name).then(res => { + if (res.code === 200) { + uni.setStorageSync('visit_' + this.result?.metadata?.name, true) + this.closeAllPop(); + this.fnGetData(); + } else { + uni.showToast({ + title: '密码错误', + icon: 'none' + }); + } + }).catch(err => { + console.log(err); + }); + return; default: return; }