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
0b968cbd
Commit
0b968cbd
authored
Dec 11, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:常见问题只获取sessionStorage中值
parent
407bb3c3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
src/pages/Home/HomeNew.tsx
+17
-7
No files found.
src/pages/Home/HomeNew.tsx
View file @
0b968cbd
...
...
@@ -87,15 +87,12 @@ export const Home: React.FC = () => {
setIsDataLoaded
(
false
)
// 重置加载状态
try
{
// 获取当前的 toolId,
优先从 sessionStorage 获取,其次从 Redux
获取
// 获取当前的 toolId,
只从 sessionStorage
获取
const
sessionToolId
=
safeSessionStorageGetItem
(
'currentToolId'
)
||
''
const
searchParams
=
new
URLSearchParams
(
location
.
search
)
const
urlToolId
=
searchParams
.
get
(
'toolId'
)
||
''
const
finalToolId
=
sessionToolId
||
urlToolId
// 调用接口重新获取问题列表
const
res
=
await
fetchEfficiencyQuestionList
({
toolId
:
final
ToolId
,
toolId
:
session
ToolId
,
})
if
(
res
&&
res
.
data
&&
res
.
data
.
questions
)
{
setOtherQuestions
((
prev
:
any
)
=>
({
...
...
@@ -143,10 +140,10 @@ export const Home: React.FC = () => {
finalToolId
=
storedToolId
||
urlToolId
}
// 调用真实 API 获取常见问题列表,
优先
使用 sessionStorage 中的 currentToolId
// 调用真实 API 获取常见问题列表,
只
使用 sessionStorage 中的 currentToolId
const
sessionToolId
=
safeSessionStorageGetItem
(
'currentToolId'
)
||
''
const
res
=
await
fetchEfficiencyQuestionList
({
toolId
:
sessionToolId
||
finalToolId
,
toolId
:
sessionToolId
,
})
if
(
res
&&
res
.
data
&&
res
.
data
.
questions
)
{
setOtherQuestions
((
prev
:
any
)
=>
({
...
...
@@ -240,6 +237,18 @@ export const Home: React.FC = () => {
}
}
else
{
// 判断是否为站内导航返回
// 如果有 location.state,说明是站内导航,不清除 toolId
// 如果 sessionStorage 中有 toolId,说明可能是从其他页面返回,不清除
// 只有在没有 location.state 且 sessionStorage 也没有 toolId 时,才清除(新标签页)
const
sessionToolId
=
safeSessionStorageGetItem
(
'currentToolId'
)
if
(
!
location
.
state
&&
!
sessionToolId
)
{
// 新标签页,清除残留的 toolId
safeSessionStorageRemoveItem
(
'currentToolId'
)
dispatch
(
clearCurrentToolId
())
}
// 如果有 location.state 或 sessionStorage 中有 toolId,不清除,保留 toolId
initConversation
()
dispatch
(
fetchConversations
())
}
...
...
@@ -247,6 +256,7 @@ export const Home: React.FC = () => {
else
{
// 模拟登录 可以用来测试
res
=
await
fetchLoginByUid
(
'123123'
)
sessionStorage
.
removeItem
(
'currentToolId'
)
if
(
res
.
data
)
{
// 登录成功后先清理旧状态,避免沿用上一次的工具模式
dispatch
(
clearCurrentToolId
())
...
...
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