Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-book
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-book
Commits
00e25eb6
提交
00e25eb6
authored
2月 05, 2026
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: simplify chapter selection logic in book sections and remove '天工' AI option.
上级
b17c3bae
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
38 行删除
+24
-38
useAI.js
src/hooks/useAI.js
+1
-1
index.jsx
src/pages/books/section/index.jsx
+23
-37
没有找到文件。
src/hooks/useAI.js
浏览文件 @
00e25eb6
...
...
@@ -8,7 +8,7 @@ export function useAI() {
{
label
:
'文心一言'
,
value
:
'yiyan'
},
{
label
:
'DeepSeek'
,
value
:
'deepseek'
},
{
label
:
'通义千问'
,
value
:
'qwen'
},
{
label
:
'天工'
,
value
:
'tiangong'
},
//
{ label: '天工', value: 'tiangong' },
]
const
[
ai
,
setAI
]
=
useState
(
localStorage
.
getItem
(
'ai'
)
||
'yiyan'
)
...
...
src/pages/books/section/index.jsx
浏览文件 @
00e25eb6
...
...
@@ -156,54 +156,40 @@ const Examine = () => {
const
onExpand
=
expandedKeys
=>
{
setExpandedKeys
(
expandedKeys
)
}
const
handleSelect
=
async
(
check
edKeys
,
info
)
=>
{
const
{
key
}
=
info
.
node
const
childInKey
=
findTreeElementByKey
(
gData
,
'key'
,
key
)
const
handleSelect
=
async
(
select
edKeys
,
info
)
=>
{
if
(
!
info
.
node
)
return
const
{
key
,
title
}
=
info
.
node
if
(
childInKey
.
children
&&
childInKey
.
children
.
length
>
0
)
{
clearInterval
(
saveInterRef
.
current
)
// 进行展开操作
const
tempExpandeds
=
JSON
.
parse
(
JSON
.
stringify
(
expandedKeys
))
let
newExpand
=
''
if
(
expandedKeys
.
includes
(
key
))
{
newExpand
=
tempExpandeds
.
filter
(
item
=>
parseInt
(
item
)
!==
parseInt
(
key
))
}
else
{
newExpand
=
[...
tempExpandeds
,
key
]
}
setExpandedKeys
(
newExpand
)
setCheckedKeys
([
key
])
// 保持选中状态,防止重复点击导致选中状态消失
setCheckedKeys
([
key
])
// 如果点击的是当前已经选中的章节,且没有发生章节切换,则直接返回
if
(
key
===
chapterId
)
{
return
}
else
{
const
{
key
,
title
}
=
info
.
node
if
(
info
.
selected
===
false
)
{
setLoading
(
true
)
setChapterId
(
key
)
setCheckedKeys
([
key
])
setNowTitle
(
title
)
setLoading
(
false
)
}
else
{
setLoading
(
true
)
clearInterval
(
saveInterRef
.
current
)
await
saveContent
()
}
if
(
key
!==
chapterId
)
{
editorRef
.
current
.
editor
.
clear
()
}
setLoading
(
true
)
setChapterId
(
checkedKeys
[
0
])
setCheckedKeys
([
checkedKeys
[
0
]])
setNowTitle
(
info
.
node
.
title
)
setLoading
(
false
)
}
setLoading
(
true
)
// 切换章节前清理保存定时器并执行一次保存
clearInterval
(
saveInterRef
.
current
)
await
saveContent
()
// 清理旧内容
if
(
editorRef
.
current
&&
editorRef
.
current
.
editor
)
{
editorRef
.
current
.
editor
.
clear
()
}
// 设置新章节 ID,触发 useEffect 加载数据
setChapterId
(
key
)
setNowTitle
(
title
)
setLoading
(
false
)
}
useEffect
(()
=>
{
getChapterTreeList
()
},
[])
useEffect
(()
=>
{
if
(
chapterId
)
{
setCheckedKeys
([
chapterId
])
getChapterVal
()
}
},
[
chapterId
])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论