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
f520e296
Commit
f520e296
authored
Oct 21, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:问答后增加跳转逻辑
parent
a5a5bf7e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
6 deletions
+39
-6
src/components/ChatEditor/index.tsx
+6
-6
src/pages/Chat/components/ChatItem/ChatAnswerParser.tsx
+25
-0
src/styles/global.less
+8
-0
No files found.
src/components/ChatEditor/index.tsx
View file @
f520e296
...
...
@@ -5,7 +5,6 @@ import { useLocalStorageState, useToggle } from 'ahooks'
import
{
LoginModal
}
from
'../LoginModal'
import
type
{
RootState
}
from
'@/store'
import
SendIcon
from
'@/assets/svg/send.svg?react'
import
dataIcon
from
'@/assets/data-icon.png'
import
efficiencyIcon
from
'@/assets/efficiency-icon.png'
import
{
type
WithAuthProps
,
withAuth
}
from
'@/auth/withAuth'
import
{
useAppSelector
}
from
'@/store/hook'
...
...
@@ -143,12 +142,14 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
onKeyDown=
{
handleKeyDown
}
onPaste=
{
handlePaste
}
suppressContentEditableWarning
data
-
placeholder=
"输入您想问的问题吧~"
style=
{
{
resize
:
'none'
,
maxHeight
:
'48px'
,
marginBottom
:
'40px'
,
}
}
/>
>
</
div
>
<
Tooltip
isOpen=
{
Boolean
(
token
)
&&
showContentTips
&&
!
isAsking
&&
!
content
}
color=
"foreground"
content=
"请输入您的问题📖"
placement=
"top-end"
>
<
Button
className=
"ask-send"
onPress=
{
handleSubmit
}
radius=
"full"
isDisabled=
{
!
content
||
isAsking
}
isIconOnly
color=
"primary"
>
<
SendIcon
/>
...
...
@@ -177,20 +178,19 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
}
}
className=
"dark:text-zinc-500 text-[14px] sm:text-[14px] font-normal text-[#3333334d] pl-4 sm:pl-12 text-left w-[calc(100%-2rem)] truncate"
>
{
placeholders
[
currentPlaceholder
]
}
</
motion
.
p
>
)
}
</
AnimatePresence
>
</
div
>
<
div
className=
"absolute left-4 bottom-2 flex items-center gap-3 pointer-events-auto"
>
<
Button
<
div
className=
"absolute left-4 bottom-2 flex items-center gap-3 pointer-events-auto
pl-[16px]
"
>
{
/*
<Button
className="w-[96px] h-[32px] px-3 rounded-full bg-white border border-[#E6E8EB] shadow-none text-[#111827] text-[12px]"
radius="full"
variant="bordered"
startContent={<img src={dataIcon} alt="数据助手" className="w-5 h-5" />}
>
数据助手
</
Button
>
</Button>
*/
}
<
Button
className=
"w-[96px] h-[32px] px-3 rounded-full bg-white border border-[#E6E8EB] shadow-none text-[#111827] text-[12px]"
radius=
"full"
...
...
src/pages/Chat/components/ChatItem/ChatAnswerParser.tsx
View file @
f520e296
...
...
@@ -42,6 +42,7 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
const
[
isTyping
,
setIsTyping
]
=
useState
(
false
)
const
[
hideOperate
,
setHideOperate
]
=
useState
(
false
)
const
[
isImageAnswer
,
setIsImageAnswer
]
=
useState
(
false
)
const
[
hasProcessedCardList
,
setHasProcessedCardList
]
=
useState
(
false
)
// 添加标记,避免重复处理cardList
function
extractImageSources
(
htmlString
:
string
):
string
[]
{
const
imgRegex
=
/<img
[^
>
]
+src="
([^
">
]
+
)
"/gi
...
...
@@ -90,6 +91,28 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
onComplate
()
}
const
handleCardListUrls
=
()
=>
{
// 如果已经处理过cardList,直接返回,避免重复警告
if
(
hasProcessedCardList
)
{
return
}
if
(
answer
.
cardList
&&
answer
.
cardList
.
length
>
0
)
{
const
cardsWithUrl
=
answer
.
cardList
[
0
].
url
||
''
// eslint-disable-next-line no-console
console
.
log
(
'准备跳转的URL:'
,
cardsWithUrl
)
if
(
cardsWithUrl
)
{
window
.
open
(
cardsWithUrl
,
'_blank'
)
}
else
{
console
.
warn
(
'cardList中的URL为空'
)
}
}
else
{
console
.
warn
(
'cardList为空或不存在'
)
}
setHasProcessedCardList
(
true
)
// 标记已处理
}
useEffect
(()
=>
{
if
(
isStopTyping
)
{
return
...
...
@@ -124,6 +147,8 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
setIsTyping
(
false
)
onComplate
()
}
// 流式输出结束时检查 cardList 中的 URL
handleCardListUrls
()
}
}
},
[
answer
,
currentIndex
])
...
...
src/styles/global.less
View file @
f520e296
...
...
@@ -32,3 +32,11 @@ body {
color: var(--sdream-text-primary);
overflow: hidden;
}
// contentEditable placeholder样式
[contenteditable]:empty:before {
content: attr(data-placeholder);
color: rgba(51,51,51,0.3);
pointer-events: none;
font-size: 15px;
}
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