Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sdream-ai-fe
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
侯明涛
sdream-ai-fe
Commits
094f3d02
Commit
094f3d02
authored
Feb 18, 2025
by
HoMeTown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 推荐问更新
parent
e7b1e623
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
18 deletions
+19
-18
src/config/recommendQuestion.ts
+11
-15
src/layouts/Navbar/components/User/index.tsx
+1
-1
src/pages/Chat/Chat.tsx
+2
-1
src/pages/Chat/components/ChatItem/ChatAnswerBox.tsx
+1
-1
src/pages/Chat/components/ChatItem/ChatAnswerParser.tsx
+4
-0
No files found.
src/config/recommendQuestion.ts
View file @
094f3d02
...
...
@@ -2,25 +2,21 @@
* 推荐问题 - 其他
*/
export
const
RECOMMEND_QUESTIONS_OTHER
=
[
'润爱家是华润自己的产品还是平安承保?理赔找谁?'
,
'离职或者退休后还能买润爱家吗?'
,
'福享传承终身护理保险产品特色有哪些?'
,
'投保润爱家门诊可以给报销吗?'
,
'祖父母、外祖父母可以给孩子买保险吗?'
,
'上班有社保,还有必要再买份商业养老保险吗?'
,
'年金险和增额终身寿险应该怎么选?'
,
'3.0%预定利率下调有什么影响?'
,
'预定利率下调,重疾险会涨价吗?'
,
'保险有了社保还需要买商业保险吗?'
,
'个人养老账户如何开通?'
,
'有社保还有必要买商业保险吗?'
,
'个人养老金全国推行对个人有哪些好处?'
,
'润爱家适合哪些人群购买?'
,
]
/**
* 推荐问题 - 产品
*/
export
const
RECOMMEND_QUESTIONS_PRODUCT
=
[
'润爱家投保前需要体检吗'
,
'和谐喜乐一生少儿终身重大疾病产品特色是什么?'
,
'家属没有医保,是否可以投保润爱家?'
,
'福寿双全A01产品保费要求是什么'
,
'润爱家等待期是多久?'
,
'润爱家保障责任有哪些?'
,
'金医保2号百万医疗险费率调整规则有哪些?'
,
'守护者长期意外伤害保险期间是多久?'
,
'爱守护3.0重大疾病保险投保年龄要求?'
,
'爱守护3.0重大疾病保险保多久?'
,
'福临门两全保险A款适合哪些人群购买?'
,
'福临门两全保险A款对银行账户有要求吗?'
,
]
src/layouts/Navbar/components/User/index.tsx
View file @
094f3d02
...
...
@@ -52,7 +52,7 @@ export const UserLogin: React.FC<UserProps> = ({ onLogout }) => {
<
DropdownMenu
variant=
"flat"
aria
-
label=
"Dynamic Actions"
items=
{
items
}
>
{
item
=>
(
<
DropdownItem
on
Click
=
{
()
=>
handleClick
(
item
.
key
)
}
on
Press
=
{
()
=>
handleClick
(
item
.
key
)
}
key=
{
item
.
key
}
color=
{
item
.
key
===
'logout'
?
'danger'
:
'primary'
}
className=
{
item
.
key
===
'logout'
?
'text-danger'
:
''
}
...
...
src/pages/Chat/Chat.tsx
View file @
094f3d02
...
...
@@ -148,10 +148,11 @@ export const Chat: React.FC = () => {
if
(
msg
?.
type
===
'DATA'
&&
msg
?.
content
?.
code
===
'00000000'
)
{
handleStreamMesageData
(
msg
,
question
)
}
// 超过最大条数
if
(
msg
?.
type
===
'DATA'
&&
msg
?.
content
?.
code
===
'01010005'
)
{
handleChatMaxCount
(
msg
,
question
)
return
}
// 结束
if
(
msg
.
type
===
'END'
)
{
if
(
isNew
)
{
setTimeout
(()
=>
{
...
...
src/pages/Chat/components/ChatItem/ChatAnswerBox.tsx
View file @
094f3d02
...
...
@@ -72,7 +72,7 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex,
</
div
>
{
isTyping
&&
(
<
div
className=
"sm:pl-[62px] mt-[12px]"
>
<
Button
on
Click
=
{
handleStopTyping
}
color=
"primary"
variant=
"bordered"
>
<
Button
on
Press
=
{
handleStopTyping
}
color=
"primary"
variant=
"bordered"
>
停止生成
</
Button
>
</
div
>
...
...
src/pages/Chat/components/ChatItem/ChatAnswerParser.tsx
View file @
094f3d02
...
...
@@ -43,6 +43,7 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
const
[
hideOperate
,
setHideOperate
]
=
useState
(
false
)
const
[
isImageAnswer
,
setIsImageAnswer
]
=
useState
(
false
)
// 提取图片链接
function
extractImageSources
(
htmlString
:
string
):
string
[]
{
const
imgRegex
=
/<img
[^
>
]
+src="
([^
">
]
+
)
"/gi
const
srcRegex
=
/src="
([^
">
]
+
)
"/i
...
...
@@ -61,6 +62,7 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
return
sources
}
// 替换图片链接
function
replaceImageSources
(
str
:
string
,
originalSrcs
:
string
[],
newSrcs
:
string
[]):
string
{
if
(
originalSrcs
.
length
!==
newSrcs
.
length
)
return
str
...
...
@@ -72,6 +74,7 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
},
str
)
}
// 格式化图片回答
async
function
formatImgAnswer
(
str
:
string
)
{
const
imagesSrc
=
extractImageSources
(
str
)
const
res
=
await
fetchGetDocumentLinks
(
imagesSrc
)
...
...
@@ -83,6 +86,7 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
else
{
return
replaceImageSources
(
str
,
imagesSrc
,
[])
}
}
// 处理图片回答
const
handleImageAnswer
=
async
()
=>
{
const
res
=
await
formatImgAnswer
(
formatAnswer
)
setDisplayedText
(
res
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment