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
d2762443
Commit
d2762443
authored
Dec 11, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:常见问题初始渲染
parent
0b968cbd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
4 deletions
+36
-4
src/pages/Home/HomeNew.tsx
+36
-4
No files found.
src/pages/Home/HomeNew.tsx
View file @
d2762443
...
@@ -110,6 +110,34 @@ export const Home: React.FC = () => {
...
@@ -110,6 +110,34 @@ export const Home: React.FC = () => {
}
}
},
[
location
.
search
])
},
[
location
.
search
])
// 首页首次挂载时拉取常见问题(强制 toolId 为空,避免带入历史值)
const
handleInitialQuestions
=
useCallback
(
async
()
=>
{
// eslint-disable-next-line no-console
console
.
log
(
'handleInitialQuestions: 首次挂载/登录后初始化常见问题,强制 toolId 为空'
)
setOtherQuestions
((
prev
:
any
)
=>
({
...
prev
,
content
:
[],
}))
setIsDataLoaded
(
false
)
try
{
const
res
=
await
fetchEfficiencyQuestionList
({
toolId
:
''
,
})
if
(
res
&&
res
.
data
&&
res
.
data
.
questions
)
{
setOtherQuestions
((
prev
:
any
)
=>
({
...
prev
,
content
:
res
.
data
.
questions
||
[],
}))
}
}
catch
(
error
)
{
console
.
error
(
'首页初始化常见问题失败:'
,
error
)
}
finally
{
setIsDataLoaded
(
true
)
}
},
[])
// 处理工具按钮点击
// 处理工具按钮点击
const
_handleToolClick
=
useCallback
(
async
(
isToolBtn
:
boolean
,
toolId
?:
string
,
ignoreUrlToolId
?:
boolean
)
=>
{
const
_handleToolClick
=
useCallback
(
async
(
isToolBtn
:
boolean
,
toolId
?:
string
,
ignoreUrlToolId
?:
boolean
)
=>
{
// 提质增效模式 / 数据助手 / 通用模式:都先清空数据,重新拉常见问题
// 提质增效模式 / 数据助手 / 通用模式:都先清空数据,重新拉常见问题
...
@@ -234,6 +262,8 @@ export const Home: React.FC = () => {
...
@@ -234,6 +262,8 @@ export const Home: React.FC = () => {
window
.
dispatchEvent
(
new
CustomEvent
(
'forceResetToGeneralMode'
))
window
.
dispatchEvent
(
new
CustomEvent
(
'forceResetToGeneralMode'
))
initConversation
()
initConversation
()
dispatch
(
fetchConversations
())
dispatch
(
fetchConversations
())
// 登录成功后再拉取一次常见问题,强制 toolId 为空
handleInitialQuestions
()
}
}
}
}
else
{
else
{
...
@@ -281,9 +311,11 @@ export const Home: React.FC = () => {
...
@@ -281,9 +311,11 @@ export const Home: React.FC = () => {
window
.
dispatchEvent
(
new
CustomEvent
(
'forceResetToGeneralMode'
))
window
.
dispatchEvent
(
new
CustomEvent
(
'forceResetToGeneralMode'
))
initConversation
()
initConversation
()
dispatch
(
fetchConversations
())
dispatch
(
fetchConversations
())
// 登录成功后再拉取一次常见问题,强制 toolId 为空
handleInitialQuestions
()
}
}
}
}
},
[
setToken
,
dispatch
])
},
[
setToken
,
dispatch
,
handleInitialQuestions
])
// 监听路由参数变化,提取 userRoles(确保路由参数被正确解析)
// 监听路由参数变化,提取 userRoles(确保路由参数被正确解析)
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -297,9 +329,9 @@ export const Home: React.FC = () => {
...
@@ -297,9 +329,9 @@ export const Home: React.FC = () => {
dispatch
(
clearCurrentToolId
())
dispatch
(
clearCurrentToolId
())
// 2. 清除 sessionStorage 中可能残留的 currentToolId,避免沿用上一次工具模式
// 2. 清除 sessionStorage 中可能残留的 currentToolId,避免沿用上一次工具模式
// sessionStorage.removeItem('currentToolId')
// sessionStorage.removeItem('currentToolId')
// 3. 首页首次挂载时
强制忽略路由中的 toolId,只按通用模式拉常见问题(toolId: '')
// 3. 首页首次挂载时
仅使用空 toolId 拉取常见问题
_handleToolClick
(
false
,
''
,
true
)
handleInitialQuestions
(
)
},
[])
// 依赖数组为空,只在组件挂载时执行一次
},
[
handleInitialQuestions
])
// 依赖数组为空,只在组件挂载时执行一次
return
(
return
(
<
div
className=
{
styles
.
homePage
}
>
<
div
className=
{
styles
.
homePage
}
>
...
...
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