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
86e1cdf8
Commit
86e1cdf8
authored
Nov 21, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:推荐问新建会话逻辑
parent
12e28b73
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
9 deletions
+28
-9
src/pages/Home/components/QuestionList/QuestionList.tsx
+28
-9
No files found.
src/pages/Home/components/QuestionList/QuestionList.tsx
View file @
86e1cdf8
...
...
@@ -3,10 +3,11 @@ import type React from 'react'
import
{
Image
}
from
'@heroui/image'
import
{
motion
}
from
'framer-motion'
import
{
useCallback
,
useEffect
,
useState
}
from
'react'
import
{
useNavigate
}
from
'react-router-dom'
import
Refresh
from
'@/assets/svg/refresh.svg?react'
import
{
type
WithAuthProps
,
withAuth
}
from
'@/auth/withAuth'
import
{
useAppDispatch
}
from
'@/store/hook'
import
{
createConversation
}
from
'@/store/conversationSlice'
import
{
useAppDispatch
,
useAppSelector
}
from
'@/store/hook'
import
{
createConversation
,
setCurrentConversation
,
setShouldSendQuestion
}
from
'@/store/conversationSlice'
import
emptyIcon
from
'@/assets/empty-icon.png'
interface
QuestionListProps
{
...
...
@@ -72,6 +73,8 @@ const QuestionListBase: React.FC<QuestionListProps & WithAuthProps> = ({
const
[
displayedItems
,
setDisplayedItems
]
=
useState
<
string
[]
>
([])
const
[
isClicking
,
setIsClicking
]
=
useState
(
false
)
const
dispatch
=
useAppDispatch
()
const
navigate
=
useNavigate
()
const
{
currentConversationId
,
conversations
}
=
useAppSelector
(
state
=>
state
.
conversation
)
// 根据 isToolBtn 动态设置 displayCount
const
actualDisplayCount
=
isToolBtn
?
6
:
4
...
...
@@ -89,13 +92,29 @@ const QuestionListBase: React.FC<QuestionListProps & WithAuthProps> = ({
const
handleClick
=
(
item
:
string
)
=>
{
if
(
checkAuth
()
&&
!
isClicking
)
{
setIsClicking
(
true
)
dispatch
(
createConversation
({
conversationData
:
{},
shouldNavigate
:
true
,
shouldSendQuestion
:
item
,
}),
)
// 优先使用当前会话,如果没有则使用第一个会话,如果都没有则创建新会话
const
targetConversationId
=
currentConversationId
||
conversations
[
0
]?.
conversationId
if
(
targetConversationId
)
{
// 使用现有会话
dispatch
(
setCurrentConversation
(
targetConversationId
))
dispatch
(
setShouldSendQuestion
(
item
))
navigate
(
`/chat/
${
targetConversationId
}
`
)
}
else
{
// 如果没有现有会话,仍然创建新会话(向后兼容)
// 这里可以改为提示用户,或者保持创建新会话的逻辑
// 为了最小修改,暂时保持创建新会话的逻辑
dispatch
(
createConversation
({
conversationData
:
{},
shouldNavigate
:
true
,
shouldSendQuestion
:
item
,
}),
)
}
// 防止重复点击
setTimeout
(()
=>
{
setIsClicking
(
false
)
...
...
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