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
066d469d
Commit
066d469d
authored
Aug 12, 2025
by
weiw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 产品问答和 您可以试着问我 调用接口
parent
e45f7927
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
8 deletions
+53
-8
src/api/home.ts
+2
-2
src/pages/Home/HomeNew.tsx
+51
-6
No files found.
src/api/home.ts
View file @
066d469d
...
...
@@ -4,6 +4,6 @@ import http from '@/utils/request'
* 查询推荐问题列表
* @params
*/
export
function
fetch
RecommendQuestionList
(
)
{
return
http
.
post
(
'/config-center/api/
question/mobile/v1/get_recommend_question_list'
)
export
function
fetch
QuestionList
(
data
:
any
)
{
return
http
.
post
(
'/config-center/api/
commonconfig/mobile/v1/query_config_list'
,
data
)
}
src/pages/Home/HomeNew.tsx
View file @
066d469d
import
type
React
from
'react'
import
{
useCallback
,
useEffect
,
useState
}
from
'react'
import
{
motion
}
from
'framer-motion'
import
{
Outlet
,
useLocation
}
from
'react-router-dom'
import
{
useEffect
}
from
'react'
import
styles
from
'./Home.module.less'
import
{
QuestionList
}
from
'./components/QuestionList'
import
HomeIcon1
from
'@/assets/homeIcon1.png'
import
HomeIcon2
from
'@/assets/homeIcon2.png'
import
{
RECOMMEND_QUESTIONS_OTHER
,
RECOMMEND_QUESTIONS_PRODUCT
}
from
'@/config/recommendQuestion'
import
{
createConversation
}
from
'@/store/conversationSlice'
import
{
useAppDispatch
}
from
'@/store/hook'
import
{
fetchQuestionList
}
from
'@/api/home'
import
SdreamLoading
from
'@/components/SdreamLoading'
function
getAnimationProps
(
delay
:
number
)
{
return
{
...
...
@@ -37,9 +38,14 @@ function getAnimationProps(delay: number) {
}
export
const
Home
:
React
.
FC
=
()
=>
{
const
[
isLoading
,
setIsLoading
]
=
useState
(
false
)
const
dispatch
=
useAppDispatch
()
const
location
=
useLocation
()
// 使用 useState 替代 useRef
const
[
productQuestions
,
setProductQuestions
]
=
useState
<
any
>
({
content
:
[]
})
const
[
otherQuestions
,
setOtherQuestions
]
=
useState
<
any
>
({
content
:
[]
})
useEffect
(()
=>
{
const
fromCollect
=
location
.
state
?.
fromCollect
// 在组件挂载时执行dispatch,但只执行一次
...
...
@@ -72,8 +78,47 @@ export const Home: React.FC = () => {
// }),
// )
// }
/** 获取qa记录 */
const
getQuestionList
=
useCallback
(
async
()
=>
{
setIsLoading
(
true
)
try
{
const
param
=
{
configTypeList
:
[
'06'
,
'07'
],
}
const
res
=
await
fetchQuestionList
(
param
)
if
(
res
.
ok
)
{
for
(
let
index
=
0
;
index
<
res
.
data
.
length
;
index
++
)
{
const
element
=
res
.
data
[
index
]
if
(
element
.
configType
===
'06'
)
{
setProductQuestions
(
element
)
}
if
(
element
.
configType
===
'07'
)
{
setOtherQuestions
(
element
)
}
}
}
}
catch
(
error
)
{
// 可以在这里添加错误处理逻辑
console
.
error
(
'Failed to fetch chat records:'
,
error
)
}
finally
{
setIsLoading
(
false
)
}
},
[])
useEffect
(()
=>
{
getQuestionList
()
},
[])
return
(
<
div
className=
{
styles
.
homePage
}
>
{
isLoading
&&
(
<
div
className=
"w-full h-full flex justify-center items-center"
>
<
SdreamLoading
/>
</
div
>
)
}
<
div
className=
"h-full w-full"
>
<
div
className=
"box flex flex-col h-full w-full"
>
<
div
className=
"flex-1 items-center pt-[24px] overflow-y-scroll sm:pt-[32px] scrollbar-hide sm:overflow-hidden"
>
...
...
@@ -83,19 +128,19 @@ export const Home: React.FC = () => {
<
div
className=
"flex flex-col gap-[20px]"
>
<
motion
.
div
className=
"w-full hidden sm:block sm:w-auto"
{
...
getAnimationProps
(2)}
>
<
QuestionList
questions=
{
RECOMMEND_QUESTIONS_PRODUCT
}
questions=
{
productQuestions
.
content
}
dotColor=
"#D4CCFF"
background=
"linear-gradient( 180deg, #EBE6FF 0%, #FFFFFF 100%)"
title=
"产品问答"
title=
{
productQuestions
.
configName
}
iconImg=
{
HomeIcon1
}
/>
</
motion
.
div
>
<
motion
.
div
className=
"w-full sm:w-auto"
{
...
getAnimationProps
(3)}
>
<
QuestionList
questions=
{
RECOMMEND_QUESTIONS_OTHER
}
questions=
{
otherQuestions
.
content
}
dotColor=
"#CBECFF"
background=
"linear-gradient( 180deg, #DBF1FF 0%, #FFFFFF 100%)"
title=
"您可以试着问我"
title=
{
otherQuestions
.
configName
}
iconImg=
{
HomeIcon2
}
/>
</
motion
.
div
>
...
...
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