现在我看清楚了。问题在于课程数据从后端返回时,没有包含 source 字段。我需要检查后端是如何返回课程数据的,然后在 CoursesPanel 中检查数据结构:
现在我找到了问题!从 CoursesPanel 看,course.source 字段是存在的(显示在卡片上),问题是 SectionTree 中的 item 数据没有 source 字段。后端返回的课程详情中的条目(items) 没有包含平台来源信息。
让我检查一下当前的拖拽处理逻辑:
完美!现在我看到了问题所在。代码中已经有 source: item.source 的处理,但是问题是:item 数据中没有 source 字段。
根据 CoursesPanel.vue 的数据结构,我看到课程对象有 source 字段,但是 SectionTree 中的 items 没有。我需要修改 SectionTree 或 CoursesPanel 来在下钻到 item 层级时保留 source 信息。
让我创建一个解决方案:在传递 item 到拖拽事件时,需要从父级课程中获取 source:
完成!我已经修复了 source 字段缺失的问题。关键改动:
courseSource prop,在拖拽时将其合并到 item 数据中,确保每个条目都有 source 字段source 字段传递给 SectionTree 组件现在拖拽课程条目时,source 字段会正确显示课程所属的平台("哔哩哔哩"或"超星网盘"等),后端接口可以根据 source 字段调用对应平台的关联接口。
courseName 也需要加上 const response = await fetch('http://127.0.0.1:8000/api/notes/link_course_item', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ noteId: appStore.selectedNote.id, courseItem: { id: item.id, title: item.title, type: item.type, duration: item.duration, completed: item.completed, source: item.source, // <-- Platform identifier: "哔哩哔哩" or "超星网盘" etc. ...(item.a_id && { a_id: item.a_id }), ...(item.bvid && { bvid: item.bvid }), ...(item.c_id && { c_id: item.c_id }), ...(item.url && { url: item.url }), ...(item.preview && { preview: item.preview }) } })
现在我需要找到如何传递课程名称。让我查看 CoursesPanel 如何传递课程信息到 SectionTree:
完美!现在我看清楚了整个数据流。我需要:
courseName propcourseName 包含在数据中courseName 在 API 请求中已完成!我添加了 courseName 支持到拖拽系统中:
courseName prop,在拖拽时将其包含在数据中,确保后端能获取课程名称title 作为 courseName 传递给 SectionTree现在在拖拽时,数据中会包含 courseName: item.courseName,后端的 /api/notes/link_course_item 接口就能接收到完整的课程条目信息(包括 courseName、source、id、title 等)。
const linkChaoxingVideo = async () => {
const jsonData = {
video_title: props.item.title,
video_preview: props.item.preview,
note_id: selectedNoteId.value,
date: new Date().toISOString().replace(/.\d+Z$/, "Z"),
source: "超星网盘",
type: "video",
// Additional fields from the item
Id: props.item.Id,
bbsid: props.item.bbsid,
folderId: props.item.folderId,
id: props.item.id,
thumbnail: props.item.thumbnail,
item_type: props.item.type,
courseName:
} 注意我需要 超星 video_link_to_home 的时候 也要传入 courseName 注意超星的courseName 就是如果当前文件的父层级(上面多级)被标记为 课程 那么拿个文件夹名就是 这个的课程名 2. 在右侧课程条目拖动到左侧detail之后 关联附件没有实时刷新 也要修复
You can send messages while the preview loads