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

feat: 新增关联知识图谱

上级 e63ceb03
import { useState, useEffect } from 'react'
import { Modal, TreeSelect, App } from 'antd'
import { getChapterEditors, updateChapterEditors } from '../api'
const EditChapterEditors = ({ chapter = {}, onOk, ...props }) => {
const { message } = App.useApp()
const [value, setValue] = useState('')
const [treeData, setTreeData] = useState([
{
id: '1',
name: '项目一:初识商务数据分析',
children: [
{
id: '1-1',
name: '任务一:人人都需要商务数据分析',
children: [
{
id: '1-1-1',
name: ' 商务数据分析就业情况',
children: [
{
id: '1-1-1-1',
name: ' 商务数据分析师岗位'
},
{
id: '1-1-1-2',
name: ' 商务数据分析师的市场优势'
},
{
id: '1-1-1-3',
name: ' 商务数据分析师的工作职责'
}
]
}
]
}
]
}
])
useEffect(() => {
getChapterEditors({ book_id: chapter.book_id, chapter_id: chapter.id }).then(res => {
const value = res.data.selected_editor_ids[0] || ''
setValue(value)
})
}, [chapter])
const handleSubmit = async () => {
message.success('关联成功')
onOk?.()
}
return (
<Modal title="关联知识图谱" centered {...props} onOk={handleSubmit}>
<TreeSelect
showSearch
treeDefaultExpandAll
treeData={treeData}
fieldNames={{ label: 'name', value: 'id' }}
style={{ width: '100%' }}></TreeSelect>
</Modal>
)
}
export default EditChapterEditors
import { useState, useEffect } from 'react'
import { Modal, Form, Radio, Space, message } from 'antd'
import { Modal, Form, Radio, Space, App } from 'antd'
import { getChapterEditors, updateChapterEditors } from '../api'
const EditChapterEditors = ({ chapter = {}, onChange, ...props }) => {
const { message } = App.useApp()
const [editors, setEditors] = useState([])
const [value, setValue] = useState('')
......
......@@ -8,6 +8,7 @@ import { setAutosaveTime } from '@/store/modules/editor'
import { setTreeChapter } from '@/store/modules/user'
import EditChapterTitle from './components/form-chapter-title'
import EditChapterEditors from './components/EditChapterEditors'
import BindKnowledgeGraph from './components/BindKnowledgeGraph'
import { get } from 'lodash-es'
import md5 from 'js-md5'
......@@ -55,6 +56,10 @@ const Examine = () => {
const onChapterEditorsChange = () => {
setEditChapterEditorsIsOpen(false)
}
// 关联知识图谱
const [bindKnowledgeGraphIsOpen, setBindKnowledgeGraphIsOpen] = useState(false)
// 编辑器内容
const editorRef = useRef()
const saveInterRef = useRef()
......@@ -298,6 +303,7 @@ const Examine = () => {
let chapterMenuItems = [
{ key: '1', label: '展开全部' },
{ key: '2', label: '添加子节' },
{ key: '7', label: '关联知识图谱' },
{ key: '5', label: '设置编者' },
{
key: '6',
......@@ -342,6 +348,8 @@ const Examine = () => {
})
} else if (e.key == 5) {
setEditChapterEditorsIsOpen(true)
} else if (e.key == 7) {
setBindKnowledgeGraphIsOpen(true)
}
}
......@@ -540,6 +548,14 @@ const Examine = () => {
onCancel={() => setEditChapterEditorsIsOpen(false)}
onChange={onChapterEditorsChange}></EditChapterEditors>
)}
{/* 关联知识图谱 */}
{currentChapter && bindKnowledgeGraphIsOpen && (
<BindKnowledgeGraph
open={bindKnowledgeGraphIsOpen}
chapter={currentChapter}
onCancel={() => setBindKnowledgeGraphIsOpen(false)}
onOk={() => setBindKnowledgeGraphIsOpen(false)}></BindKnowledgeGraph>
)}
</div>
)
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论