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
1ad0fc87
Commit
1ad0fc87
authored
Dec 08, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:换一换调用常见问题接口&&按钮高亮2个逻辑
parent
b57c7782
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
9 deletions
+35
-9
src/components/ChatEditor/index.tsx
+1
-2
src/pages/Home/components/QuestionList/QuestionList.tsx
+34
-7
No files found.
src/components/ChatEditor/index.tsx
View file @
1ad0fc87
...
@@ -398,10 +398,9 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
...
@@ -398,10 +398,9 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
const
toolIdStr
=
String
(
tool
.
toolId
)
const
toolIdStr
=
String
(
tool
.
toolId
)
const
isSelectedByState
=
selectedToolId
&&
toolIdStr
===
String
(
selectedToolId
)
const
isSelectedByState
=
selectedToolId
&&
toolIdStr
===
String
(
selectedToolId
)
const
isSelectedBySession
=
!
selectedToolId
&&
sessionToolId
&&
toolIdStr
===
String
(
sessionToolId
)
const
isSelectedBySession
=
!
selectedToolId
&&
sessionToolId
&&
toolIdStr
===
String
(
sessionToolId
)
const
isSelectedByUrl
=
!
selectedToolId
&&
!
sessionToolId
&&
toolIdFromUrl
&&
toolIdStr
===
String
(
toolIdFromUrl
)
// 通用模式高亮:路由内没有 toolId 或 toolId 为空时默认高亮,点击后也要高亮
// 通用模式高亮:路由内没有 toolId 或 toolId 为空时默认高亮,点击后也要高亮
const
isGeneralMode
=
tool
.
toolName
===
'通用模式'
&&
isToolBtnActive
&&
!
selectedToolId
&&
!
sessionToolId
&&
!
toolIdFromUrl
const
isGeneralMode
=
tool
.
toolName
===
'通用模式'
&&
isToolBtnActive
&&
!
selectedToolId
&&
!
sessionToolId
&&
!
toolIdFromUrl
const
isSelected
=
isSelectedByState
||
isSelectedBySession
||
is
SelectedByUrl
||
is
GeneralMode
const
isSelected
=
isSelectedByState
||
isSelectedBySession
||
isGeneralMode
const
baseBtnClass
const
baseBtnClass
=
'w-auto h-[32px] px-3 rounded-full shadow-none text-[12px] flex items-center gap-2 transition-all duration-200 border'
=
'w-auto h-[32px] px-3 rounded-full shadow-none text-[12px] flex items-center gap-2 transition-all duration-200 border'
...
...
src/pages/Home/components/QuestionList/QuestionList.tsx
View file @
1ad0fc87
...
@@ -6,6 +6,7 @@ import { useCallback, useEffect, useState } from 'react'
...
@@ -6,6 +6,7 @@ import { useCallback, useEffect, useState } from 'react'
import
{
useNavigate
}
from
'react-router-dom'
import
{
useNavigate
}
from
'react-router-dom'
import
Refresh
from
'@/assets/svg/refresh.svg?react'
import
Refresh
from
'@/assets/svg/refresh.svg?react'
import
{
type
WithAuthProps
,
withAuth
}
from
'@/auth/withAuth'
import
{
type
WithAuthProps
,
withAuth
}
from
'@/auth/withAuth'
import
{
fetchEfficiencyQuestionList
}
from
'@/api/home'
import
{
useAppDispatch
,
useAppSelector
}
from
'@/store/hook'
import
{
useAppDispatch
,
useAppSelector
}
from
'@/store/hook'
import
{
createConversation
,
setCurrentConversation
,
setShouldSendQuestion
}
from
'@/store/conversationSlice'
import
{
createConversation
,
setCurrentConversation
,
setShouldSendQuestion
}
from
'@/store/conversationSlice'
import
{
safeSessionStorageGetItem
}
from
'@/lib/utils'
import
{
safeSessionStorageGetItem
}
from
'@/lib/utils'
...
@@ -73,6 +74,7 @@ const QuestionListBase: React.FC<QuestionListProps & WithAuthProps> = ({
...
@@ -73,6 +74,7 @@ const QuestionListBase: React.FC<QuestionListProps & WithAuthProps> = ({
const
[
isRotating
,
setIsRotating
]
=
useState
(
false
)
const
[
isRotating
,
setIsRotating
]
=
useState
(
false
)
const
[
displayedItems
,
setDisplayedItems
]
=
useState
<
string
[]
>
([])
const
[
displayedItems
,
setDisplayedItems
]
=
useState
<
string
[]
>
([])
const
[
isClicking
,
setIsClicking
]
=
useState
(
false
)
const
[
isClicking
,
setIsClicking
]
=
useState
(
false
)
const
[
fetchedQuestions
,
setFetchedQuestions
]
=
useState
<
string
[]
|
null
>
(
null
)
const
dispatch
=
useAppDispatch
()
const
dispatch
=
useAppDispatch
()
const
navigate
=
useNavigate
()
const
navigate
=
useNavigate
()
const
{
currentConversationId
,
conversations
,
currentToolId
}
=
useAppSelector
(
state
=>
state
.
conversation
)
const
{
currentConversationId
,
conversations
,
currentToolId
}
=
useAppSelector
(
state
=>
state
.
conversation
)
...
@@ -80,15 +82,40 @@ const QuestionListBase: React.FC<QuestionListProps & WithAuthProps> = ({
...
@@ -80,15 +82,40 @@ const QuestionListBase: React.FC<QuestionListProps & WithAuthProps> = ({
// 根据 isToolBtn 动态设置 displayCount
// 根据 isToolBtn 动态设置 displayCount
const
actualDisplayCount
=
isToolBtn
?
6
:
4
const
actualDisplayCount
=
isToolBtn
?
6
:
4
const
updateDisplayedItems
=
useCallback
(()
=>
{
const
updateDisplayedItems
=
useCallback
(
const
indices
=
getRandomIndices
(
questions
.
length
,
Math
.
min
(
actualDisplayCount
,
questions
.
length
))
(
customQuestions
?:
string
[])
=>
{
setDisplayedItems
(
indices
.
map
(
index
=>
questions
[
index
]))
const
sourceQuestions
=
(
customQuestions
&&
customQuestions
.
length
>
0
)
},
[
questions
,
actualDisplayCount
])
?
customQuestions
:
(
fetchedQuestions
&&
fetchedQuestions
.
length
>
0
?
fetchedQuestions
:
questions
)
if
(
!
sourceQuestions
.
length
)
{
return
}
const
indices
=
getRandomIndices
(
sourceQuestions
.
length
,
Math
.
min
(
actualDisplayCount
,
sourceQuestions
.
length
))
setDisplayedItems
(
indices
.
map
(
index
=>
sourceQuestions
[
index
]))
},
[
questions
,
fetchedQuestions
,
actualDisplayCount
],
)
const
handleRefresh
=
()
=>
{
const
handleRefresh
=
async
()
=>
{
setIsRotating
(
true
)
setIsRotating
(
true
)
updateDisplayedItems
()
const
toolId
=
safeSessionStorageGetItem
(
'currentToolId'
)
||
''
setIsRotating
(
false
)
try
{
const
res
=
await
fetchEfficiencyQuestionList
({
toolId
})
const
newQuestions
=
res
?.
data
?.
questions
as
string
[]
|
undefined
if
(
newQuestions
?.
length
)
{
setFetchedQuestions
(
newQuestions
)
updateDisplayedItems
(
newQuestions
)
return
}
updateDisplayedItems
()
}
catch
(
error
)
{
console
.
error
(
'刷新常见问题失败:'
,
error
)
updateDisplayedItems
()
}
finally
{
setIsRotating
(
false
)
}
}
}
const
handleClick
=
(
item
:
string
)
=>
{
const
handleClick
=
(
item
:
string
)
=>
{
if
(
checkAuth
()
&&
!
isClicking
)
{
if
(
checkAuth
()
&&
!
isClicking
)
{
...
...
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