feat(knowledge): This PR implements the knowledge categorization feature, allowing users to automatically categorize knowledge entries into the selected category when uploading or creating knowledge. #547
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request
描述 (Description)
本次 PR 实现了知识分类功能,允许用户在上传或创建知识时自动归类到选中的分类下。

核心功能:
技术实现:
tag_id参数支持,在创建知识时保存分类IDtag_id为可选参数,未提供时默认为"未分类"变更类型 (Type of Change)
影响范围 (Scope)
测试 (Testing)
测试步骤 (Test Steps)
文件上传测试
文件夹上传测试
URL 导入测试
在线编辑测试
未分类测试
检查清单 (Checklist)
相关 Issue
Fixes #
变更文件列表
后端 (Backend)
internal/handler/knowledge.go: 添加tag_id参数接收(文件上传、URL导入、手工创建)internal/application/service/knowledge.go: 在创建知识时保存tag_id到数据库internal/types/knowledge.go:ManualKnowledgePayload结构体添加TagID字段internal/types/interfaces/knowledge.go: 接口定义添加tagID参数前端 (Frontend)
frontend/src/stores/ui.ts: 添加selectedTagId状态和setSelectedTagId方法frontend/src/views/knowledge/KnowledgeBase.vue: 分类切换时同步更新 Storefrontend/src/components/menu.vue: 上传文档和文件夹时从 Store 读取并传递tag_idfrontend/src/components/manual-knowledge-editor.vue: 在线编辑创建时从 Store 读取并传递tag_idfrontend/src/hooks/useKnowledgeBase.ts: 拖拽上传时从 Store 读取并传递tag_idfrontend/src/api/knowledge-base/index.ts: API 函数添加tag_id参数支持数据库迁移 (Database Migration)
tag_id字段已存在于knowledge表中)配置变更 (Configuration Changes)
无需配置变更
部署说明 (Deployment Notes)
其他信息 (Additional Information)
设计说明:
useUIStore) 统一管理选中分类状态,避免状态分散selectedTagId,确保行为一致tag_id参数,空字符串或"__untagged__"表示未分类注意事项:
tag_id不会被传递,后端会保存为空字符串selectedTagId !== '__untagged__'判断是否需要传递tag_id