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
9d6b33b3
Commit
9d6b33b3
authored
Oct 23, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:空数据出现时机
parent
f77c4254
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
src/pages/Home/HomeNew.tsx
+11
-2
src/pages/Home/components/QuestionList/QuestionList.tsx
+5
-3
No files found.
src/pages/Home/HomeNew.tsx
View file @
9d6b33b3
...
...
@@ -43,6 +43,7 @@ function getAnimationProps(delay: number) {
export
const
Home
:
React
.
FC
=
()
=>
{
const
viteOutputObj
=
import
.
meta
.
env
.
VITE_OUTPUT_OBJ
||
'open'
const
[
isLoading
,
setIsLoading
]
=
useState
(
false
)
const
[
isDataLoaded
,
setIsDataLoaded
]
=
useState
(
false
)
const
dispatch
=
useAppDispatch
()
const
location
=
useLocation
()
const
hasFetched
=
useRef
(
false
)
...
...
@@ -86,6 +87,7 @@ export const Home: React.FC = () => {
}
finally
{
setIsLoading
(
false
)
setIsDataLoaded
(
true
)
}
},
[])
...
...
@@ -117,6 +119,7 @@ export const Home: React.FC = () => {
...
prev
,
content
:
[],
}))
setIsDataLoaded
(
false
)
// 重置加载状态
try
{
const
res
=
await
fetchEfficiencyQuestionList
({
toolId
})
if
(
res
&&
res
.
data
&&
res
.
data
.
questions
)
{
...
...
@@ -129,10 +132,14 @@ export const Home: React.FC = () => {
catch
(
error
)
{
console
.
error
(
'获取工具相关问题失败:'
,
error
)
}
finally
{
setIsDataLoaded
(
true
)
// 无论成功失败都标记为已加载
}
}
else
if
(
!
isToolBtn
)
{
// 当isToolBtn为false时,恢复原始的configType为07的数据
setOtherQuestions
(
originalOtherQuestions
)
setIsDataLoaded
(
true
)
// 恢复原始数据时标记为已加载
}
},
[
originalOtherQuestions
])
...
...
@@ -239,6 +246,7 @@ export const Home: React.FC = () => {
title=
{
productQuestions
.
configName
}
iconImg=
{
HomeIcon1
}
isToolBtn=
{
isToolBtnActive
}
isLoaded=
{
isDataLoaded
}
/>
</
motion
.
div
>
)
}
...
...
@@ -247,15 +255,16 @@ export const Home: React.FC = () => {
questions=
{
otherQuestions
.
content
}
dotColor=
"#CBECFF"
background=
"linear-gradient(180deg, #F0F8FF 0%, #FFFFFF 50%, #FFFFFF 100%)"
height=
{
isToolBtnActive
?
'
3
88px'
:
'auto'
}
height=
{
isToolBtnActive
?
'
2
88px'
:
'auto'
}
title=
{
otherQuestions
.
configName
}
iconImg=
{
HomeIcon2
}
isToolBtn=
{
isToolBtnActive
}
isLoaded=
{
isDataLoaded
}
/>
</
motion
.
div
>
{
isToolBtnActive
&&
(
<
div
>
<
img
src=
{
SmartIce
}
alt=
"Smart Ice"
className=
"w-[260px] h-[330px] object-contain"
/>
<
img
src=
{
SmartIce
}
alt=
"Smart Ice"
className=
"w-[260px] h-[330px]
mt-[-12px]
object-contain"
/>
</
div
>
)
}
</
div
>
...
...
src/pages/Home/components/QuestionList/QuestionList.tsx
View file @
9d6b33b3
...
...
@@ -19,6 +19,7 @@ interface QuestionListProps {
background
:
string
height
?:
string
isToolBtn
?:
boolean
isLoaded
?:
boolean
}
const
containerVariants
=
{
hidden
:
{},
...
...
@@ -63,8 +64,9 @@ const QuestionListBase: React.FC<QuestionListProps & WithAuthProps> = ({
title
,
iconImg
,
showRefresh
=
true
,
displayCount
:
_displayCount
=
8
,
displayCount
:
_displayCount
=
6
,
isToolBtn
=
false
,
isLoaded
=
false
,
})
=>
{
const
[
isRotating
,
setIsRotating
]
=
useState
(
false
)
const
[
displayedItems
,
setDisplayedItems
]
=
useState
<
string
[]
>
([])
...
...
@@ -72,7 +74,7 @@ const QuestionListBase: React.FC<QuestionListProps & WithAuthProps> = ({
const
dispatch
=
useAppDispatch
()
// 根据 isToolBtn 动态设置 displayCount
const
actualDisplayCount
=
isToolBtn
?
8
:
4
const
actualDisplayCount
=
isToolBtn
?
6
:
4
const
updateDisplayedItems
=
useCallback
(()
=>
{
const
indices
=
getRandomIndices
(
questions
.
length
,
Math
.
min
(
actualDisplayCount
,
questions
.
length
))
...
...
@@ -136,7 +138,7 @@ const QuestionListBase: React.FC<QuestionListProps & WithAuthProps> = ({
)
:
null
}
</
h3
>
{
questions
.
length
===
0
{
isLoaded
&&
questions
&&
questions
.
length
===
0
?
(
<
div
className=
"mt-[80px] flex flex-col items-center justify-center h-[200px]"
>
<
div
className=
"flex flex-col items-center"
>
...
...
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