From e3bc24bd9ab5da056ca1cf5ad169243a3c0f97f1 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:03:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(note):=20=E6=B7=BB=E5=8A=A0=E7=A7=81?= =?UTF-8?q?=E5=AF=86=E7=AC=94=E8=AE=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增私密笔记相关样式和图标 - 在笔记列表和详情页面添加私密状态显示 - 实现私密笔记的创建和状态切换功能 - 添加未登录用户查看私密笔记时的提示 --- biji-qianduan/src/assets/styles/global.css | 67 +++++++++++++++++ biji-qianduan/src/components/HomePage.vue | 82 +++++++++++++++++++-- mydatabase.db | Bin 65536 -> 73728 bytes 3 files changed, 143 insertions(+), 6 deletions(-) diff --git a/biji-qianduan/src/assets/styles/global.css b/biji-qianduan/src/assets/styles/global.css index a64d0fc..51975e6 100644 --- a/biji-qianduan/src/assets/styles/global.css +++ b/biji-qianduan/src/assets/styles/global.css @@ -83,4 +83,71 @@ body { .slide-in-up { animation: slideInUp var(--transition-duration) ease-in-out; +} + +/* 私密笔记相关样式 */ +.private-note { + border-left: 3px solid var(--el-color-warning); + opacity: 0.9; +} + +.lock-icon { + margin-left: 8px; + color: var(--el-color-warning); + font-size: 16px; +} + +.private-note-notice { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 40px 20px; + text-align: center; + color: var(--el-text-color-secondary); + background-color: var(--el-color-warning-light-9); + border-radius: 4px; + margin: 20px 0; +} + +.private-note-notice .el-icon { + font-size: 48px; + color: var(--el-color-warning); + margin-bottom: 16px; +} + +.private-note-notice p { + margin: 0; + font-size: 16px; + line-height: 1.5; +} + +/* 表单帮助文本 */ +.form-item-help { + margin-top: 4px; + font-size: 12px; + color: var(--el-text-color-secondary); + line-height: 1.4; +} + +/* 私密状态说明 */ +.privacy-explanation { + display: flex; + align-items: center; + margin-top: 16px; + padding: 12px; + background-color: var(--el-color-info-light-9); + border-radius: 4px; + color: var(--el-text-color-regular); +} + +.privacy-explanation .el-icon { + margin-right: 8px; + color: var(--el-color-info); + font-size: 18px; +} + +.privacy-explanation span { + font-size: 14px; + line-height: 1.5; } \ No newline at end of file diff --git a/biji-qianduan/src/components/HomePage.vue b/biji-qianduan/src/components/HomePage.vue index c25acf8..111db8f 100644 --- a/biji-qianduan/src/components/HomePage.vue +++ b/biji-qianduan/src/components/HomePage.vue @@ -40,6 +40,7 @@

{{ selectedFile.title }} +

@@ -50,6 +51,9 @@ 返回 保存 {{ saveStatus }} + + {{ selectedFile.isPrivate === 1 ? '设为公开' : '设为私密' }} + 导出 @@ -64,7 +68,12 @@
-
+
+
+ +

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

+
+
@@ -109,10 +118,11 @@
- +
{{ file.title }} {{ file.groupingName }} +
@@ -158,6 +168,16 @@ style="width: 100%;" > + + +
私密笔记只有登录用户才能查看内容
+
+ + + +
+

您确定要将笔记 "{{ selectedFile.title }}" {{ selectedFile.isPrivate === 1 ? '设为公开' : '设为私密' }}吗?

+
+ + {{ selectedFile.isPrivate === 1 ? '公开笔记:所有用户都可以查看内容' : '私密笔记:只有登录用户才能查看内容' }} +
+
+ +
@@ -274,7 +309,7 @@ import { generateRegistrationCode, updatePassword } from '@/api/CommonApi.js' -import { Plus, Fold, Expand, Folder, Document, Search, Edit, Delete, ArrowDown, Clock } from "@element-plus/icons-vue"; +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'; @@ -304,6 +339,7 @@ const showSystemSettingsDialog = ref(false); const isRegistrationEnabled = ref(true); const generatedCode = ref(''); const showUpdatePasswordDialog = ref(false); +const showPrivacyDialog = ref(false); const groupFormRef = ref(null); const newGroupForm = ref({ name: '', parentId: null }); @@ -317,7 +353,8 @@ const newNoteForm = ref({ title: '', groupingId: null, fileName: '', - content: '' + content: '', + isPrivate: 0 }); const noteFormRules = ref({ title: [{ required: true, message: '请输入笔记标题', trigger: 'blur' }], @@ -494,7 +531,8 @@ const createNote = async () => { title: newNoteForm.value.title, groupingId: groupingId, fileName: newNoteForm.value.title + '.md', - content: '' + content: '', + isPrivate: newNoteForm.value.isPrivate }; editData.value = payload; showCreateNoteDialog.value = false; @@ -511,7 +549,7 @@ const createNote = async () => { }; const resetNoteForm = () => { - newNoteForm.value = { id: null, title: '', groupingId: null, fileName: '', content: '' }; + newNoteForm.value = { id: null, title: '', groupingId: null, fileName: '', content: '', isPrivate: 0 }; if (noteFormRef.value) { noteFormRef.value.resetFields(); } @@ -571,6 +609,11 @@ const previewFile = async (file) => { content: content }; showEditor.value = false; // 确保进入预览模式 + + // 如果是私密笔记且用户未登录,显示提示 + if (file.isPrivate === 1 && !userStore.isLoggedIn) { + ElMessage.info('这是私密笔记,请登录后查看完整内容'); + } } catch (error) { ElMessage.error('获取笔记内容失败: ' + error.message); selectedFile.value = null; @@ -587,6 +630,33 @@ const editNote = async (file) => { }); }; +// 修改笔记私密状态 +const handlePrivacyChange = async () => { + if (!selectedFile.value) return; + + try { + const newPrivacyStatus = selectedFile.value.isPrivate === 1 ? 0 : 1; + const payload = { + ...selectedFile.value, + isPrivate: newPrivacyStatus + }; + + const updatedFile = await updateMarkdown(payload); + selectedFile.value = updatedFile; + + // 更新列表中的文件状态 + const index = groupMarkdownFiles.value.findIndex(file => file.id === selectedFile.value.id); + if (index !== -1) { + groupMarkdownFiles.value[index] = updatedFile; + } + + showPrivacyDialog.value = false; + ElMessage.success(`笔记已${newPrivacyStatus === 1 ? '设为私密' : '设为公开'}`); + } catch (error) { + ElMessage.error('修改笔记状态失败: ' + error.message); + } +}; + // 图片上传 const handleImageUpload=async (files) => { const promise = await uploadImage(files[0]); diff --git a/mydatabase.db b/mydatabase.db index d9d2f2227e309b821c23a2bcc4a7ed69f1632c2a..1266b6628d816008b73aa4e880569b20abcd50a3 100644 GIT binary patch delta 506 zcmZo@U}-qOGC@j+kpT#VfS4JI?I!9NX#hp_{A+pHI2d@Cjx+GC<}>E+;#|qGh%vrNaCj&Gdk$fVUAtH>^{uFlw2S(2EPlbV}Yl%0}ao)@2%iN+DwY{WK! zadJNwtD;h7aeP5hW?5oMs**xxUP)?tYLSAAtD9q}Pl$p6FPG-#i~EfW}cfx=8o8Vr0JnKU*|lwp#XQHLbQD6hIvo0XM=fq`Rl zzj7guM3YO?!Wkd-b+=4lA@th60K#o0qdBGIBLriL;BVt24G4Prk?`&&ay@Bhv&%c3v(` z&V>v)6DMYDHsm-juE`6ufr&|rfk}(Gf?+d|0|E*gMnfC zNj}CpWd@A{?pskwrTzR>5JaL^lsFK$T~1F7V-%3@?T|O;ori*f13Xp{}%q+{I@p?DlFok zyv5#For_tWEjO_!J0-t7FFq|ZCzWNdim42f00S$~;f(yBLGI__{|wadf}fKaX3OUP z{)`EHylheo%uKr&m_ym(n05ifY7LWkqd?R8C5KmhfVreG5aL~7Va68mRx6+Z*uA)p zNfc<43q&V3$p7kajmpZ5GvW>B6fn+6YdMxaSsZA{)vbphHb}}Z&4&1Oy)a`p=b{4! PJRm1S0sm%3hcEm9w^@yp