From 4d2f65c23fc493d2d91f8a0b781b9312c6ebca80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=AD=9F?= <3111696955@qq.com> Date: Wed, 6 Aug 2025 15:13:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(biji-qianduan):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=A7=81=E5=AF=86=E7=AC=94=E8=AE=B0=E5=92=8C=E5=9B=9E=E6=94=B6?= =?UTF-8?q?=E7=AB=99=E7=9A=84=E8=AE=BF=E9=97=AE=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 HomePage 中重复的私密笔记提示逻辑 - 在 markdown-preview 中通过条件渲染显示私密笔记提示- 为未登录用户提供回收站访问限制 - 新增私密笔记提示内容的单独文件 --- biji-qianduan/src/components/HomePage.vue | 39 ++++++++++++------- biji-qianduan/src/components/TrashPage.vue | 31 ++++++++++++++- biji-qianduan/src/utils/privateNoteContent.js | 25 ++++++++++++ 3 files changed, 78 insertions(+), 17 deletions(-) create mode 100644 biji-qianduan/src/utils/privateNoteContent.js diff --git a/biji-qianduan/src/components/HomePage.vue b/biji-qianduan/src/components/HomePage.vue index 111db8f..a1545d7 100644 --- a/biji-qianduan/src/components/HomePage.vue +++ b/biji-qianduan/src/components/HomePage.vue @@ -69,10 +69,7 @@
-
- -

这是私密笔记,请登录后查看完整内容

-
+
@@ -312,6 +309,7 @@ import { import { Plus, Fold, Expand, Folder, Document, Search, Edit, Delete, ArrowDown, Clock, Lock, InfoFilled } from "@element-plus/icons-vue"; import { useUserStore } from '../stores/user'; import { useRouter } from 'vue-router'; +import { privateNoteContent } from '../utils/privateNoteContent.js'; const userStore = useUserStore(); const router = useRouter(); @@ -610,10 +608,8 @@ const previewFile = async (file) => { }; showEditor.value = false; // 确保进入预览模式 - // 如果是私密笔记且用户未登录,显示提示 - if (file.isPrivate === 1 && !userStore.isLoggedIn) { - ElMessage.info('这是私密笔记,请登录后查看完整内容'); - } + // 如果是私密笔记且用户未登录,内容会被后端置空,这里不需要额外提示 + // 提示信息已经在模板中通过条件渲染显示 } catch (error) { ElMessage.error('获取笔记内容失败: ' + error.message); selectedFile.value = null; @@ -1054,13 +1050,26 @@ watch([selectedFile, showEditor], ([newFile, newShowEditor]) => { nextTick(() => { const previewElement = document.querySelector('.markdown-preview'); if (previewElement) { - Vditor.preview(previewElement, newFile.content, { - mode: 'light', - hljs: { - enable: true, - style: 'github' - } - }); + // 如果是私密笔记且用户未登录,显示提示内容 + if (newFile.isPrivate === 1 && !userStore.isLoggedIn) { + // 渲染私密笔记提示内容 + Vditor.preview(previewElement, privateNoteContent, { + mode: 'light', + hljs: { + enable: true, + style: 'github' + } + }); + } else if (newFile.content) { + // 只有在有内容时才渲染 Markdown + Vditor.preview(previewElement, newFile.content, { + mode: 'light', + hljs: { + enable: true, + style: 'github' + } + }); + } } }); } diff --git a/biji-qianduan/src/components/TrashPage.vue b/biji-qianduan/src/components/TrashPage.vue index c7d43d4..91c5a49 100644 --- a/biji-qianduan/src/components/TrashPage.vue +++ b/biji-qianduan/src/components/TrashPage.vue @@ -1,5 +1,5 @@ @@ -101,4 +121,11 @@ onMounted(() => { justify-content: space-between; align-items: center; } + +.login-required { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; +} \ No newline at end of file diff --git a/biji-qianduan/src/utils/privateNoteContent.js b/biji-qianduan/src/utils/privateNoteContent.js new file mode 100644 index 0000000..f73c1d7 --- /dev/null +++ b/biji-qianduan/src/utils/privateNoteContent.js @@ -0,0 +1,25 @@ +// 私密笔记提示内容 +export const privateNoteContent = ` +# 🔒 私密笔记 + +这是私密笔记,只有登录用户才能查看完整内容。 + +## 请先登录 + +- 点击右上角的"登录"按钮 +- 输入您的用户名和密码 +- 登录后即可查看此笔记的完整内容 + +## 什么是私密笔记? + +私密笔记是一种特殊的笔记类型,只有登录用户才能查看其内容。未登录用户只能看到笔记标题,无法查看正文。 + +## 为什么使用私密笔记? + +- 保护个人隐私信息 +- 存储敏感或机密内容 +- 限制特定内容的访问权限 + +--- +请登录后查看完整内容 +`;