Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-book
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-book
Commits
be6fb6b6
提交
be6fb6b6
authored
1月 22, 2025
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: update
上级
15a93038
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
26 行增加
和
31 行删除
+26
-31
AISearchModal.less
...common/wangeditor-customer/menu/common/AISearchModal.less
+2
-2
useWenku.js
src/hooks/useWenku.js
+24
-29
没有找到文件。
src/common/wangeditor-customer/menu/common/AISearchModal.less
浏览文件 @
be6fb6b6
...
...
@@ -72,8 +72,8 @@
}
.message-content {
padding: 16px;
max-height: 300px;
overflow-y: auto;
//
max-height: 300px;
//
overflow-y: auto;
}
.message-tools {
padding: 16px;
...
...
src/hooks/useWenku.js
浏览文件 @
be6fb6b6
...
...
@@ -68,56 +68,51 @@ export function useSearch() {
return
{
messages
,
setMessages
,
isLoading
,
query
:
execute
}
}
function
parseInput
(
inputStr
)
{
const
result
=
[]
const
regex
=
/^
(
#+
)\s
*
(
.+
?)\s
*
(?=\n
|【描述】|$
)
/
g
const
regex
=
/^
(
#+
)\s
*
(
.+
?)\s
*
(?=\n
|【描述】|$
)
/
const
descriptionRegex
=
/【描述】
(
.*
)
/
const
sections
=
[]
const
lines
=
inputStr
.
split
(
'
\
n'
)
let
level
=
0
let
currentTitle
=
''
let
currentChapter
=
''
for
(
let
line
of
lines
)
{
const
lines
=
inputStr
.
split
(
'
\
n'
)
lines
.
forEach
((
line
)
=>
{
const
headerMatch
=
line
.
match
(
regex
)
const
descriptionMatch
=
line
.
match
(
descriptionRegex
)
if
(
headerMatch
)
{
const
header
=
headerMatch
[
0
]
const
newLevel
=
header
.
match
(
/^#+/
)[
0
].
length
const
title
=
header
.
replace
(
/^#+
\s
*/
,
''
).
trim
()
const
header
=
headerMatch
[
1
]
// Capture the number of `#`
const
title
=
headerMatch
[
2
].
trim
()
// Capture the title
const
newLevel
=
header
.
length
//
Handle level change
//
Adjust section numbering based on levels
if
(
newLevel
>
level
)
{
// Increase section number for sub-levels
if
(
level
===
0
)
{
sections
.
push
(
1
)
}
else
{
sections
.
push
(
sections
[
sections
.
length
-
1
]
+
1
)
}
sections
.
push
(
1
)
// Add new sub-level
}
else
if
(
newLevel
===
level
)
{
sections
[
sections
.
length
-
1
]
=
sections
[
sections
.
length
-
1
]
+
1
sections
[
sections
.
length
-
1
]
++
// Increment current level
}
else
{
sections
.
splice
(
newLevel
,
sections
.
length
-
newLevel
)
sections
.
splice
(
newLevel
-
1
)
// Drop deeper levels
sections
[
sections
.
length
-
1
]
++
}
// Generate chapter number
currentChapter
=
sections
.
join
(
'.'
)
// Set level and title
level
=
newLevel
currentTitle
=
title
}
level
=
newLevel
// Update current level
if
(
descriptionMatch
)
{
// Create chapter number and entry
const
chapter
=
sections
.
join
(
'.'
)
result
.
push
({
title
,
level
,
desc
:
''
,
// Will be updated if a description follows
chapter
:
level
===
1
?
'标题'
:
`第
${
chapter
}
章`
,
})
}
else
if
(
descriptionMatch
)
{
const
desc
=
descriptionMatch
[
1
].
trim
()
result
.
push
({
title
:
currentTitle
,
level
,
desc
,
chapter
:
`第
${
currentChapter
}
章`
})
if
(
result
.
length
>
0
)
{
result
[
result
.
length
-
1
].
desc
=
desc
// Attach description to the last entry
}
}
})
return
result
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论