Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-book
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-book
Commits
e0539045
提交
e0539045
authored
2月 06, 2025
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: update
上级
be6fb6b6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
53 行增加
和
38 行删除
+53
-38
AIWriteModal.jsx
src/common/wangeditor-customer/menu/common/AIWriteModal.jsx
+2
-2
useWenku.js
src/hooks/useWenku.js
+51
-36
没有找到文件。
src/common/wangeditor-customer/menu/common/AIWriteModal.jsx
浏览文件 @
e0539045
...
...
@@ -62,7 +62,7 @@ export default function AIModal() {
const
paper
=
await
generatePaper
({
userQuery
:
msg
.
userQuery
,
queryID
:
msg
.
queryID
,
outline
:
msg
.
content
})
setMessages
((
prevMessages
)
=>
{
prevMessages
.
pop
()
return
[...
prevMessages
,
{
content
:
'已为您生成初稿,请点击
查看
'
,
role
:
'ai'
,
queryID
:
msg
.
queryID
,
paper
}]
return
[...
prevMessages
,
{
content
:
'已为您生成初稿,请点击
下载
'
,
role
:
'ai'
,
queryID
:
msg
.
queryID
,
paper
}]
})
}
...
...
@@ -77,7 +77,7 @@ export default function AIModal() {
return
(
<
div
className=
"chapter-item"
key=
{
index
}
>
<
div
className=
"chapter-left"
>
<
div
className=
"chapter-left-title"
>
{
item
.
chapter
}
</
div
>
<
div
className=
"chapter-left-title"
>
{
item
.
tag
}
</
div
>
<
div
className=
"line-dot"
>
<
div
className=
"dot"
></
div
>
<
div
className=
"line"
></
div
>
...
...
src/hooks/useWenku.js
浏览文件 @
e0539045
...
...
@@ -68,51 +68,66 @@ export function useSearch() {
return
{
messages
,
setMessages
,
isLoading
,
query
:
execute
}
}
function
parseInput
(
inputStr
)
{
function
parseInput
(
markdown
)
{
// Split content into lines
const
lines
=
markdown
.
split
(
'
\
n'
).
filter
((
line
)
=>
line
.
trim
())
const
result
=
[]
const
regex
=
/^
(
#+
)\s
*
(
.+
?)\s
*
(?=\n
|【描述】|$
)
/
const
descriptionRegex
=
/【描述】
(
.*
)
/
const
sections
=
[]
let
level
=
0
const
lines
=
inputStr
.
split
(
'
\
n'
)
lines
.
forEach
((
line
)
=>
{
const
headerMatch
=
line
.
match
(
regex
)
const
descriptionMatch
=
line
.
match
(
descriptionRegex
)
if
(
headerMatch
)
{
const
header
=
headerMatch
[
1
]
// Capture the number of `#`
const
title
=
headerMatch
[
2
].
trim
()
// Capture the title
const
newLevel
=
header
.
length
// Adjust section numbering based on levels
if
(
newLevel
>
level
)
{
sections
.
push
(
1
)
// Add new sub-level
}
else
if
(
newLevel
===
level
)
{
sections
[
sections
.
length
-
1
]
++
// Increment current level
}
else
{
sections
.
splice
(
newLevel
-
1
)
// Drop deeper levels
sections
[
sections
.
length
-
1
]
++
let
chapterCount
=
0
let
subChapterCount
=
0
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
const
line
=
lines
[
i
]
let
level
=
0
let
title
=
''
let
desc
=
''
// Determine level and title
if
(
line
.
startsWith
(
'# '
))
{
level
=
1
title
=
line
.
replace
(
'# '
,
''
)
}
else
if
(
line
.
startsWith
(
'## '
))
{
level
=
2
title
=
line
.
replace
(
'## '
,
''
)
chapterCount
++
subChapterCount
=
0
}
else
if
(
line
.
startsWith
(
'### '
))
{
level
=
3
title
=
line
.
replace
(
'### '
,
''
)
subChapterCount
++
}
// If this is a header line
if
(
level
>
0
)
{
// Get description from next line if it exists and contains 【描述】
const
nextLine
=
lines
[
i
+
1
]
if
(
nextLine
&&
nextLine
.
includes
(
'【描述】'
))
{
desc
=
nextLine
.
replace
(
'【描述】'
,
''
)
i
++
// Skip the description line in next iteration
}
// Determine tag based on level
let
tag
if
(
level
===
1
)
{
tag
=
'标题'
}
else
if
(
level
===
2
)
{
tag
=
`第
${
chapterCount
}
章`
}
else
if
(
level
===
3
)
{
tag
=
`
${
chapterCount
}
.
${
subChapterCount
}
`
}
level
=
newLevel
// Update current level
// Create content string
const
content
=
desc
?
`
${
'#'
.
repeat
(
level
)}
${
title
}
\n【描述】
${
desc
}
`
:
`
${
'#'
.
repeat
(
level
)}
${
title
}
`
// Create chapter number and entry
const
chapter
=
sections
.
join
(
'.'
)
// Add to result array
result
.
push
({
title
,
level
,
desc
:
''
,
// Will be updated if a description follows
chapter
:
level
===
1
?
'标题'
:
`第
${
chapter
}
章`
,
tag
,
desc
:
desc
||
''
,
content
,
})
}
else
if
(
descriptionMatch
)
{
const
desc
=
descriptionMatch
[
1
].
trim
()
if
(
result
.
length
>
0
)
{
result
[
result
.
length
-
1
].
desc
=
desc
// Attach description to the last entry
}
}
}
)
}
return
result
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论