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 d9d2f22..1266b66 100644 Binary files a/mydatabase.db and b/mydatabase.db differ