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
af45edef
Commit
af45edef
authored
Aug 12, 2025
by
weiw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:收藏页面增加返回功能
parent
9807cfe4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
10 deletions
+33
-10
src/layouts/Navbar/Navbar.tsx
+12
-0
src/pages/Collect/Collect.tsx
+0
-0
src/pages/Home/HomeNew.tsx
+21
-10
No files found.
src/layouts/Navbar/Navbar.tsx
View file @
af45edef
...
...
@@ -59,6 +59,18 @@ const NavbarBase: React.FC<NavbarProps & WithAuthProps> = ({ isHistoryVisible, c
}
if
(
type
===
'collect'
)
{
// 从URL中提取会话ID并存储到 sessionStorage
const
pathParts
=
location
.
pathname
.
split
(
'/'
)
// 从路径中提取会话ID,获取 chat/ 后面的值
// 查找 'chat' 在路径中的位置,然后获取其后一项作为会话ID
const
chatIndex
=
pathParts
.
indexOf
(
'chat'
)
const
conversationId
=
chatIndex
!==
-
1
&&
pathParts
.
length
>
chatIndex
+
1
?
pathParts
[
chatIndex
+
1
]
:
null
if
(
conversationId
)
{
sessionStorage
.
setItem
(
'currentConversationId'
,
conversationId
)
}
navigate
(
'/collect'
)
}
...
...
src/pages/Collect/Collect.tsx
View file @
af45edef
This diff is collapsed.
Click to expand it.
src/pages/Home/HomeNew.tsx
View file @
af45edef
import
type
React
from
'react'
import
{
motion
}
from
'framer-motion'
import
{
Outlet
}
from
'react-router-dom'
import
{
Outlet
,
useLocation
}
from
'react-router-dom'
import
{
useEffect
}
from
'react'
import
styles
from
'./Home.module.less'
import
{
QuestionList
}
from
'./components/QuestionList'
...
...
@@ -38,16 +38,27 @@ function getAnimationProps(delay: number) {
export
const
Home
:
React
.
FC
=
()
=>
{
const
dispatch
=
useAppDispatch
()
const
location
=
useLocation
()
useEffect
(()
=>
{
// 在组件挂载时执行dispatch
dispatch
(
createConversation
({
conversationData
:
{},
shouldNavigate
:
true
,
shouldSendQuestion
:
''
,
}),
)
},
[])
// 空依赖数组确保只在组件挂载时执行一次
const
fromCollect
=
location
.
state
?.
fromCollect
// 在组件挂载时执行dispatch,但只执行一次
if
(
!
fromCollect
)
{
dispatch
(
createConversation
({
conversationData
:
{},
shouldNavigate
:
true
,
shouldSendQuestion
:
''
,
}),
)
}
// 清除状态以避免下次影响
if
(
location
.
state
?.
fromCollect
)
{
// 使用 replace 替换当前历史记录,清除 state
window
.
history
.
replaceState
({},
document
.
title
,
window
.
location
.
pathname
)
}
},
[])
// const location = useLocation()
// 检查当前路径是否包含 "/chat/"
...
...
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