Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-resource
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-resource
Commits
58d8afeb
提交
58d8afeb
authored
7月 01, 2025
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: update
上级
b3ca2028
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
121 行增加
和
7 行删除
+121
-7
demo.ts
src/modules/course/create/assets/demo.ts
+0
-0
AddKnowledge.vue
...urse/create/components/stepTwoComponents/AddKnowledge.vue
+5
-5
KnowledgeGraphPreview.vue
...te/components/stepTwoComponents/KnowledgeGraphPreview.vue
+1
-1
StepTwo.vue
src/modules/course/create/views/StepTwo.vue
+115
-1
没有找到文件。
src/modules/course/create/assets/demo.ts
0 → 100644
浏览文件 @
58d8afeb
差异被折叠。
点击展开。
src/modules/course/create/components/stepTwoComponents/AddKnowledge.vue
浏览文件 @
58d8afeb
...
@@ -70,10 +70,10 @@ const generateId = () => {
...
@@ -70,10 +70,10 @@ const generateId = () => {
// 添加根节点
// 添加根节点
const
addRootNode
=
()
=>
{
const
addRootNode
=
()
=>
{
if
(
treeData
.
value
.
length
>
0
)
{
//
if (treeData.value.length > 0) {
ElMessage
.
warning
(
'只能添加一个根节点'
)
//
ElMessage.warning('只能添加一个根节点')
return
//
return
}
//
}
const
newNode
=
{
const
newNode
=
{
id
:
generateId
(),
id
:
generateId
(),
...
@@ -226,7 +226,7 @@ onMounted(() => {
...
@@ -226,7 +226,7 @@ onMounted(() => {
</
script
>
</
script
>
<
template
>
<
template
>
<el-dialog
draggable
width=
"
8
00px"
title=
"添加知识点"
:model-value=
"true"
@
close=
"emit('update:modelValue', false)"
>
<el-dialog
draggable
width=
"
10
00px"
title=
"添加知识点"
:model-value=
"true"
@
close=
"emit('update:modelValue', false)"
>
<el-tabs
v-model=
"activeName"
>
<el-tabs
v-model=
"activeName"
>
<el-tab-pane
label=
"树状结构"
name=
"first"
>
<el-tab-pane
label=
"树状结构"
name=
"first"
>
<div
class=
"knowledge-tree-container"
>
<div
class=
"knowledge-tree-container"
>
...
...
src/modules/course/create/components/stepTwoComponents/KnowledgeGraphPreview.vue
浏览文件 @
58d8afeb
...
@@ -103,7 +103,7 @@ onMounted(() => {
...
@@ -103,7 +103,7 @@ onMounted(() => {
<el-dialog
<el-dialog
:model-value=
"isShowKnowledgeGraphPreview"
:model-value=
"isShowKnowledgeGraphPreview"
:title=
"title || '知识点脑图预览'"
:title=
"title || '知识点脑图预览'"
width=
"
8
00px"
width=
"
10
00px"
:before-close=
"handleClose"
:before-close=
"handleClose"
draggable
draggable
destroy-on-close
destroy-on-close
...
...
src/modules/course/create/views/StepTwo.vue
浏览文件 @
58d8afeb
...
@@ -16,8 +16,9 @@ import AddTextbookDialog from '../components/stepTwoComponents/AddTextbookDialog
...
@@ -16,8 +16,9 @@ import AddTextbookDialog from '../components/stepTwoComponents/AddTextbookDialog
import
AddGraphbookDialog
from
'../components/stepTwoComponents/AddGraphbookDialog.vue'
import
AddGraphbookDialog
from
'../components/stepTwoComponents/AddGraphbookDialog.vue'
import
AddKnowledge
from
'../components/stepTwoComponents/AddKnowledge.vue'
import
AddKnowledge
from
'../components/stepTwoComponents/AddKnowledge.vue'
import
KnowledgeGraphPreview
from
'../components/stepTwoComponents/KnowledgeGraphPreview.vue'
import
KnowledgeGraphPreview
from
'../components/stepTwoComponents/KnowledgeGraphPreview.vue'
import
{
knowledgeTree
}
from
'../assets/demo'
import
OpenRules
from
'../components/stepTwoComponents/OpenRules.vue'
import
OpenRules
from
'../components/stepTwoComponents/OpenRules.vue'
const
route
=
useRoute
()
const
route
=
useRoute
()
const
router
=
useRouter
()
const
router
=
useRouter
()
const
isEditCourse
=
route
.
query
.
isEditCourse
as
string
const
isEditCourse
=
route
.
query
.
isEditCourse
as
string
...
@@ -111,9 +112,122 @@ const handleChapterList = () => {
...
@@ -111,9 +112,122 @@ const handleChapterList = () => {
})
})
}
}
})
})
// 设置知识点默认值
setDefaultKnowledgePoints
(
res
.
data
[
0
])
})
})
}
}
// 设置知识点默认值
const
setDefaultKnowledgePoints
=
(
courseData
:
any
)
=>
{
if
(
!
courseData
)
return
const
courseName
=
courseData
.
name
const
storageKey
=
'knowledge'
// 获取现有的知识点数据
let
existingData
=
[]
try
{
existingData
=
JSON
.
parse
(
localStorage
.
getItem
(
storageKey
)
||
'[]'
)
}
catch
(
error
)
{
console
.
error
(
'读取localStorage失败:'
,
error
)
existingData
=
[]
}
// 遍历课程章节数据,匹配knowledgeTree中的默认知识点
const
processChapters
=
(
chapters
:
any
[],
parentChapterName
=
''
)
=>
{
chapters
.
forEach
((
chapter
)
=>
{
if
(
chapter
.
depth
===
'1'
)
{
// 处理章,递归处理其子节点(节)
const
chapterName
=
chapter
.
name
if
(
chapter
.
children
&&
chapter
.
children
.
length
>
0
)
{
processChapters
(
chapter
.
children
,
chapterName
)
}
}
else
if
(
chapter
.
depth
===
'2'
)
{
// 只有节才有知识点,处理节
const
sectionName
=
chapter
.
name
const
fullChapterName
=
parentChapterName
// 在knowledgeTree中查找匹配的知识点
const
matchedKnowledge
=
knowledgeTree
.
find
(
(
item
:
any
)
=>
item
.
courseName
===
courseName
&&
item
.
chapterName
===
fullChapterName
&&
item
.
sectionName
===
sectionName
)
if
(
matchedKnowledge
)
{
// 检查是否已经存在该节的知识点数据
const
existingSectionData
=
existingData
.
find
((
item
:
any
)
=>
item
.
section_id
===
chapter
.
id
)
if
(
!
existingSectionData
)
{
// 转换知识点数据格式,添加必要的字段
// matchedKnowledge.children 包含多个根知识点,每个根知识点都有自己的子知识点树
const
knowledgeData
=
convertKnowledgeToStorageFormat
(
matchedKnowledge
.
children
,
courseData
.
id
,
chapter
.
parent_id
,
chapter
.
id
)
// 添加到现有数据中
existingData
.
push
(...
knowledgeData
)
console
.
log
(
`为节 "
${
sectionName
}
" 设置了默认知识点`
)
}
}
}
})
}
// 处理课程数据
if
(
courseData
.
children
&&
courseData
.
children
.
length
>
0
)
{
processChapters
(
courseData
.
children
)
}
// 保存到localStorage
try
{
localStorage
.
setItem
(
storageKey
,
JSON
.
stringify
(
existingData
))
console
.
log
(
'知识点默认值设置完成'
)
}
catch
(
error
)
{
console
.
error
(
'保存知识点数据到localStorage失败:'
,
error
)
}
}
// 转换知识点数据格式
const
convertKnowledgeToStorageFormat
=
(
knowledgeNodes
:
any
[],
courseId
:
string
,
chapterId
:
string
,
sectionId
:
string
):
any
[]
=>
{
const
result
:
any
[]
=
[]
const
processNode
=
(
node
:
any
):
any
=>
{
const
convertedNode
=
{
id
:
node
.
id
,
label
:
node
.
label
,
course_id
:
id
,
chapter_id
:
chapterId
,
section_id
:
sectionId
,
children
:
[]
as
any
[],
}
if
(
node
.
children
&&
node
.
children
.
length
>
0
)
{
node
.
children
.
forEach
((
child
:
any
)
=>
{
convertedNode
.
children
.
push
(
processNode
(
child
))
})
}
return
convertedNode
}
// 处理每个根知识点及其子知识点树
knowledgeNodes
.
forEach
((
rootNode
)
=>
{
result
.
push
(
processNode
(
rootNode
))
})
return
result
}
// 新增章节
// 新增章节
const
handleAddChapter
=
()
=>
{
const
handleAddChapter
=
()
=>
{
isShowDialog
.
value
=
true
isShowDialog
.
value
=
true
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论