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 7bc80c7..32cbdb3 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 @@ -8,7 +8,6 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -33,12 +32,12 @@ public class MarkdownController { @Parameter(name = "id", description = "文件ID", required = true) }) @GetMapping("/{id}") - public ResponseEntity getMarkdownContent(@PathVariable Long id) { + public R getMarkdownContent(@PathVariable Long id) { MarkdownFile file = markdownFileService.getMarkdownById(id); if (file != null) { - return ResponseEntity.ok(file.getContent()); + return R.success(file.getContent()); } - return ResponseEntity.notFound().build(); + return R.fail(); } @Operation(summary = "创建markdown文件") @@ -49,7 +48,7 @@ public class MarkdownController { @Parameter(name = "content", description = "内容",required = true) }) @PostMapping - public ResponseEntity createMarkdown( + public R createMarkdown( @RequestParam Long groupingId, @RequestParam String title, @RequestParam String fileName, @@ -58,7 +57,7 @@ public class MarkdownController { MarkdownFile file = markdownFileService.createMarkdownFile( groupingId, title, fileName, content); - return ResponseEntity.ok(file); + return R.success(file); } @Operation(summary = "更新Markdown文件") @@ -67,39 +66,38 @@ public class MarkdownController { @Parameter(name = "content", description = "Markdown文件内容", required = true) }) @PostMapping("/{id}") - public ResponseEntity updateMarkdown( + public R updateMarkdown( @PathVariable Long id, @RequestBody String content) { MarkdownFile file = markdownFileService.updateMarkdownContent(id, content); if (file != null) { - return ResponseEntity.ok(file); + return R.success(file); } - return ResponseEntity.notFound().build(); + return R.fail(); } @Operation(summary = "获取所有Markdown文件") @GetMapping - public ResponseEntity> getAllMarkdownFiles() { - // 固定用户ID=1,因为是个人笔记 + public R> getAllMarkdownFiles() { List files = markdownFileService.getAllMarkdownFiles(); - return ResponseEntity.ok(files); + return R.success(files); } @Operation(summary = "删除Markdown文件") @DeleteMapping("/{id}") - public ResponseEntity deleteMarkdown(@PathVariable Long id) { + public R deleteMarkdown(@PathVariable Long id) { if (markdownFileService.deleteMarkdownFile(id)) { - return ResponseEntity.noContent().build(); + return R.success(); } - return ResponseEntity.notFound().build(); + return R.fail(); } @Operation(summary = "根据分组ID获取Markdown文件") @GetMapping("/grouping/{groupingId}") - public ResponseEntity> getFilesByGroupingId(@PathVariable String groupingId) { + public R> getFilesByGroupingId(@PathVariable String groupingId) { List files = markdownFileService.getFilesByGroupingId(groupingId); - return ResponseEntity.ok(files); + return R.success(files); } } 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 d5f3759..04905c4 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 @@ -18,8 +18,6 @@ public class MarkdownFile { private Long id; @Schema(description = "分组表id",implementation = Long.class) private Long groupingId; - @Schema(description = "用户ID",implementation = Long.class) - private Long userId; @Schema(description = "文本标题",implementation = String.class) private String title; 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 2a10849..0ce1431 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 @@ -11,7 +11,6 @@ import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.time.LocalDateTime; import java.util.Date; import java.util.List; diff --git a/biji-houdaun/src/main/resources/application.yml b/biji-houdaun/src/main/resources/application.yml index 4aff118..fb6bef5 100644 --- a/biji-houdaun/src/main/resources/application.yml +++ b/biji-houdaun/src/main/resources/application.yml @@ -13,7 +13,7 @@ file: #?? server: - port: 8083 + port: 8084 ## Snowflake ID????? diff --git a/biji-qianduan/src/components/HomePage.vue b/biji-qianduan/src/components/HomePage.vue index 6fe8594..46c9a8f 100644 --- a/biji-qianduan/src/components/HomePage.vue +++ b/biji-qianduan/src/components/HomePage.vue @@ -2,22 +2,25 @@
- -
+ +
+
+

{{ group.grouping }}

+
    +
  • + {{ file.title }} +
  • +
+
+
+

{{ selectedFile.title }}

@@ -79,6 +94,7 @@ import { ref, onMounted } from 'vue'; import axios from 'axios'; import { ElMessage } from 'element-plus'; +import { Expand } from '@element-plus/icons-vue'; import MarkdownEditor from './MarkdownEditor.vue'; import VMdPreview from '@kangc/v-md-editor/lib/preview'; import '@kangc/v-md-editor/lib/style/preview.css'; @@ -90,10 +106,11 @@ VMdPreview.use(githubTheme); export default { components: { MarkdownEditor, - [VMdPreview.name]: VMdPreview + [VMdPreview.name]: VMdPreview, + Expand }, setup() { - const API_BASE_URL = 'http://localhost:8083'; + const API_BASE_URL = 'http://localhost:8084'; const markdownFiles = ref([]); const groupings = ref([]); const groupFiles = ref({}); @@ -128,6 +145,11 @@ export default { } }; + // 选择文件预览 + const selectFile = (file) => { + selectedFile.value = file; + }; + // 编辑笔记 const editNote = (file) => { currentFileId.value = file.id; @@ -154,7 +176,7 @@ export default { const fileId = index.split('-')[1]; const file = markdownFiles.value.find(f => f.id == fileId); if (file) { - selectedFile.value = file; + selectFile(file); } } }; @@ -203,6 +225,7 @@ export default { currentFileId, selectedFile, isCollapsed, + selectFile, editNote, deleteNote, handleMarkdownUpload, @@ -242,6 +265,35 @@ export default { margin-left: 10px; } +.file-list { + margin-top: 20px; +} + +.group-section { + margin-bottom: 20px; +} + +.group-section h3 { + margin-bottom: 10px; + font-size: 18px; + color: #333; +} + +.group-section ul { + list-style: none; + padding: 0; +} + +.group-section li { + padding: 8px 0; + border-bottom: 1px solid #eee; + cursor: pointer; +} + +.group-section li:hover { + background-color: #f5f7fa; +} + .file-preview { padding: 20px; border: 1px solid #ebeef5; @@ -263,4 +315,15 @@ export default { border-radius: 4px; background: #fff; } + +/* 修复菜单折叠样式 */ +.el-menu-vertical-demo { + height: calc(100vh - 60px); + overflow-y: auto; +} +.sidebar-header { + height: 60px; + display: flex; + align-items: center; +} diff --git a/mydatabase.db b/mydatabase.db index fe2ec3f..c604201 100644 Binary files a/mydatabase.db and b/mydatabase.db differ diff --git a/sql/data.sql b/sql/data.sql index 45d11f5..754bc40 100644 --- a/sql/data.sql +++ b/sql/data.sql @@ -16,6 +16,7 @@ CREATE TABLE "user" ( CREATE TABLE IF NOT EXISTS markdown_file ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, + grouping_id TEXT, title TEXT NOT NULL, file_name TEXT NOT NULL, content TEXT NOT NULL, @@ -34,4 +35,4 @@ CREATE TABLE IF NOT EXISTS image ( size INTEGER NOT NULL, content_type TEXT NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP - ); \ No newline at end of file + );