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
48cf7ad7
Commit
48cf7ad7
authored
Sep 28, 2025
by
weiw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修复收藏页点击新建时的bug
parent
80f76e0f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
19 deletions
+39
-19
src/layouts/Navbar/Navbar.tsx
+14
-10
src/pages/Collect/Collect.tsx
+25
-9
No files found.
src/layouts/Navbar/Navbar.tsx
View file @
48cf7ad7
...
...
@@ -5,7 +5,7 @@ import { useNavigate } from 'react-router-dom'
import
{
useClickAway
,
useSessionStorageState
}
from
'ahooks'
import
styles
from
'./Navbar.module.less'
import
{
NavBarItem
}
from
'./components/NavBarItem'
import
{
clearNavigationFlag
}
from
'@/store/conversationSlice'
import
{
clearNavigationFlag
,
createConversation
}
from
'@/store/conversationSlice'
import
type
{
WithAuthProps
}
from
'@/auth/withAuth'
import
{
withAuth
}
from
'@/auth/withAuth'
import
{
NAV_BAR_ITEMS
}
from
'@/config/nav'
...
...
@@ -24,13 +24,13 @@ const NavbarBase: React.FC<NavbarProps & WithAuthProps> = ({ isHistoryVisible, c
const
{
currentConversationId
,
shouldNavigateToNewConversation
}
=
useAppSelector
(
state
=>
state
.
conversation
)
//
const handleCreateConversation = () => {
//
dispatch(createConversation({
//
conversationData: {},
//
shouldNavigate: true,
//
shouldSendQuestion: '',
//
}))
//
}
const
handleCreateConversation
=
()
=>
{
dispatch
(
createConversation
({
conversationData
:
{},
shouldNavigate
:
true
,
shouldSendQuestion
:
''
,
}))
}
const
[
isH5NavVisible
,
setIsH5NavVisible
]
=
useState
(
isMobile
())
...
...
@@ -51,8 +51,12 @@ const NavbarBase: React.FC<NavbarProps & WithAuthProps> = ({ isHistoryVisible, c
}
if
(
type
===
'add'
)
{
// handleCreateConversation()
navigate
(
'/'
)
if
(
location
.
pathname
.
includes
(
'/chat'
))
{
handleCreateConversation
()
}
else
{
navigate
(
'/'
)
}
onSetHistoryVisible
(
false
)
}
...
...
src/pages/Collect/Collect.tsx
View file @
48cf7ad7
import
{
useEffect
,
useState
}
from
'react'
import
{
useEffect
,
use
Ref
,
use
State
}
from
'react'
import
{
Button
,
Modal
,
ModalBody
,
ModalContent
,
ModalFooter
,
ModalHeader
,
Tooltip
}
from
'@heroui/react'
import
{
motion
}
from
'framer-motion'
import
{
useNavigate
}
from
'react-router-dom'
...
...
@@ -17,6 +17,7 @@ import SdreamLoading from '@/components/SdreamLoading'
export
const
Collect
:
React
.
FC
=
()
=>
{
const
navigate
=
useNavigate
()
const
hasLoaded
=
useRef
(
false
)
const
[
isLoading
,
setIsLoading
]
=
useState
(
false
)
const
[
isOpen
,
setIsOpen
]
=
useState
(
false
)
...
...
@@ -27,20 +28,31 @@ export const Collect: React.FC = () => {
const
[
total
,
setTotal
]
=
useState
(
0
)
const
getCollectList
=
async
()
=>
{
// 防止重复调用
if
(
hasLoaded
.
current
)
{
return
}
hasLoaded
.
current
=
true
setIsLoading
(
true
)
const
params
=
{
pageNum
,
pageSize
,
}
const
res
=
await
fetchQueryCollectionList
(
params
)
let
timer
=
null
as
any
timer
=
setTimeout
(()
=>
{
setCollectList
(
[...
collect
List
,
...
res
.
data
.
records
])
try
{
const
res
=
await
fetchQueryCollectionList
(
params
)
// 使用函数式更新确保获取最新的 collectList 值
setCollectList
(
(
prevList
:
any
)
=>
[...
prev
List
,
...
res
.
data
.
records
])
setTotal
(
res
.
data
.
total
)
}
catch
(
error
)
{
console
.
error
(
'获取收藏列表失败:'
,
error
)
hasLoaded
.
current
=
false
// 出错时重置标志位
}
finally
{
setIsLoading
(
false
)
clearTimeout
(
timer
)
timer
=
null
},
500
)
}
}
const
handleDelete
=
(
item
:
any
)
=>
{
...
...
@@ -79,7 +91,11 @@ export const Collect: React.FC = () => {
useEffect
(()
=>
{
getCollectList
()
},
[
pageNum
])
// 清理函数,在组件卸载时重置标志位
return
()
=>
{
hasLoaded
.
current
=
false
}
},
[])
return
(
<
div
className=
{
styles
.
scrollView
}
>
<
div
className=
{
`${styles.collectPage} relative`
}
>
...
...
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