提交 58d8afeb authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 b3ca2028
export const knowledgeTree = [
{
id: '1',
courseName: '人工智能基础',
chapterName: '第一章:人工智能概述',
sectionName: '1.1 人工智能的定义与发展',
children: [
{
id: '1-1',
label: '图灵测试',
children: [
{ id: '1-1-1', label: '测试方法' },
{ id: '1-1-2', label: '历史意义' }
]
},
{
id: '1-2',
label: 'AI分类',
children: [
{ id: '1-2-1', label: '弱人工智能' },
{ id: '1-2-2', label: '强人工智能' },
{ id: '1-2-3', label: '超人工智能' }
]
},
{
id: '1-3',
label: '发展历程',
children: [
{ id: '1-3-1', label: '起源期(1950s)' },
{ id: '1-3-2', label: '早期发展(1960-70s)' },
{ id: '1-3-3', label: '知识工程期(1980-90s)' },
{ id: '1-3-4', label: '机器学习复兴(2000s)' },
{ id: '1-3-5', label: '深度学习革命(2010s-)' }
]
}
]
},
{
id: '2',
courseName: '人工智能基础',
chapterName: '第一章:人工智能概述',
sectionName: '1.2 AI的应用领域',
children: [
{
id: '2-1',
label: '医疗健康',
children: [
{ id: '2-1-1', label: '医学影像诊断' },
{ id: '2-1-2', label: '药物研发' },
{ id: '2-1-3', label: '手术机器人' }
]
},
{
id: '2-2',
label: '金融服务',
children: [
{ id: '2-2-1', label: '风险控制' },
{ id: '2-2-2', label: '智能投顾' },
{ id: '2-2-3', label: '反欺诈检测' }
]
},
{
id: '2-3',
label: '智能交通',
children: [
{ id: '2-3-1', label: '自动驾驶' },
{ id: '2-3-2', label: '交通优化' }
]
}
]
},
{
id: '3',
courseName: '人工智能基础',
chapterName: '第一章:人工智能概述',
sectionName: '1.3 AI技术栈与工具',
children: [
{
id: '3-1',
label: '开发环境',
children: [
{ id: '3-1-1', label: 'Python环境搭建' },
{ id: '3-1-2', label: '开发工具配置' }
]
},
{
id: '3-2',
label: '技术栈架构',
children: [
{ id: '3-2-1', label: '硬件层' },
{ id: '3-2-2', label: '软件框架层' },
{ id: '3-2-3', label: '应用层' }
]
},
{
id: '3-3',
label: '主流工具对比',
children: [
{ id: '3-3-1', label: '开源工具' },
{ id: '3-3-2', label: '商业工具' }
]
}
]
},
{
id: '4',
courseName: '人工智能基础',
chapterName: '第二章:机器学习基础',
sectionName: '2.1 机器学习概述',
children: [
{
id: '4-1',
label: '监督学习',
children: [
{ id: '4-1-1', label: '分类算法' },
{ id: '4-1-2', label: '回归算法' }
]
},
{
id: '4-2',
label: '无监督学习',
children: [
{ id: '4-2-1', label: '聚类算法' },
{ id: '4-2-2', label: '降维技术' }
]
},
{
id: '4-3',
label: '强化学习',
children: [
{ id: '4-3-1', label: 'Q学习' },
{ id: '4-3-2', label: '策略梯度' }
]
}
]
},
{
id: '5',
courseName: '人工智能基础',
chapterName: '第二章:机器学习基础',
sectionName: '2.2 线性回归算法',
children: [
{
id: '5-1',
label: '数学原理',
children: [
{ id: '5-1-1', label: '最小二乘法' },
{ id: '5-1-2', label: '梯度下降' },
{ id: '5-1-3', label: '损失函数' }
]
},
{
id: '5-2',
label: '算法实现',
children: [
{ id: '5-2-1', label: 'Python实现' },
{ id: '5-2-2', label: '参数优化' }
]
},
{
id: '5-3',
label: '应用案例',
children: [
{ id: '5-3-1', label: '房价预测' },
{ id: '5-3-2', label: '销量预测' }
]
}
]
},
{
id: '6',
courseName: '人工智能基础',
chapterName: '第二章:机器学习基础',
sectionName: '2.3 分类算法基础',
children: [
{
id: '6-1',
label: '逻辑回归',
children: [
{ id: '6-1-1', label: 'Sigmoid函数' },
{ id: '6-1-2', label: '极大似然估计' }
]
},
{
id: '6-2',
label: '决策树',
children: [
{ id: '6-2-1', label: '信息增益' },
{ id: '6-2-2', label: '剪枝策略' }
]
},
{
id: '6-3',
label: '性能评估',
children: [
{ id: '6-3-1', label: '混淆矩阵' },
{ id: '6-3-2', label: 'ROC曲线' }
]
}
]
},
{
id: '7',
courseName: '人工智能基础',
chapterName: '第三章:深度学习入门',
sectionName: '3.1 神经网络基础',
children: [
{
id: '7-1',
label: '感知机',
children: [
{ id: '7-1-1', label: '单层感知机' },
{ id: '7-1-2', label: '多层感知机' }
]
},
{
id: '7-2',
label: '激活函数',
children: [
{ id: '7-2-1', label: 'Sigmoid' },
{ id: '7-2-2', label: 'ReLU' },
{ id: '7-2-3', label: 'Tanh' }
]
},
{
id: '7-3',
label: '反向传播',
children: [
{ id: '7-3-1', label: '梯度计算' },
{ id: '7-3-2', label: '权重更新' }
]
}
]
},
{
id: '8',
courseName: '人工智能基础',
chapterName: '第三章:深度学习入门',
sectionName: '3.2 卷积神经网络',
children: [
{
id: '8-1',
label: '卷积层',
children: [
{ id: '8-1-1', label: '卷积操作' },
{ id: '8-1-2', label: '特征提取' }
]
},
{
id: '8-2',
label: '池化层',
children: [
{ id: '8-2-1', label: '最大池化' },
{ id: '8-2-2', label: '平均池化' }
]
},
{
id: '8-3',
label: '网络架构',
children: [
{ id: '8-3-1', label: 'LeNet' },
{ id: '8-3-2', label: 'AlexNet' }
]
}
]
},
{
id: '9',
courseName: '人工智能基础',
chapterName: '第三章:深度学习入门',
sectionName: '3.3 深度学习框架',
children: [
{
id: '9-1',
label: 'TensorFlow',
children: [
{ id: '9-1-1', label: '基础API' },
{ id: '9-1-2', label: '高级API' }
]
},
{
id: '9-2',
label: 'PyTorch',
children: [
{ id: '9-2-1', label: '动态图机制' },
{ id: '9-2-2', label: '自动求导' }
]
},
{
id: '9-3',
label: '框架选择',
children: [
{ id: '9-3-1', label: '性能对比' },
{ id: '9-3-2', label: '应用场景' }
]
}
]
},
{
id: '10',
courseName: '人工智能基础',
chapterName: '第四章:自然语言处理',
sectionName: '4.1 文本预处理',
children: [
{
id: '10-1',
label: '中文处理',
children: [
{ id: '10-1-1', label: '分词技术' },
{ id: '10-1-2', label: '词性标注' }
]
},
{
id: '10-2',
label: '文本清洗',
children: [
{ id: '10-2-1', label: '去除噪声' },
{ id: '10-2-2', label: '标准化处理' }
]
},
{
id: '10-3',
label: '特征提取',
children: [
{ id: '10-3-1', label: '词袋模型' },
{ id: '10-3-2', label: 'TF-IDF' }
]
}
]
},
{
id: '11',
courseName: '人工智能基础',
chapterName: '第四章:自然语言处理',
sectionName: '4.2 词向量与语言模型',
children: [
{
id: '11-1',
label: 'Word2Vec',
children: [
{ id: '11-1-1', label: 'CBOW模型' },
{ id: '11-1-2', label: 'Skip-gram模型' }
]
},
{
id: '11-2',
label: 'Transformer',
children: [
{ id: '11-2-1', label: '注意力机制' },
{ id: '11-2-2', label: '编码器-解码器' }
]
},
{
id: '11-3',
label: '预训练模型',
children: [
{ id: '11-3-1', label: 'BERT' },
{ id: '11-3-2', label: 'GPT系列' }
]
}
]
},
{
id: '12',
courseName: '人工智能基础',
chapterName: '第五章:计算机视觉',
sectionName: '5.1 图像处理基础',
children: [
{
id: '12-1',
label: '数字图像',
children: [
{ id: '12-1-1', label: '像素表示' },
{ id: '12-1-2', label: '色彩空间' }
]
},
{
id: '12-2',
label: '图像滤波',
children: [
{ id: '12-2-1', label: '高斯滤波' },
{ id: '12-2-2', label: '中值滤波' }
]
},
{
id: '12-3',
label: '边缘检测',
children: [
{ id: '12-3-1', label: 'Sobel算子' },
{ id: '12-3-2', label: 'Canny检测' }
]
}
]
},
{
id: '13',
courseName: '人工智能基础',
chapterName: '第五章:计算机视觉',
sectionName: '5.2 目标检测与识别',
children: [
{
id: '13-1',
label: '传统方法',
children: [
{ id: '13-1-1', label: '特征描述子' },
{ id: '13-1-2', label: '滑动窗口' }
]
},
{
id: '13-2',
label: '深度学习方法',
children: [
{ id: '13-2-1', label: 'R-CNN系列' },
{ id: '13-2-2', label: 'YOLO算法' }
]
},
{
id: '13-3',
label: '性能评估',
children: [
{ id: '13-3-1', label: 'mAP指标' },
{ id: '13-3-2', label: 'IoU计算' }
]
}
]
}
]
...@@ -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="800px" title="添加知识点" :model-value="true" @close="emit('update:modelValue', false)"> <el-dialog draggable width="1000px" 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">
......
...@@ -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="800px" width="1000px"
:before-close="handleClose" :before-close="handleClose"
draggable draggable
destroy-on-close destroy-on-close
......
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论