From a7cb3dc2c715b4a0d3d085eba9581b5a692c051c Mon Sep 17 00:00:00 2001 From: ikmkj <1@qq,com> Date: Thu, 31 Jul 2025 18:25:57 +0800 Subject: [PATCH 01/11] =?UTF-8?q?feat(components):=20=E5=9C=A8=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=92=8C=E6=B3=A8=E5=86=8C=E9=A1=B5=E9=9D=A2=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=BF=94=E5=9B=9E=E9=A6=96=E9=A1=B5=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 LoginPage.vue 和 RegisterPage.vue 中添加返回首页按钮 - 实现 goToHome 方法,用于跳转到首页- 优化用户操作流程,提供更便捷的页面导航 --- biji-qianduan/src/components/LoginPage.vue | 5 +++++ biji-qianduan/src/components/RegisterPage.vue | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/biji-qianduan/src/components/LoginPage.vue b/biji-qianduan/src/components/LoginPage.vue index 8d7b202..8bc0e97 100644 --- a/biji-qianduan/src/components/LoginPage.vue +++ b/biji-qianduan/src/components/LoginPage.vue @@ -16,6 +16,7 @@ 登录 注册 + 返回首页 @@ -58,6 +59,10 @@ const handleLogin = async () => { const goToRegister = () => { router.push('/register'); }; + +const goToHome = () => { + router.push('/home'); +}; From 384ac43370137b2b695397243827492dc032421d Mon Sep 17 00:00:00 2001 From: ikmkj <1@qq,com> Date: Thu, 31 Jul 2025 18:50:52 +0800 Subject: [PATCH 03/11] =?UTF-8?q?feat(menu):=20=E6=B7=BB=E5=8A=A0=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E9=A1=B9=E9=9A=90=E8=97=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 ElSubMenu 组件中添加 popperClass 属性,根据菜单是否折叠来决定是否隐藏- 在样式中添加 .hide-popper 类,用于隐藏菜单项 --- biji-qianduan/src/components/HomePage.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/biji-qianduan/src/components/HomePage.vue b/biji-qianduan/src/components/HomePage.vue index 6a4fbbb..569bc18 100644 --- a/biji-qianduan/src/components/HomePage.vue +++ b/biji-qianduan/src/components/HomePage.vue @@ -448,7 +448,10 @@ const renderMenu = (item) => { }); if (item.children && item.children.length > 0) { - return h(ElSubMenu, { index: `group-${item.id}` }, { + return h(ElSubMenu, { + index: `group-${item.id}`, + popperClass: isCollapsed.value ? 'hide-popper' : '' + }, { title: () => h('div', { onClick: () => selectFile(item), style: 'width: 100%;' }, [ wrappedContent() ]), default: () => item.children.map(child => renderMenu(child)) }); @@ -837,6 +840,10 @@ watch(activeMenu, (newVal) => { background-color: var(--primary-color-light) !important; } +.hide-popper { + display: none !important; +} + /* 移除预览中代码块的内部滚动条 */ .markdown-preview .vditor-reset pre { max-height: none !important; From 8cbd5b02b32567e2bdc2d0a30203c52519f8647c Mon Sep 17 00:00:00 2001 From: ikmkj <1@qq,com> Date: Thu, 31 Jul 2025 19:21:58 +0800 Subject: [PATCH 04/11] =?UTF-8?q?feat(recycle-bin):=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=9B=9E=E6=94=B6=E7=AB=99=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增回收站相关 API 接口 - 添加回收站页面组件和路由 - 实现笔记和分类的软删除功能 - 支持回收站内容的获取、恢复和永久删除操作 - 优化用户界面,增加回收站入口和相关提示 --- biji-qianduan/package-lock.json | 197 +++++++++++++++++++++ biji-qianduan/package.json | 2 + biji-qianduan/src/api/CommonApi.js | 12 ++ biji-qianduan/src/components/HomePage.vue | 149 +++++++++++++++- biji-qianduan/src/components/TrashPage.vue | 104 +++++++++++ biji-qianduan/src/router/index.js | 6 + 回收站功能设计.md | 22 +++ 7 files changed, 485 insertions(+), 7 deletions(-) create mode 100644 biji-qianduan/src/components/TrashPage.vue create mode 100644 回收站功能设计.md diff --git a/biji-qianduan/package-lock.json b/biji-qianduan/package-lock.json index 72afe44..377d74a 100644 --- a/biji-qianduan/package-lock.json +++ b/biji-qianduan/package-lock.json @@ -12,6 +12,8 @@ "codemirror": "^6.0.1", "element-plus": "^2.10.4", "highlight.js": "^11.11.1", + "html2canvas": "^1.4.1", + "jspdf": "^3.0.1", "pinia": "^3.0.3", "pinia-plugin-persistedstate": "^4.4.1", "vditor": "^3.11.1", @@ -1132,6 +1134,20 @@ "undici-types": "~7.8.0" } }, + "node_modules/@types/raf": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/@types/raf/-/raf-3.4.3.tgz", + "integrity": "sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw==", + "license": "MIT", + "optional": true + }, + "node_modules/@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", + "license": "MIT", + "optional": true + }, "node_modules/@types/unist": { "version": "2.0.11", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", @@ -1604,6 +1620,15 @@ "node": ">=0.10.0" } }, + "node_modules/base64-arraybuffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz", + "integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/birpc": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/birpc/-/birpc-2.5.0.tgz", @@ -1665,6 +1690,18 @@ "node": ">=0.10.0" } }, + "node_modules/btoa": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==", + "license": "(MIT OR Apache-2.0)", + "bin": { + "btoa": "bin/btoa.js" + }, + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -1691,6 +1728,26 @@ "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==", "license": "MIT" }, + "node_modules/canvg": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/canvg/-/canvg-3.0.11.tgz", + "integrity": "sha512-5ON+q7jCTgMp9cjpu4Jo6XbvfYwSB2Ow3kzHKfIyJfaCAOHLbdKPQqGKgfED/R5B+3TFFfe8pegYA+b423SRyA==", + "license": "MIT", + "optional": true, + "dependencies": { + "@babel/runtime": "^7.12.5", + "@types/raf": "^3.4.0", + "core-js": "^3.8.3", + "raf": "^3.4.1", + "regenerator-runtime": "^0.13.7", + "rgbcolor": "^1.0.1", + "stackblur-canvas": "^2.0.0", + "svg-pathdata": "^6.0.3" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -1855,6 +1912,18 @@ "toggle-selection": "^1.0.6" } }, + "node_modules/core-js": { + "version": "3.44.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.44.0.tgz", + "integrity": "sha512-aFCtd4l6GvAXwVEh3XbbVqJGHDJt0OZRa+5ePGx3LLwi12WfexqQxcsohb2wgsa/92xtl19Hd66G/L+TaAxDMw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/cose-base": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-1.0.3.tgz", @@ -1870,6 +1939,15 @@ "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==", "license": "MIT" }, + "node_modules/css-line-break": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.1.0.tgz", + "integrity": "sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==", + "license": "MIT", + "dependencies": { + "utrie": "^1.0.2" + } + }, "node_modules/cssfilter": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/cssfilter/-/cssfilter-0.0.10.tgz", @@ -2795,6 +2873,12 @@ } } }, + "node_modules/fflate": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", + "integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==", + "license": "MIT" + }, "node_modules/fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -3075,6 +3159,19 @@ "integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==", "license": "MIT" }, + "node_modules/html2canvas": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.4.1.tgz", + "integrity": "sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==", + "license": "MIT", + "dependencies": { + "css-line-break": "^2.1.0", + "text-segmentation": "^1.0.3" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", @@ -3304,6 +3401,34 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jspdf": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/jspdf/-/jspdf-3.0.1.tgz", + "integrity": "sha512-qaGIxqxetdoNnFQQXxTKUD9/Z7AloLaw94fFsOiJMxbfYdBbrBuhWmbzI8TVjrw7s3jBY1PFHofBKMV/wZPapg==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.26.7", + "atob": "^2.1.2", + "btoa": "^1.2.1", + "fflate": "^0.8.1" + }, + "optionalDependencies": { + "canvg": "^3.0.11", + "core-js": "^3.6.0", + "dompurify": "^3.2.4", + "html2canvas": "^1.0.0-rc.5" + } + }, + "node_modules/jspdf/node_modules/dompurify": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.2.6.tgz", + "integrity": "sha512-/2GogDQlohXPZe6D6NOgQvXLPSYBqIWMnZ8zzOhn09REE4eyAzb+Hed3jhoM9OkuaJ8P6ZGTTVWQKAi8ieIzfQ==", + "license": "(MPL-2.0 OR Apache-2.0)", + "optional": true, + "optionalDependencies": { + "@types/trusted-types": "^2.0.7" + } + }, "node_modules/katex": { "version": "0.13.24", "resolved": "https://registry.npmjs.org/katex/-/katex-0.13.24.tgz", @@ -4300,6 +4425,13 @@ "integrity": "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==", "license": "MIT" }, + "node_modules/performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", + "license": "MIT", + "optional": true + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -4422,6 +4554,23 @@ "node": ">=6" } }, + "node_modules/raf": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz", + "integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==", + "license": "MIT", + "optional": true, + "dependencies": { + "performance-now": "^2.1.0" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", + "license": "MIT", + "optional": true + }, "node_modules/regex-not": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", @@ -4481,6 +4630,16 @@ "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", "license": "MIT" }, + "node_modules/rgbcolor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/rgbcolor/-/rgbcolor-1.0.1.tgz", + "integrity": "sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==", + "license": "MIT OR SEE LICENSE IN FEEL-FREE.md", + "optional": true, + "engines": { + "node": ">= 0.8.15" + } + }, "node_modules/robust-predicates": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.2.tgz", @@ -4844,6 +5003,16 @@ "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "license": "BSD-3-Clause" }, + "node_modules/stackblur-canvas": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/stackblur-canvas/-/stackblur-canvas-2.7.0.tgz", + "integrity": "sha512-yf7OENo23AGJhBriGx0QivY5JP6Y1HbrrDI6WLt6C5auYZXlQrheoY8hD4ibekFKz1HOfE48Ww8kMWMnJD/zcQ==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.1.14" + } + }, "node_modules/static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -4927,6 +5096,25 @@ "node": ">=4" } }, + "node_modules/svg-pathdata": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/svg-pathdata/-/svg-pathdata-6.0.3.tgz", + "integrity": "sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/text-segmentation": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/text-segmentation/-/text-segmentation-1.0.3.tgz", + "integrity": "sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==", + "license": "MIT", + "dependencies": { + "utrie": "^1.0.2" + } + }, "node_modules/tinyglobby": { "version": "0.2.14", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz", @@ -5149,6 +5337,15 @@ "node": ">=0.10.0" } }, + "node_modules/utrie": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/utrie/-/utrie-1.0.2.tgz", + "integrity": "sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==", + "license": "MIT", + "dependencies": { + "base64-arraybuffer": "^1.0.2" + } + }, "node_modules/uuid": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", diff --git a/biji-qianduan/package.json b/biji-qianduan/package.json index b089ac1..98b8b70 100644 --- a/biji-qianduan/package.json +++ b/biji-qianduan/package.json @@ -13,6 +13,8 @@ "codemirror": "^6.0.1", "element-plus": "^2.10.4", "highlight.js": "^11.11.1", + "html2canvas": "^1.4.1", + "jspdf": "^3.0.1", "pinia": "^3.0.3", "pinia-plugin-persistedstate": "^4.4.1", "vditor": "^3.11.1", diff --git a/biji-qianduan/src/api/CommonApi.js b/biji-qianduan/src/api/CommonApi.js index 4f44429..bd3a719 100644 --- a/biji-qianduan/src/api/CommonApi.js +++ b/biji-qianduan/src/api/CommonApi.js @@ -115,3 +115,15 @@ export const MD5 = (data, file) => { + +// 获取回收站内容 +export const getTrash = () => axiosApi.get('/api/trash'); + +// 恢复项目 +export const restoreTrashItem = (id) => axiosApi.post(`/api/trash/restore/${id}`); + +// 彻底删除 +export const permanentlyDeleteItem = (id) => axiosApi.delete(`/api/trash/permanently/${id}`); + +// 清空回收站 +export const cleanTrash = () => axiosApi.delete('/api/trash/clean'); diff --git a/biji-qianduan/src/components/HomePage.vue b/biji-qianduan/src/components/HomePage.vue index 569bc18..5e62255 100644 --- a/biji-qianduan/src/components/HomePage.vue +++ b/biji-qianduan/src/components/HomePage.vue @@ -26,6 +26,10 @@ + + + + @@ -46,7 +50,18 @@ 返回 保存 {{ saveStatus }} - 导出为.md + + + 导出 + + +
@@ -212,7 +227,7 @@ import { deleteGrouping as apiDeleteGrouping, getRecentFiles } from '@/api/CommonApi.js' -import { Plus, Fold, Expand, Folder, Document, Search, Edit, Delete } from "@element-plus/icons-vue"; +import { Plus, Fold, Expand, Folder, Document, Search, Edit, Delete, ArrowDown, Clock } from "@element-plus/icons-vue"; import { useUserStore } from '../stores/user'; import { useRouter } from 'vue-router'; @@ -715,18 +730,134 @@ const handleSearch = async () => { } }; -const handleExportMd = () => { - if (!selectedFile.value) return; - const blob = new Blob([selectedFile.value.content], { type: 'text/markdown;charset=utf-8' }); +import jsPDF from 'jspdf'; +import html2canvas from 'html2canvas'; + + +const showExportLoading = ref(false); + +// 文件名特殊字符清理 +const sanitizeFilename = (name) => name.replace(/[<>:"/\\|?*]/g, '_').trim() || '未命名笔记'; + +const handleExport = async (format) => { + if (!selectedFile.value || showExportLoading.value) return; + + const title = sanitizeFilename(selectedFile.value.title); + const content = selectedFile.value.content; + const previewElement = document.querySelector('.markdown-preview'); + + if (!previewElement) { + ElMessage.error('无法找到预览区域'); + return; + } + + showExportLoading.value = true; + ElMessage.info(`正在导出为 ${format.toUpperCase()}...`); + + try { + switch (format) { + case 'md': + exportAsMd(title, content); + break; + case 'pdf': + await exportAsPdf(title, previewElement); + break; + case 'html': + exportAsHtml(title, previewElement.innerHTML); + break; + } + ElMessage.success(`${format.toUpperCase()} 导出成功`); + } catch (error) { + console.error('Export failed:', error); + ElMessage.error(`导出失败: ${error.message}`); + } finally { + showExportLoading.value = false; + } +}; + +const exportAsMd = (title, content) => { + const blob = new Blob([content], { type: 'text/markdown;charset=utf-8' }); + downloadBlob(blob, `${title}.md`); +}; + +const exportAsPdf = async (title, element) => { + const canvas = await html2canvas(element, { + scale: 2, + useCORS: true, + logging: false, + }); + + const pdf = new jsPDF({ + orientation: 'p', + unit: 'mm', + format: 'a4', + }); + + const pageHeight = pdf.internal.pageSize.getHeight() - 20; // 减去页边距 + const pageWidth = pdf.internal.pageSize.getWidth() - 20; + const imgWidth = pageWidth; + const imgHeight = (canvas.height * imgWidth) / canvas.width; + let heightLeft = imgHeight; + let position = 10; // 初始Y轴位置 + const imgData = canvas.toDataURL('image/png'); + + pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight); + heightLeft -= pageHeight; + + let pageCount = 1; + while (heightLeft > 0) { + pageCount++; + position = -pageHeight * (pageCount - 1) + 10; + pdf.addPage(); + pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight); + heightLeft -= pageHeight; + } + + // 添加页眉和页脚 + for (let i = 1; i <= pageCount; i++) { + pdf.setPage(i); + pdf.setFontSize(8); + pdf.setTextColor(150); + pdf.text(title, pdf.internal.pageSize.getWidth() / 2, 8, { align: 'center' }); + pdf.text(`第 ${i} 页 / 共 ${pageCount} 页`, pdf.internal.pageSize.getWidth() / 2, pdf.internal.pageSize.getHeight() - 8, { align: 'center' }); + } + + pdf.save(`${title}.pdf`); +}; + +const exportAsHtml = (title, htmlContent) => { + const fullHtml = ` + + + + + ${title} + + + + +

${title}

+ ${htmlContent} + + + `; + const blob = new Blob([fullHtml], { type: 'text/html;charset=utf-8' }); + downloadBlob(blob, `${title}.html`); +}; + +const downloadBlob = (blob, filename) => { const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; - link.download = `${selectedFile.value.title}.md`; + link.download = filename; document.body.appendChild(link); link.click(); document.body.removeChild(link); URL.revokeObjectURL(url); -}; +} const goToLogin = () => { router.push('/login'); @@ -742,6 +873,10 @@ const handleLogout = () => { router.push('/login'); }; +const goToTrash = () => { + router.push({ name: 'Trash' }); +}; + const resetToHomeView = async () => { selectedFile.value = null; showEditor.value = false; diff --git a/biji-qianduan/src/components/TrashPage.vue b/biji-qianduan/src/components/TrashPage.vue new file mode 100644 index 0000000..268ed4c --- /dev/null +++ b/biji-qianduan/src/components/TrashPage.vue @@ -0,0 +1,104 @@ + + + + + \ No newline at end of file diff --git a/biji-qianduan/src/router/index.js b/biji-qianduan/src/router/index.js index eea42c0..97e135d 100644 --- a/biji-qianduan/src/router/index.js +++ b/biji-qianduan/src/router/index.js @@ -3,6 +3,7 @@ import HomePage from '../components/HomePage.vue'; import MarkdownEditor from '../components/MarkdownEditor.vue'; import LoginPage from '../components/LoginPage.vue'; import RegisterPage from '../components/RegisterPage.vue'; +import TrashPage from '../components/TrashPage.vue'; const routes = [ { @@ -34,6 +35,11 @@ const routes = [ path: '/register', name: 'Register', component: RegisterPage + }, + { + path: '/trash', + name: 'Trash', + component: TrashPage } ]; diff --git a/回收站功能设计.md b/回收站功能设计.md new file mode 100644 index 0000000..65a66e8 --- /dev/null +++ b/回收站功能设计.md @@ -0,0 +1,22 @@ +# 回收站功能设计方案 + +## 功能需求 +- 实现笔记和分类的软删除功能 +- 提供30天数据保留期 +- 支持恢复和永久删除操作 + +## 前端修改 +1. 侧边栏添加回收站入口 +2. 删除操作改为"移至回收站" +3. 新建TrashPage.vue组件 + +## 后端修改 +```sql +ALTER TABLE markdown ADD COLUMN is_deleted BOOLEAN DEFAULT false; +ALTER TABLE markdown ADD COLUMN deleted_at TIMESTAMP; +``` + +## API接口 +- GET /api/trash - 获取回收站内容 +- POST /api/trash/restore - 恢复项目 +- DELETE /api/trash/clean - 清空回收站 \ No newline at end of file From 16998c514419e522791df66ddcd68843456e8be6 Mon Sep 17 00:00:00 2001 From: ikmkj <1@qq,com> Date: Thu, 31 Jul 2025 19:26:34 +0800 Subject: [PATCH 05/11] =?UTF-8?q?style(qianduan):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=AD=90=E8=8F=9C=E5=8D=95=E6=A0=87=E9=A2=98=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为子菜单标题添加样式类 'submenu-title-wrapper' - 在标题容器内添加 flex 布局,使内容垂直居中 --- biji-qianduan/src/components/HomePage.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/biji-qianduan/src/components/HomePage.vue b/biji-qianduan/src/components/HomePage.vue index 5e62255..8dc27cf 100644 --- a/biji-qianduan/src/components/HomePage.vue +++ b/biji-qianduan/src/components/HomePage.vue @@ -467,7 +467,11 @@ const renderMenu = (item) => { index: `group-${item.id}`, popperClass: isCollapsed.value ? 'hide-popper' : '' }, { - title: () => h('div', { onClick: () => selectFile(item), style: 'width: 100%;' }, [ wrappedContent() ]), + title: () => h('div', { + class: 'submenu-title-wrapper', + onClick: () => selectFile(item), + style: 'width: 100%; display: flex; align-items: center;' + }, [ wrappedContent() ]), default: () => item.children.map(child => renderMenu(child)) }); } From cd43768bafecd7c6d2cec1b1dabc9fda0d15fe7e Mon Sep 17 00:00:00 2001 From: ikmkj <1@qq,com> Date: Thu, 31 Jul 2025 19:39:59 +0800 Subject: [PATCH 06/11] =?UTF-8?q?feat(security):=20=E6=B7=BB=E5=8A=A0=20To?= =?UTF-8?q?ken=20=E9=AA=8C=E8=AF=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 CommonApi.js 中添加 validateToken 函数,用于验证 Token 有效性 - 在 HomePage.vue 中集成 Token 验证功能,导出前验证登录状态- 在 UserController.java 中添加 validateToken 接口,用于后端验证 Token --- .../bijihoudaun/controller/UserController.java | 7 ++++++- biji-qianduan/src/api/CommonApi.js | 3 +++ biji-qianduan/src/components/HomePage.vue | 14 ++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/controller/UserController.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/controller/UserController.java index 51f885e..75ea2ad 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/controller/UserController.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/controller/UserController.java @@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; @@ -57,6 +58,10 @@ public class UserController { return R.success("删除成功"); } - + @Operation(summary = "验证Token有效性") + @PostMapping("/validate-token") + public R validateToken() { + return R.success("Token is valid"); + } } diff --git a/biji-qianduan/src/api/CommonApi.js b/biji-qianduan/src/api/CommonApi.js index bd3a719..cf4d372 100644 --- a/biji-qianduan/src/api/CommonApi.js +++ b/biji-qianduan/src/api/CommonApi.js @@ -127,3 +127,6 @@ export const permanentlyDeleteItem = (id) => axiosApi.delete(`/api/trash/permane // 清空回收站 export const cleanTrash = () => axiosApi.delete('/api/trash/clean'); + +// 验证Token +export const validateToken = () => axiosApi.post('/api/user/validate-token'); diff --git a/biji-qianduan/src/components/HomePage.vue b/biji-qianduan/src/components/HomePage.vue index 8dc27cf..9465c02 100644 --- a/biji-qianduan/src/components/HomePage.vue +++ b/biji-qianduan/src/components/HomePage.vue @@ -50,7 +50,7 @@ 返回 保存 {{ saveStatus }} - + 导出 @@ -225,7 +225,8 @@ import { updateGroupingName, updateMarkdownTitle, deleteGrouping as apiDeleteGrouping, - getRecentFiles + getRecentFiles, + validateToken } from '@/api/CommonApi.js' import { Plus, Fold, Expand, Folder, Document, Search, Edit, Delete, ArrowDown, Clock } from "@element-plus/icons-vue"; import { useUserStore } from '../stores/user'; @@ -746,6 +747,15 @@ const sanitizeFilename = (name) => name.replace(/[<>:"/\\|?*]/g, '_').trim() || const handleExport = async (format) => { if (!selectedFile.value || showExportLoading.value) return; + try { + await validateToken(); + } catch (error) { + ElMessage.error('登录已过期,请重新登录'); + userStore.logout(); + router.push('/login'); + return; + } + const title = sanitizeFilename(selectedFile.value.title); const content = selectedFile.value.content; const previewElement = document.querySelector('.markdown-preview'); From 56633dfd3b3602804708062bdb5cd5dde64487be Mon Sep 17 00:00:00 2001 From: ikmkj <1@qq,com> Date: Thu, 31 Jul 2025 22:07:00 +0800 Subject: [PATCH 07/11] =?UTF-8?q?feat:=E9=87=8D=E6=9E=84=20UI=20=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E5=B9=B6=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7=E4=BD=93?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新了全局样式,增加了更多主题颜色和样式 - 重新设计了首页、登录和注册页面的布局和样式 - 增加了暗黑主题支持 - 优化了表单元素和按钮的样式- 调整了字体颜色和背景渐变 --- biji-qianduan/src/assets/styles/global.css | 5 +- biji-qianduan/src/assets/styles/theme.css | 88 +++++---- biji-qianduan/src/components/HomePage.vue | 186 +++++++++++++----- biji-qianduan/src/components/LoginPage.vue | 160 +++++++++++---- biji-qianduan/src/components/RegisterPage.vue | 166 ++++++++++++---- 5 files changed, 440 insertions(+), 165 deletions(-) diff --git a/biji-qianduan/src/assets/styles/global.css b/biji-qianduan/src/assets/styles/global.css index 5277f59..a64d0fc 100644 --- a/biji-qianduan/src/assets/styles/global.css +++ b/biji-qianduan/src/assets/styles/global.css @@ -7,9 +7,10 @@ body { font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - background-color: var(--bg-color); + background: var(--bg-gradient); color: var(--text-color); - transition: background-color var(--transition-duration), color var(--transition-duration); + transition: background var(--transition-duration), color var(--transition-duration); + background-attachment: fixed; } /* 滚动条美化 */ diff --git a/biji-qianduan/src/assets/styles/theme.css b/biji-qianduan/src/assets/styles/theme.css index df4b1ed..31ef241 100644 --- a/biji-qianduan/src/assets/styles/theme.css +++ b/biji-qianduan/src/assets/styles/theme.css @@ -2,46 +2,66 @@ /* 默认浅色主题 */ :root { + /* 主色调 - 活力紫 */ + --primary-color: #6a11cb; + --primary-color-light: #f3e5f5; /* 浅紫色,用于悬停 */ + --primary-color-dark: #4a008f; /* 深紫色,用于激活 */ + + /* 辅助色 */ + --secondary-color: #f7fafc; + --accent-color: #2575fc; /* 亮蓝色,用于强调 */ + --danger-color: #f5365c; + --success-color: #2dce89; + --warning-color: #fb6340; + + /* 背景色 - 带有色彩倾向的渐变 */ --bg-color: #ffffff; - --bg-color-secondary: #f7f8fa; - --bg-color-tertiary: #eff2f5; - --text-color: #303133; - --text-color-secondary: #606266; - --text-color-placeholder: #a8abb2; - --border-color: #dcdfe6; - --border-color-light: #e4e7ed; - --primary-color: #409eff; - --primary-color-light: #ecf5ff; - --danger-color: #f56c6c; - --success-color: #67c23a; - --warning-color: #e6a23c; - --info-color: #909399; + --bg-color-secondary: #f8f9fe; + --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); - --box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); - --box-shadow-light: 0 2px 4px rgba(0, 0, 0, 0.08); - --box-shadow-dark: 0 4px 16px rgba(0, 0, 0, 0.15); + /* 文本色 */ + --text-color: #32325d; /* 深蓝灰色 */ + --text-color-secondary: #6b7c93; /* 灰蓝色 */ + --text-color-placeholder: #adb5bd; - --transition-duration: 0.3s; + /* 边框和阴影 */ + --border-color: #e9ecef; + --border-radius: 8px; + --box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08); + --box-shadow-light: 0 2px 4px rgba(50, 50, 93, 0.1); + --box-shadow-dark: 0 7px 14px rgba(50, 50, 93, 0.1), 0 3px 6px rgba(0, 0, 0, 0.08); + + /* 过渡 */ + --transition-duration: 0.25s; } /* 深色主题 */ .dark-theme { - --bg-color: #141414; - --bg-color-secondary: #1a1a1a; - --bg-color-tertiary: #222222; - --text-color: #e5e5e5; - --text-color-secondary: #a3a3a3; - --text-color-placeholder: #5c5c5c; - --border-color: #3a3a3a; - --border-color-light: #2a2a2a; - --primary-color: #409eff; - --primary-color-light: #26334f; - --danger-color: #f56c6c; - --success-color: #67c23a; - --warning-color: #e6a23c; - --info-color: #909399; + /* 主色调 - 科技蓝 */ + --primary-color: #007bff; + --primary-color-light: #1f2937; + --primary-color-dark: #0056b3; - --box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.3); - --box-shadow-light: 0 2px 4px rgba(0, 0, 0, 0.25); - --box-shadow-dark: 0 4px 16px rgba(0, 0, 0, 0.4); + /* 辅助色 */ + --secondary-color: #111827; + --accent-color: #10b981; /* 亮绿色 */ + --danger-color: #ef4444; + --success-color: #22c55e; + --warning-color: #f97316; + + /* 背景色 - 深邃的渐变 */ + --bg-color: #0d1117; + --bg-color-secondary: #1f2937; + --bg-gradient: linear-gradient(135deg, #0d1117 0%, #1f2937 100%); + + /* 文本色 */ + --text-color: #e5e7eb; + --text-color-secondary: #9ca3af; + --text-color-placeholder: #4b5563; + + /* 边框和阴影 */ + --border-color: #374151; + --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.15); + --box-shadow-light: 0 2px 4px rgba(0, 0, 0, 0.18); + --box-shadow-dark: 0 7px 14px rgba(0, 0, 0, 0.2), 0 3px 6px rgba(0, 0, 0, 0.15); } \ No newline at end of file diff --git a/biji-qianduan/src/components/HomePage.vue b/biji-qianduan/src/components/HomePage.vue index 9465c02..29985ed 100644 --- a/biji-qianduan/src/components/HomePage.vue +++ b/biji-qianduan/src/components/HomePage.vue @@ -71,7 +71,7 @@
-

我的笔记

+

我的笔记

-
- 欢迎, {{ userStore.userInfo?.username }} + -
+
登录 注册
- 新建笔记 - - 上传Markdown -
@@ -1009,43 +1008,66 @@ watch(activeMenu, (newVal) => { + +/* 对话框样式 */ +:deep(.el-dialog) { + border-radius: var(--border-radius); + background-color: var(--bg-color-secondary); +} + +:deep(.el-dialog__header) { + border-bottom: 1px solid var(--border-color); + padding: 1.5rem; +} + +:deep(.el-dialog__title) { + font-size: 1.25rem; + font-weight: 600; + color: var(--text-color); +} + +:deep(.el-dialog__body) { + padding: 1.5rem; +} + +:deep(.el-dialog__footer) { + padding: 1.5rem; + border-top: 1px solid var(--border-color); +} + +.welcome-text { + white-space: nowrap; +} +.user-actions, .guest-actions { + display: flex; + align-items: center; + gap: 10px; +} diff --git a/biji-qianduan/src/components/LoginPage.vue b/biji-qianduan/src/components/LoginPage.vue index 8bc0e97..a90ac53 100644 --- a/biji-qianduan/src/components/LoginPage.vue +++ b/biji-qianduan/src/components/LoginPage.vue @@ -1,25 +1,36 @@ @@ -28,6 +39,7 @@ import { ref } from 'vue'; import { useRouter } from 'vue-router'; import { useUserStore } from '../stores/user'; import { ElMessage } from 'element-plus'; +import { User, Lock } from '@element-plus/icons-vue'; const router = useRouter(); const userStore = useUserStore(); @@ -70,60 +82,128 @@ const goToHome = () => { display: flex; justify-content: center; align-items: center; - height: 100vh; - background-color: var(--bg-color-secondary); - background-image: linear-gradient(135deg, var(--bg-color) 0%, var(--bg-color-secondary) 100%); + min-height: 100vh; + padding: 2rem; + background: var(--bg-gradient); + background-attachment: fixed; } .login-card { - width: 420px; - padding: 20px 30px; - border-radius: 12px; - background-color: var(--bg-color); + width: 100%; + max-width: 420px; + padding: 2.5rem 2rem; + border-radius: var(--border-radius); + background-color: rgba(255, 255, 255, 0.85); + backdrop-filter: blur(10px); box-shadow: var(--box-shadow-dark); - border: 1px solid var(--border-color); - animation: slideInDown 0.5s ease-out; + border: 1px solid rgba(255, 255, 255, 0.2); + animation: fadeIn 0.5s ease-out; overflow: hidden; } +.dark-theme .login-card { + background-color: rgba(23, 23, 39, 0.85); + border: 1px solid rgba(255, 255, 255, 0.1); +} + .card-header { text-align: center; - font-size: 24px; + margin-bottom: 2.5rem; +} + +.card-header h2 { + margin: 0 0 0.5rem 0; + font-size: 1.75rem; font-weight: 600; color: var(--text-color); - padding-bottom: 20px; - margin-bottom: 20px; - border-bottom: 1px solid var(--border-color-light); +} + +.card-header p { + margin: 0; + color: var(--text-color-secondary); } .el-form-item { - margin-bottom: 25px; + margin-bottom: 1.5rem; } -.el-button { +:deep(.el-form-item__label) { + color: var(--text-color-secondary); + line-height: 1.5; + margin-bottom: 0.5rem; +} + +:deep(.el-input__wrapper) { + border-radius: var(--border-radius); + background-color: var(--bg-color-secondary); + box-shadow: none; + transition: all var(--transition-duration) ease; + border: 1px solid var(--border-color); +} + +:deep(.el-input__wrapper.is-focus) { + border-color: var(--primary-color); + box-shadow: 0 0 0 2px rgba(var(--primary-color), 0.2); +} + +.button-group { + display: flex; width: 100%; + gap: 1rem; +} + +.login-button, .register-button { + flex: 1; + height: 44px; + border-radius: var(--border-radius); + font-size: 1rem; + font-weight: 600; + border: none; transition: all var(--transition-duration) ease; } -.el-button--primary { - height: 40px; +.login-button { + background-color: var(--primary-color); } -.el-button--primary:hover { +.register-button { + background-color: var(--secondary-color); + color: var(--text-color); + border: 1px solid var(--border-color); +} + +.login-button:hover, .register-button:hover { transform: translateY(-2px); - box-shadow: 0 4px 10px rgba(64, 158, 255, 0.4); + box-shadow: var(--box-shadow); } -.el-button:last-child { - margin-left: 0; - margin-top: 10px; - color: var(--text-color-secondary); - border: none; - background: none; +.login-button:hover { + background-color: var(--primary-color-dark); } -.el-button:last-child:hover { +.register-button:hover { + background-color: var(--border-color); +} + +.card-footer { + margin-top: 2rem; + display: flex; + justify-content: center; + align-items: center; + gap: 1rem; + font-size: 0.875rem; +} + +.link-highlight { + color: var(--primary-color); + font-weight: 600; +} + +:deep(.el-link) { + color: var(--text-color-secondary); +} + +:deep(.el-link:hover) { color: var(--primary-color); - background-color: var(--primary-color-light); } \ No newline at end of file diff --git a/biji-qianduan/src/components/RegisterPage.vue b/biji-qianduan/src/components/RegisterPage.vue index fc5612c..e8461fb 100644 --- a/biji-qianduan/src/components/RegisterPage.vue +++ b/biji-qianduan/src/components/RegisterPage.vue @@ -1,28 +1,43 @@ @@ -31,6 +46,7 @@ import { ref } from 'vue'; import { useRouter } from 'vue-router'; import { register } from '../api/CommonApi'; import { ElMessage } from 'element-plus'; +import { User, Lock, CircleCheck } from '@element-plus/icons-vue'; const router = useRouter(); const registerFormRef = ref(null); @@ -84,60 +100,128 @@ const goToHome = () => { display: flex; justify-content: center; align-items: center; - height: 100vh; - background-color: var(--bg-color-secondary); - background-image: linear-gradient(135deg, var(--bg-color) 0%, var(--bg-color-secondary) 100%); + min-height: 100vh; + padding: 2rem; + background: var(--bg-gradient); + background-attachment: fixed; } .register-card { - width: 420px; - padding: 20px 30px; - border-radius: 12px; - background-color: var(--bg-color); + width: 100%; + max-width: 420px; + padding: 2.5rem 2rem; + border-radius: var(--border-radius); + background-color: rgba(255, 255, 255, 0.85); + backdrop-filter: blur(10px); box-shadow: var(--box-shadow-dark); - border: 1px solid var(--border-color); - animation: slideInDown 0.5s ease-out; + border: 1px solid rgba(255, 255, 255, 0.2); + animation: fadeIn 0.5s ease-out; overflow: hidden; } +.dark-theme .register-card { + background-color: rgba(23, 23, 39, 0.85); + border: 1px solid rgba(255, 255, 255, 0.1); +} + .card-header { text-align: center; - font-size: 24px; + margin-bottom: 2.5rem; +} + +.card-header h2 { + margin: 0 0 0.5rem 0; + font-size: 1.75rem; font-weight: 600; color: var(--text-color); - padding-bottom: 20px; - margin-bottom: 20px; - border-bottom: 1px solid var(--border-color-light); +} + +.card-header p { + margin: 0; + color: var(--text-color-secondary); } .el-form-item { - margin-bottom: 25px; + margin-bottom: 1.5rem; } -.el-button { +:deep(.el-form-item__label) { + color: var(--text-color-secondary); + line-height: 1.5; + margin-bottom: 0.5rem; +} + +:deep(.el-input__wrapper) { + border-radius: var(--border-radius); + background-color: var(--bg-color-secondary); + box-shadow: none; + transition: all var(--transition-duration) ease; + border: 1px solid var(--border-color); +} + +:deep(.el-input__wrapper.is-focus) { + border-color: var(--primary-color); + box-shadow: 0 0 0 2px rgba(var(--primary-color), 0.2); +} + +.button-group { + display: flex; width: 100%; + gap: 1rem; +} + +.register-button, .login-button { + flex: 1; + height: 44px; + border-radius: var(--border-radius); + font-size: 1rem; + font-weight: 600; + border: none; transition: all var(--transition-duration) ease; } -.el-button--primary { - height: 40px; +.register-button { + background-color: var(--primary-color); } -.el-button--primary:hover { +.login-button { + background-color: var(--secondary-color); + color: var(--text-color); + border: 1px solid var(--border-color); +} + +.register-button:hover, .login-button:hover { transform: translateY(-2px); - box-shadow: 0 4px 10px rgba(64, 158, 255, 0.4); + box-shadow: var(--box-shadow); } -.el-button:last-child { - margin-left: 0; - margin-top: 10px; - color: var(--text-color-secondary); - border: none; - background: none; +.register-button:hover { + background-color: var(--primary-color-dark); } -.el-button:last-child:hover { +.login-button:hover { + background-color: var(--border-color); +} + +.card-footer { + margin-top: 2rem; + display: flex; + justify-content: center; + align-items: center; + gap: 1rem; + font-size: 0.875rem; +} + +.link-highlight { + color: var(--primary-color); + font-weight: 600; +} + +:deep(.el-link) { + color: var(--text-color-secondary); +} + +:deep(.el-link:hover) { color: var(--primary-color); - background-color: var(--primary-color-light); } \ No newline at end of file From 1491cfc330ac67112f39439e65e6150197f9f2a1 Mon Sep 17 00:00:00 2001 From: ikmkj <1@qq,com> Date: Thu, 31 Jul 2025 23:09:58 +0800 Subject: [PATCH 08/11] =?UTF-8?q?feat(recycle-bin):=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=9B=9E=E6=94=B6=E7=AB=99=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在数据库中添加逻辑删除字段和相关索引- 新增回收站相关实体类和接口 - 实现回收站列表查询、项目恢复、永久删除和清空回收站等功能 - 前端集成回收站接口,支持回收站页面操作 --- .../bijihoudaun/config/MybatisPlusConfig.java | 4 +- .../controller/TrashController.java | 47 +++++++++ .../com/test/bijihoudaun/entity/Grouping.java | 16 ++- .../test/bijihoudaun/entity/MarkdownFile.java | 14 ++- .../test/bijihoudaun/entity/TrashItemVo.java | 26 +++++ .../bijihoudaun/service/TrashService.java | 33 ++++++ .../service/impl/TrashServiceImpl.java | 99 ++++++++++++++++++ .../src/main/resources/application-dev.yml | 4 +- .../src/main/resources/application.yml | 5 + biji-qianduan/src/api/CommonApi.js | 4 +- biji-qianduan/src/components/TrashPage.vue | 4 +- mydatabase.db | Bin 49152 -> 53248 bytes sql/data.sql | 8 +- 13 files changed, 254 insertions(+), 10 deletions(-) create mode 100644 biji-houdaun/src/main/java/com/test/bijihoudaun/controller/TrashController.java create mode 100644 biji-houdaun/src/main/java/com/test/bijihoudaun/entity/TrashItemVo.java create mode 100644 biji-houdaun/src/main/java/com/test/bijihoudaun/service/TrashService.java create mode 100644 biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/TrashServiceImpl.java diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/config/MybatisPlusConfig.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/config/MybatisPlusConfig.java index 3e50436..a55a001 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/config/MybatisPlusConfig.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/config/MybatisPlusConfig.java @@ -3,6 +3,7 @@ package com.test.bijihoudaun.config; import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -10,11 +11,12 @@ import org.springframework.context.annotation.Configuration; public class MybatisPlusConfig { /** - * 添加分页插件 + * 添加分页插件和逻辑删除插件 */ @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + // 分页插件 interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.SQLITE)); return interceptor; } diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/controller/TrashController.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/controller/TrashController.java new file mode 100644 index 0000000..5e53222 --- /dev/null +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/controller/TrashController.java @@ -0,0 +1,47 @@ +package com.test.bijihoudaun.controller; + +import com.test.bijihoudaun.common.response.R; +import com.test.bijihoudaun.entity.TrashItemVo; +import com.test.bijihoudaun.service.TrashService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/api/trash") +@Tag(name = "回收站管理") +public class TrashController { + + @Autowired + private TrashService trashService; + + @GetMapping + @Operation(summary = "获取回收站列表") + public R> getTrashItems() { + return R.success(trashService.getTrashItems()); + } + + @PostMapping("/restore/{type}/{id}") + @Operation(summary = "恢复项目") + public R restoreItem(@PathVariable String type, @PathVariable String id) { + trashService.restoreItem(id, type); + return R.success(); + } + + @DeleteMapping("/permanently/{type}/{id}") + @Operation(summary = "永久删除项目") + public R permanentlyDeleteItem(@PathVariable String type, @PathVariable String id) { + trashService.permanentlyDeleteItem(id, type); + return R.success(); + } + + @DeleteMapping("/clean") + @Operation(summary = "清空回收站") + public R cleanTrash() { + trashService.cleanTrash(); + return R.success(); + } +} \ No newline at end of file diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/Grouping.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/Grouping.java index eb464e7..f3260ff 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/Grouping.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/Grouping.java @@ -3,15 +3,19 @@ package com.test.bijihoudaun.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.io.Serializable; +import java.util.Date; + @Data @Schema(name = "分组实体") @TableName("grouping") -public class Grouping { +public class Grouping implements Serializable { @Schema(description = "分组id",implementation = Long.class) @TableId(type = IdType.ASSIGN_ID) @JsonFormat(shape = JsonFormat.Shape.STRING) // 仅作用于此字段 @@ -24,4 +28,14 @@ public class Grouping { @Schema(description = "分组名称",implementation = String.class) private String grouping; + + @Schema(description = "是否删除 0-未删除 1-已删除", implementation = Integer.class) + @TableLogic + private Integer isDeleted; + + @Schema(description = "删除时间", implementation = Date.class) + private Date deletedAt; + + @Schema(description = "删除人ID", implementation = Long.class) + private Long deletedBy; } diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/MarkdownFile.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/MarkdownFile.java index aa78aad..6c6cfd6 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/MarkdownFile.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/MarkdownFile.java @@ -3,17 +3,19 @@ package com.test.bijihoudaun.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.io.Serializable; import java.util.Date; @Data @Schema(name = "文本实体") @TableName("markdown_file") -public class MarkdownFile { +public class MarkdownFile implements Serializable { @Schema(description = "文本id",implementation = Long.class) @TableId(type = IdType.AUTO) @JsonFormat(shape = JsonFormat.Shape.STRING) // 仅作用于此字段 @@ -33,4 +35,14 @@ public class MarkdownFile { private Date createdAt; @Schema(description = "更新时间",implementation = Date.class) private Date updatedAt; + + @Schema(description = "是否删除 0-未删除 1-已删除", implementation = Integer.class) + @TableLogic + private Integer isDeleted; + + @Schema(description = "删除时间", implementation = Date.class) + private Date deletedAt; + + @Schema(description = "删除人ID", implementation = Long.class) + private Long deletedBy; } diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/TrashItemVo.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/TrashItemVo.java new file mode 100644 index 0000000..4e8368e --- /dev/null +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/TrashItemVo.java @@ -0,0 +1,26 @@ +package com.test.bijihoudaun.entity; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +@Data +@Schema(name = "回收站项目视图对象") +public class TrashItemVo { + + @Schema(description = "项目ID") + private String id; + + @Schema(description = "项目名称(笔记标题或分组名称)") + private String name; + + @Schema(description = "项目类型(note 或 group)") + private String type; + + @Schema(description = "删除时间") + private Date deletedAt; + + @Schema(description = "删除者ID") + private String deletedBy; +} \ No newline at end of file diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/service/TrashService.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/service/TrashService.java new file mode 100644 index 0000000..8fc004c --- /dev/null +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/service/TrashService.java @@ -0,0 +1,33 @@ +package com.test.bijihoudaun.service; + +import com.test.bijihoudaun.entity.TrashItemVo; + +import java.util.List; + +public interface TrashService { + + /** + * 获取回收站中的所有项目 + * @return 回收站项目列表 + */ + List getTrashItems(); + + /** + * 恢复指定的回收站项目 + * @param id 项目ID + * @param type 项目类型 ("note" 或 "group") + */ + void restoreItem(String id, String type); + + /** + * 永久删除指定的回收站项目 + * @param id 项目ID + * @param type 项目类型 ("note" 或 "group") + */ + void permanentlyDeleteItem(String id, String type); + + /** + * 清空回收站 + */ + void cleanTrash(); +} \ No newline at end of file diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/TrashServiceImpl.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/TrashServiceImpl.java new file mode 100644 index 0000000..1432fc1 --- /dev/null +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/TrashServiceImpl.java @@ -0,0 +1,99 @@ +package com.test.bijihoudaun.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.test.bijihoudaun.entity.Grouping; +import com.test.bijihoudaun.entity.MarkdownFile; +import com.test.bijihoudaun.entity.TrashItemVo; +import com.test.bijihoudaun.mapper.GroupingMapper; +import com.test.bijihoudaun.mapper.MarkdownFileMapper; +import com.test.bijihoudaun.service.TrashService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Service +public class TrashServiceImpl implements TrashService { + + @Autowired + private MarkdownFileMapper markdownFileMapper; + + @Autowired + private GroupingMapper groupingMapper; + + @Override + public List getTrashItems() { + // 查询已删除的笔记 + List deletedNotes = markdownFileMapper.selectList(new QueryWrapper().eq("is_deleted", 1)) + .stream() + .map(file -> { + TrashItemVo vo = new TrashItemVo(); + vo.setId(String.valueOf(file.getId())); + vo.setName(file.getTitle()); + vo.setType("note"); + vo.setDeletedAt(file.getDeletedAt()); + vo.setDeletedBy(String.valueOf(file.getDeletedBy())); + return vo; + }) + .collect(Collectors.toList()); + + // 查询已删除的分组 + List deletedGroups = groupingMapper.selectList(new QueryWrapper().eq("is_deleted", 1)) + .stream() + .map(group -> { + TrashItemVo vo = new TrashItemVo(); + vo.setId(String.valueOf(group.getId())); + vo.setName(group.getGrouping()); + vo.setType("group"); + vo.setDeletedAt(group.getDeletedAt()); + vo.setDeletedBy(String.valueOf(group.getDeletedBy())); + return vo; + }) + .collect(Collectors.toList()); + + // 合并并返回 + return Stream.concat(deletedNotes.stream(), deletedGroups.stream()).collect(Collectors.toList()); + } + + @Override + @Transactional + public void restoreItem(String id, String type) { + if ("note".equals(type)) { + MarkdownFile file = new MarkdownFile(); + file.setId(Long.parseLong(id)); + file.setIsDeleted(0); + file.setDeletedAt(null); + file.setDeletedBy(null); + markdownFileMapper.updateById(file); + } else if ("group".equals(type)) { + Grouping group = new Grouping(); + group.setId(Long.parseLong(id)); + group.setIsDeleted(0); + group.setDeletedAt(null); + group.setDeletedBy(null); + groupingMapper.updateById(group); + } + } + + @Override + @Transactional + public void permanentlyDeleteItem(String id, String type) { + if ("note".equals(type)) { + markdownFileMapper.deleteById(Long.parseLong(id)); + } else if ("group".equals(type)) { + // 删除分组时,也删除其下的所有笔记 + groupingMapper.deleteById(Long.parseLong(id)); + markdownFileMapper.delete(new QueryWrapper().eq("grouping_id", id)); + } + } + + @Override + @Transactional + public void cleanTrash() { + markdownFileMapper.delete(new QueryWrapper().eq("is_deleted", 1)); + groupingMapper.delete(new QueryWrapper().eq("is_deleted", 1)); + } +} \ No newline at end of file diff --git a/biji-houdaun/src/main/resources/application-dev.yml b/biji-houdaun/src/main/resources/application-dev.yml index 9f0f341..16c8b63 100644 --- a/biji-houdaun/src/main/resources/application-dev.yml +++ b/biji-houdaun/src/main/resources/application-dev.yml @@ -1,8 +1,8 @@ spring: datasource: driver-class-name: org.sqlite.JDBC -# url: jdbc:sqlite:C:\it\houtaigunli\biji\mydatabase.db - url: jdbc:sqlite:C:\KAIFA\2\mydatabase.db + url: jdbc:sqlite:C:\it\houtaigunli\biji\mydatabase.db +# url: jdbc:sqlite:C:\KAIFA\2\mydatabase.db jpa: hibernate: ddl-auto: none diff --git a/biji-houdaun/src/main/resources/application.yml b/biji-houdaun/src/main/resources/application.yml index e85a973..0d94671 100644 --- a/biji-houdaun/src/main/resources/application.yml +++ b/biji-houdaun/src/main/resources/application.yml @@ -29,6 +29,11 @@ mybatis-plus: mapper-locations: classpath:mapper/*.xml configuration: map-underscore-to-camel-case: true + global-config: + db-config: + logic-delete-field: isDeleted # 全局逻辑删除的实体字段名 + logic-delete-value: 1 # 逻辑已删除值(默认为 1) + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) # JWT 配置 jwt: diff --git a/biji-qianduan/src/api/CommonApi.js b/biji-qianduan/src/api/CommonApi.js index cf4d372..f4eaf91 100644 --- a/biji-qianduan/src/api/CommonApi.js +++ b/biji-qianduan/src/api/CommonApi.js @@ -120,10 +120,10 @@ export const MD5 = (data, file) => { export const getTrash = () => axiosApi.get('/api/trash'); // 恢复项目 -export const restoreTrashItem = (id) => axiosApi.post(`/api/trash/restore/${id}`); +export const restoreTrashItem = (id, type) => axiosApi.post(`/api/trash/restore/${type}/${id}`); // 彻底删除 -export const permanentlyDeleteItem = (id) => axiosApi.delete(`/api/trash/permanently/${id}`); +export const permanentlyDeleteItem = (id, type) => axiosApi.delete(`/api/trash/permanently/${type}/${id}`); // 清空回收站 export const cleanTrash = () => axiosApi.delete('/api/trash/clean'); diff --git a/biji-qianduan/src/components/TrashPage.vue b/biji-qianduan/src/components/TrashPage.vue index 268ed4c..c7d43d4 100644 --- a/biji-qianduan/src/components/TrashPage.vue +++ b/biji-qianduan/src/components/TrashPage.vue @@ -48,7 +48,7 @@ const fetchTrashItems = async () => { const handleRestore = async (item) => { try { - await restoreTrashItem(item.id); + await restoreTrashItem(item.id, item.type); ElMessage.success('恢复成功'); fetchTrashItems(); } catch (error) { @@ -63,7 +63,7 @@ const handleDeletePermanently = async (item) => { type: 'warning', }); try { - await permanentlyDeleteItem(item.id); + await permanentlyDeleteItem(item.id, item.type); ElMessage.success('已永久删除'); fetchTrashItems(); } catch (error) { diff --git a/mydatabase.db b/mydatabase.db index 2b7c05d2ffd0ea25e145be09b2a220b723bb69cb..99eb9391f92f44de0011766fb49c15d0eb75e782 100644 GIT binary patch delta 685 zcmZo@U~X8zJV9D;3IhWJFA#GBF*6VwPSi1$ox-3OoWRR|l!2X%gMoK7pD}+I_XS=< z&XsH&Y#bXKdsw-et;E^I)zul>j5lX;L@`e8=VS}dERIh}%}FguO;J+t^b2uycMVc- zadmSH^$Afh(Bb7$P*8%($0wF3DY!U>xQ2N8x}wS?Rl+s%a%pm{WPGx*@c|=OW33pw zxU4K=v+v|uu5J${D%myp7ndp%qx!~1WyZ}HxJ^VjnAoHk*y7lvHa7CHiCQ(SUvhZG zhn5Mz&|#EURcB@8U|^VRw9Ph6T+Hfhxrs&DDf#7j@oAYksVsX{Ol6n^7+8U_ zjQpR0BvAY3&5RRX@XPQ3?b-0S;&Y^NqXtSlJmQ8G#~C*DiZGeH}9|3y=?1F|GaCj6Pmw zDEImDiO;$kHYKn-urdLy;@vE;-~<1}0G3GtEIcd>It=_9`74<|GU!Znlo4+Q1`O0$ zK<~?|cBw+V->9&jNvswqH+|6?NYKcuZq$az@jDmti0U;hobh2_cgqAuZU!c4X=zA+ fdMPN2y250DLCq;C8OX}Y2@L9E`c{h>CkOxloBO~{ delta 663 zcmb7COK4L;6utBQ?1(KI)T*siv2ml-Z8zdhgtXWyrB<<_2(FUY7)d1L z`LyXm@PmJeX`OZ@8fYP#P{^hWL2w~WD|As%TzjKLH*TEa%!k9=x#ymnc*rLbd?DaY z1Ar6ZKyV1t+TRyU!@)B{x>^NUiGlulTOZ9j>iQuirp2{5bGyFCT580QeUS)B%gm6@ z5?R;wI)YHLk}tJn#3TEHL6QpDOwHMMH6I7eN|ssOaoFn=pdaW0^z%J1VI}t%-Kj^j zTOV@M1)=~K2n0mY&R06U>7%LggSqdu=>n)g%y2d=itN-}ne$vnqWE~TMa*|2p|Gn? z<76umD4_cNr!i8sa?GXE67bXpTBEDfrZ#i;-k|L}6+R+O3{Q@aT)B2Rc46$&sPKOG zkv7f+^fRJcJfO*XBR4MzT)i}{`^1X9O%T)`9G!6=>~|Dar6_d(`Cx&kLE;$d3w%h=J|K% znTrCLO5^^kwOcpW=ifO*0sLgG^z3W#4X+7!Q5rLu#%x~Wo9FfCRwJ9h=T5)cSj=sd z?*Yh}F#$YEG#Y(7B%ja;vRVs_6gKG{m!NP`2S~$G2eye Date: Thu, 31 Jul 2025 23:58:13 +0800 Subject: [PATCH 09/11] =?UTF-8?q?feattrash:=20=E4=BC=98=E5=8C=96=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8A=9F=E8=83=BD=E5=92=8C=E5=9B=9E=E6=94=B6=E7=AB=99?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 Markdown 文件和分组的删除逻辑,使用软删除方式 - 更新回收站相关接口和页面展示 -优化前端保存逻辑,支持新建文件和更新文件 - 调整后端 API 接口,使用更合适的 HTTP 方法 --- .../controller/MarkdownController.java | 7 ++- .../test/bijihoudaun/entity/TrashItemVo.java | 2 +- .../bijihoudaun/mapper/GroupingMapper.java | 6 +++ .../mapper/MarkdownFileMapper.java | 6 ++- .../service/impl/GroupingServiceImpl.java | 17 ++++--- .../service/impl/MarkdownFileServiceImpl.java | 7 ++- .../service/impl/TrashServiceImpl.java | 12 ++--- biji-qianduan/src/api/CommonApi.js | 2 +- biji-qianduan/src/components/HomePage.vue | 42 +++++++++++------- mydatabase.db | Bin 53248 -> 53248 bytes 10 files changed, 67 insertions(+), 34 deletions(-) diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/controller/MarkdownController.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/controller/MarkdownController.java index fc73057..cde5258 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/controller/MarkdownController.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/controller/MarkdownController.java @@ -61,10 +61,9 @@ public class MarkdownController { @Parameters({ @Parameter(name = "id", description = "Markdown文件ID", required = true), }) - @PostMapping("/delete") - public R deleteMarkdown(String id) { - long l = Long.parseLong(id); - if (markdownFileService.deleteMarkdownFile(l)) { + @DeleteMapping("/{id}") + public R deleteMarkdown(@PathVariable Long id) { + if (markdownFileService.deleteMarkdownFile(id)) { return R.success(); } return R.fail(); diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/TrashItemVo.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/TrashItemVo.java index 4e8368e..91c8ad7 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/TrashItemVo.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/TrashItemVo.java @@ -13,7 +13,7 @@ public class TrashItemVo { private String id; @Schema(description = "项目名称(笔记标题或分组名称)") - private String name; + private String title; @Schema(description = "项目类型(note 或 group)") private String type; diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/GroupingMapper.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/GroupingMapper.java index 48ecb89..ee642fe 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/GroupingMapper.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/GroupingMapper.java @@ -3,7 +3,13 @@ package com.test.bijihoudaun.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.test.bijihoudaun.entity.Grouping; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; + +import java.util.List; @Mapper public interface GroupingMapper extends BaseMapper { + + @Select("SELECT * FROM grouping WHERE is_deleted = 1") + List selectDeleted(); } diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/MarkdownFileMapper.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/MarkdownFileMapper.java index d7f8483..32efec9 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/MarkdownFileMapper.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/MarkdownFileMapper.java @@ -15,6 +15,7 @@ public interface MarkdownFileMapper extends BaseMapper { @Select("SELECT mf.*, g.grouping as groupingName " + "FROM markdown_file mf " + "LEFT JOIN grouping g ON mf.grouping_id = g.id " + + "WHERE mf.is_deleted = 0 " + "ORDER BY mf.updated_at DESC " + "LIMIT #{limit}") List selectRecentWithGrouping(@Param("limit") int limit); @@ -22,7 +23,10 @@ public interface MarkdownFileMapper extends BaseMapper { @Select("SELECT mf.*, g.grouping as groupingName " + "FROM markdown_file mf " + "LEFT JOIN grouping g ON mf.grouping_id = g.id " + - "WHERE mf.grouping_id = #{groupingId} " + + "WHERE mf.grouping_id = #{groupingId} AND mf.is_deleted = 0 " + "ORDER BY mf.updated_at DESC") List selectByGroupingIdWithGrouping(@Param("groupingId") String groupingId); + + @Select("SELECT * FROM markdown_file WHERE is_deleted = 1") + List selectDeleted(); } diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/GroupingServiceImpl.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/GroupingServiceImpl.java index e52f470..c42357f 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/GroupingServiceImpl.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/GroupingServiceImpl.java @@ -54,12 +54,19 @@ public class GroupingServiceImpl @Override @Transactional public void deleteGrouping(Long id) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.eq(MarkdownFile::getGroupingId, id) - .set(MarkdownFile::getGroupingId, 999L); - markdownFileMapper.update(null, updateWrapper); + // 1. 使用 LambdaUpdateWrapper 软删除分组本身,确保 isDeleted 和 deletedAt 都被更新 + LambdaUpdateWrapper groupingUpdateWrapper = new LambdaUpdateWrapper<>(); + groupingUpdateWrapper.eq(Grouping::getId, id) + .set(Grouping::getIsDeleted, 1) + .set(Grouping::getDeletedAt, new java.util.Date()); + this.update(groupingUpdateWrapper); - this.removeById(id); + // 2. 将该分组下的所有笔记也一并软删除 + LambdaUpdateWrapper markdownFileUpdateWrapper = new LambdaUpdateWrapper<>(); + markdownFileUpdateWrapper.eq(MarkdownFile::getGroupingId, id) + .set(MarkdownFile::getIsDeleted, 1) + .set(MarkdownFile::getDeletedAt, new java.util.Date()); + markdownFileMapper.update(null, markdownFileUpdateWrapper); } @Override diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/MarkdownFileServiceImpl.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/MarkdownFileServiceImpl.java index 54d2b4c..8e2e1ec 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/MarkdownFileServiceImpl.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/MarkdownFileServiceImpl.java @@ -1,6 +1,7 @@ package com.test.bijihoudaun.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.test.bijihoudaun.entity.MarkdownFile; import com.test.bijihoudaun.entity.MarkdownFileVO; @@ -52,7 +53,11 @@ public class MarkdownFileServiceImpl @Override public boolean deleteMarkdownFile(Long id) { - return this.removeById(id); + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(MarkdownFile::getId, id) + .set(MarkdownFile::getIsDeleted, 1) + .set(MarkdownFile::getDeletedAt, new Date()); + return this.update(updateWrapper); } @Override diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/TrashServiceImpl.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/TrashServiceImpl.java index 1432fc1..06ef803 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/TrashServiceImpl.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/TrashServiceImpl.java @@ -26,13 +26,13 @@ public class TrashServiceImpl implements TrashService { @Override public List getTrashItems() { - // 查询已删除的笔记 - List deletedNotes = markdownFileMapper.selectList(new QueryWrapper().eq("is_deleted", 1)) + // 调用自定义的Mapper方法查询已删除的笔记,绕过全局逻辑删除过滤器 + List deletedNotes = markdownFileMapper.selectDeleted() .stream() .map(file -> { TrashItemVo vo = new TrashItemVo(); vo.setId(String.valueOf(file.getId())); - vo.setName(file.getTitle()); + vo.setTitle(file.getTitle()); vo.setType("note"); vo.setDeletedAt(file.getDeletedAt()); vo.setDeletedBy(String.valueOf(file.getDeletedBy())); @@ -40,13 +40,13 @@ public class TrashServiceImpl implements TrashService { }) .collect(Collectors.toList()); - // 查询已删除的分组 - List deletedGroups = groupingMapper.selectList(new QueryWrapper().eq("is_deleted", 1)) + // 调用自定义的Mapper方法查询已删除的分组 + List deletedGroups = groupingMapper.selectDeleted() .stream() .map(group -> { TrashItemVo vo = new TrashItemVo(); vo.setId(String.valueOf(group.getId())); - vo.setName(group.getGrouping()); + vo.setTitle(group.getGrouping()); vo.setType("group"); vo.setDeletedAt(group.getDeletedAt()); vo.setDeletedBy(String.valueOf(group.getDeletedBy())); diff --git a/biji-qianduan/src/api/CommonApi.js b/biji-qianduan/src/api/CommonApi.js index f4eaf91..3340eb7 100644 --- a/biji-qianduan/src/api/CommonApi.js +++ b/biji-qianduan/src/api/CommonApi.js @@ -40,7 +40,7 @@ export const uploadImage = (file) => { } // 删除Markdown文件 -export const deleteMarkdown = (id) => axiosApi.post(`/api/markdown/delete?id=${id}`); +export const deleteMarkdown = (id) => axiosApi.delete(`/api/markdown/${id}`); // 根据分组ID获取Markdown文件列表 export const markdownList = (groupingId) => axiosApi.get(`/api/markdown/grouping/${groupingId}`); diff --git a/biji-qianduan/src/components/HomePage.vue b/biji-qianduan/src/components/HomePage.vue index 29985ed..8d973a6 100644 --- a/biji-qianduan/src/components/HomePage.vue +++ b/biji-qianduan/src/components/HomePage.vue @@ -548,29 +548,41 @@ const debouncedSave = (value) => { const handleSave = async (content) => { saveStatus.value = '正在保存...'; try { - const newImageUrls = extractImageUrls(content); - const deletedImages = originalImages.value.filter(url => !newImageUrls.includes(url)); + // 构造一个干净的、只包含必要字段的 payload + const payload = { + id: editData.value.id, // 可能是 null,用于创建 + title: editData.value.title, + groupingId: editData.value.groupingId, + content: content, + fileName: editData.value.fileName || `${editData.value.title}.md`, + }; - if (deletedImages.length > 0) { - await deleteImages({ imageUrls: deletedImages }); + // 调用后端接口 + const response = await updateMarkdown(payload); + + // 使用后端返回的完整、最新的数据更新前端状态 + // 这对于新创建的笔记至关重要,因为它会获得一个新的 ID + editData.value = response.data; + + // 如果当前正在预览这个文件,也更新 selectedFile + if (selectedFile.value && (!selectedFile.value.id || selectedFile.value.id === response.data.id)) { + selectedFile.value = response.data; } - originalImages.value = newImageUrls; - - const payload = { - ...editData.value, - content: content, - }; - const response = await updateMarkdown(payload); - editData.value = response.data; - selectedFile.value = editData.value; saveStatus.value = '已保存'; ElMessage.success('保存成功'); - await fetchGroupings(); + + // 刷新文件列表以反映更改(例如,新文件出现) await fetchMarkdownFiles(); + // 如果当前在某个分类下,也刷新该分类的列表 + if (activeMenu.value.startsWith('group-')) { + const groupId = activeMenu.value.split('-'); + await selectFile({ id: groupId, grouping: currentGroupName.value }); + } + } catch (error) { saveStatus.value = '保存失败'; - ElMessage.error('保存失败: ' + error.message); + ElMessage.error('保存失败: ' + (error.response?.data?.message || error.message)); } }; diff --git a/mydatabase.db b/mydatabase.db index 99eb9391f92f44de0011766fb49c15d0eb75e782..69dd3fd9b450be5ec72b42be09462ae2f18c7d0d 100644 GIT binary patch delta 75 zcmV-R0JQ&rpaX!Q1CSd5nUNer0hzI2rXL0r00v$L6tfW!2nG~Dg0G~*sPKf401E&C hA0;OR1qlU{E+#Mr0hnPl405wxCM}r(3A2p9bP!8l72f~= delta 68 zcmV-K0K5NypaX!Q1CSd5l#v`m0hF;|rXL0x00v$L8nY1)4h9rDg0G~*sPKf401E&C aA0;OR1qc9>C?+toUM4M>0SL2 Date: Fri, 1 Aug 2025 00:14:34 +0800 Subject: [PATCH 10/11] =?UTF-8?q?feat(trash):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=9B=9E=E6=94=B6=E7=AB=99=E7=89=A9=E5=93=81=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E5=92=8C=E6=B0=B8=E4=B9=85=E5=88=A0=E9=99=A4=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 GroupingMapper 和 MarkdownFileMapper 中添加物理删除和恢复的 SQL 操作 - 优化 HomePage组件中的删除操作,删除后刷新分组树并回到主视图 - 在 TrashServiceImpl 中实现物品恢复和永久删除的业务逻辑- 为 TrashItemVo 中的 deletedAt 字段添加 JSON 格式化注解 --- .../test/bijihoudaun/entity/TrashItemVo.java | 2 ++ .../bijihoudaun/mapper/GroupingMapper.java | 11 +++++++++ .../mapper/MarkdownFileMapper.java | 12 +++++++++ .../service/impl/TrashServiceImpl.java | 23 ++++++------------ biji-qianduan/src/components/HomePage.vue | 18 +++++--------- mydatabase.db | Bin 53248 -> 53248 bytes 6 files changed, 38 insertions(+), 28 deletions(-) diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/TrashItemVo.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/TrashItemVo.java index 91c8ad7..425f408 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/TrashItemVo.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/entity/TrashItemVo.java @@ -1,5 +1,6 @@ package com.test.bijihoudaun.entity; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -19,6 +20,7 @@ public class TrashItemVo { private String type; @Schema(description = "删除时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date deletedAt; @Schema(description = "删除者ID") diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/GroupingMapper.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/GroupingMapper.java index ee642fe..a1a6837 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/GroupingMapper.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/GroupingMapper.java @@ -2,8 +2,13 @@ package com.test.bijihoudaun.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.test.bijihoudaun.entity.Grouping; +import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; import java.util.List; @@ -12,4 +17,10 @@ public interface GroupingMapper extends BaseMapper { @Select("SELECT * FROM grouping WHERE is_deleted = 1") List selectDeleted(); + + @Delete("DELETE FROM grouping WHERE id = #{id}") + void physicalDeleteById(@Param("id") Long id); + + @Update("UPDATE grouping SET is_deleted = 0, deleted_at = NULL, deleted_by = NULL WHERE id = #{id}") + void restoreById(@Param("id") Long id); } diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/MarkdownFileMapper.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/MarkdownFileMapper.java index 32efec9..0c86114 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/MarkdownFileMapper.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/mapper/MarkdownFileMapper.java @@ -9,6 +9,9 @@ import org.apache.ibatis.annotations.Select; import java.util.List; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Update; + @Mapper public interface MarkdownFileMapper extends BaseMapper { @@ -29,4 +32,13 @@ public interface MarkdownFileMapper extends BaseMapper { @Select("SELECT * FROM markdown_file WHERE is_deleted = 1") List selectDeleted(); + + @Delete("DELETE FROM markdown_file WHERE id = #{id}") + void physicalDeleteById(@Param("id") Long id); + + @Delete("DELETE FROM markdown_file WHERE grouping_id = #{groupingId}") + void physicalDeleteByGroupingId(@Param("groupingId") Long groupingId); + + @Update("UPDATE markdown_file SET is_deleted = 0, deleted_at = NULL, deleted_by = NULL WHERE id = #{id}") + void restoreById(@Param("id") Long id); } diff --git a/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/TrashServiceImpl.java b/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/TrashServiceImpl.java index 06ef803..2abb930 100644 --- a/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/TrashServiceImpl.java +++ b/biji-houdaun/src/main/java/com/test/bijihoudaun/service/impl/TrashServiceImpl.java @@ -1,6 +1,7 @@ package com.test.bijihoudaun.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.test.bijihoudaun.entity.Grouping; import com.test.bijihoudaun.entity.MarkdownFile; import com.test.bijihoudaun.entity.TrashItemVo; @@ -62,19 +63,9 @@ public class TrashServiceImpl implements TrashService { @Transactional public void restoreItem(String id, String type) { if ("note".equals(type)) { - MarkdownFile file = new MarkdownFile(); - file.setId(Long.parseLong(id)); - file.setIsDeleted(0); - file.setDeletedAt(null); - file.setDeletedBy(null); - markdownFileMapper.updateById(file); + markdownFileMapper.restoreById(Long.parseLong(id)); } else if ("group".equals(type)) { - Grouping group = new Grouping(); - group.setId(Long.parseLong(id)); - group.setIsDeleted(0); - group.setDeletedAt(null); - group.setDeletedBy(null); - groupingMapper.updateById(group); + groupingMapper.restoreById(Long.parseLong(id)); } } @@ -82,11 +73,11 @@ public class TrashServiceImpl implements TrashService { @Transactional public void permanentlyDeleteItem(String id, String type) { if ("note".equals(type)) { - markdownFileMapper.deleteById(Long.parseLong(id)); + markdownFileMapper.physicalDeleteById(Long.parseLong(id)); } else if ("group".equals(type)) { - // 删除分组时,也删除其下的所有笔记 - groupingMapper.deleteById(Long.parseLong(id)); - markdownFileMapper.delete(new QueryWrapper().eq("grouping_id", id)); + // 永久删除分组时,也永久删除其下的所有笔记 + groupingMapper.physicalDeleteById(Long.parseLong(id)); + markdownFileMapper.physicalDeleteByGroupingId(Long.parseLong(id)); } } diff --git a/biji-qianduan/src/components/HomePage.vue b/biji-qianduan/src/components/HomePage.vue index 8d973a6..89a889a 100644 --- a/biji-qianduan/src/components/HomePage.vue +++ b/biji-qianduan/src/components/HomePage.vue @@ -639,12 +639,9 @@ const handleDeleteGroup = (group) => { try { await apiDeleteGrouping(group.id); ElMessage.success('分类已删除'); + // 删除分类后,刷新分组树并回到主视图 await fetchGroupings(); - await fetchMarkdownFiles(); - if (activeMenu.value.startsWith('group-') && activeMenu.value.endsWith(group.id)) { - activeMenu.value = 'all'; - groupMarkdownFiles.value = markdownFiles.value; - } + await resetToHomeView(); } catch (error) { ElMessage.error('删除分类失败: ' + error.message); } @@ -666,13 +663,10 @@ const deleteNote = (file) => { try { await deleteMarkdown(file.id); ElMessage.success('笔记已删除'); - selectedFile.value = null; - await fetchMarkdownFiles(); - // Optionally, refresh the current group's file list - if (activeMenu.value.startsWith('group-')) { - const groupId = activeMenu.value.split('-'); - await selectFile({ id: groupId }); - } + selectedFile.value = null; // 关闭预览 + // 刷新分组和主视图 + await fetchGroupings(); + await resetToHomeView(); } catch (error) { ElMessage.error('删除笔记失败: ' + error.message); } diff --git a/mydatabase.db b/mydatabase.db index 69dd3fd9b450be5ec72b42be09462ae2f18c7d0d..2c30f1861266b7ee04cb52c9a3612b4fa70b2423 100644 GIT binary patch delta 104 zcmV-u0GI!OpaX!Q1CSd5oRJ(u0i3a5rXL0x00v$L8nY1)3kDZT!>BrfucX7M@Pv>6 z3jhHhB_{<12mq5PCNQ&JCZmZD53v9P04x9xc>?hOEC4K#K^(IzuwM@W2$PJzB?JHf K08g{Eze^BfvL0Um delta 108 zcmV-y0F(cKpaX!Q1CSd5nUNer0hzI2rXL0r00v$L6tfW!2nG~Dg0G~*sPKf401E&C zA0;OR1qlU{E+#Mr0hnPl405wxCZmZD0000404x9xu@89y@c=B5K^(IzuwM@W36qS! OB?Lu+p_sF^ze^B}EFawf From 9c232c1586097518bf13c26ea4336fb8a8da0eda Mon Sep 17 00:00:00 2001 From: ikmkj <1@qq,com> Date: Fri, 1 Aug 2025 00:15:19 +0800 Subject: [PATCH 11/11] =?UTF-8?q?docs(development=5Fplan):=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=BC=80=E5=8F=91=E8=AE=A1=E5=88=92=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 补充了后端接口返回数据结构的改动说明 - 更新了前端页面的数据显示逻辑 - 添加了关于系统表和注册码功能的建议 --- doc/development_plan.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/development_plan.md b/doc/development_plan.md index 7f7be91..e53bfcc 100644 --- a/doc/development_plan.md +++ b/doc/development_plan.md @@ -101,3 +101,8 @@ - 全面更新了 `MarkdownFileService` 和 `MarkdownController`,将 `/api/markdown/recent` 和 `/api/markdown/grouping/{groupingId}` 两个接口的返回数据统一升级为包含分类名的 `MarkdownFileVO` 对象列表。 - **前端**: - 修改了 `HomePage.vue` 中的笔记卡片模板,使其直接从每个笔记对象中获取并显示 `groupingName` 属性,取代了之前错误的全局变量方案。 + + +~~~ +能不能设计一个表,叫做系统表,设置一个值,只有登录的用户能控制注册按钮关闭和打开,并且注册需要一个注册码,只有已经登录过的用户才能生成一个注册码,注册码有效期只有一天。只有用户注册就把注册码和注册码过期时间从数据表中删除了,若是用户注册填的注册码过期了,就把注册码和注册码过期时间从数据表中删除。 +~~~ \ No newline at end of file