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
66a4eb6f
Commit
66a4eb6f
authored
Dec 19, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:没有记录时不允许清空
parent
f72a780f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
src/pages/ChatTactics/TacticsChat.tsx
+13
-1
src/pages/ChatTactics/TacticsHome.tsx
+0
-2
No files found.
src/pages/ChatTactics/TacticsChat.tsx
View file @
66a4eb6f
...
...
@@ -23,6 +23,7 @@ import { useAppDispatch, useAppSelector } from '@/store/hook'
import
ScrollBtoIcon
from
'@/assets/svg/scrollBto.svg?react'
import
{
setIsAsking
}
from
'@/store/chatSlice'
import
SdreamLoading
from
'@/components/SdreamLoading'
import
useToast
from
'@/hooks/useToast'
export
const
TacticsChat
:
React
.
FC
=
()
=>
{
const
{
id
}
=
useParams
<
{
id
:
string
}
>
()
...
...
@@ -60,6 +61,7 @@ export const TacticsChat: React.FC = () => {
const
isAsking
=
useAppSelector
((
state
:
RootState
)
=>
state
.
chat
.
isAsking
)
const
[
searchParams
]
=
useSearchParams
()
const
hasFetched
=
useRef
(
false
)
const
showToast
=
useToast
()
// 使用 useLocalStorageState 管理 token,与原有逻辑保持一致
const
[
token
,
setToken
]
=
useLocalStorageState
<
string
|
undefined
>
(
'__TOKEN__'
,
{
defaultValue
:
''
,
...
...
@@ -664,8 +666,18 @@ export const TacticsChat: React.FC = () => {
},
[])
const
handleOpenClearConfirm
=
useCallback
(()
=>
{
// 检查是否有对话记录(排除 system 角色)
const
hasConversationRecords
=
allItems
.
some
(
item
=>
item
.
role
!==
'system'
)
// 检查是否有历史记录
const
hasHistoryRecords
=
hasHistory
===
true
// 如果两者都没有,显示提示并返回
if
(
!
hasConversationRecords
&&
!
hasHistoryRecords
)
{
showToast
(
'暂无记录'
,
'default'
)
return
}
// 有记录时正常打开确认弹窗
setShowClearConfirm
(
true
)
},
[])
},
[
allItems
,
hasHistory
,
showToast
])
useEffect
(()
=>
{
if
(
id
)
{
...
...
src/pages/ChatTactics/TacticsHome.tsx
View file @
66a4eb6f
...
...
@@ -204,8 +204,6 @@ export const TacticsHome: React.FC = () => {
login
()
},
[])
// 处理清除记录
return
(
<
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