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
48808e81
Commit
48808e81
authored
Dec 16, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:用户中心隐藏收藏
parent
bb6b1466
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
11 deletions
+23
-11
src/pages/Chat/components/ChatItem/ChatAnswerOperate.tsx
+19
-7
src/pages/ChatTactics/TacticsChat.tsx
+4
-4
No files found.
src/pages/Chat/components/ChatItem/ChatAnswerOperate.tsx
View file @
48808e81
import
{
Button
,
Tooltip
}
from
'@heroui/react'
import
{
Button
,
Tooltip
}
from
'@heroui/react'
import
{
useMemo
,
useRef
,
useState
}
from
'react'
import
{
useMemo
,
useRef
,
useState
}
from
'react'
import
{
useLocation
}
from
'react-router-dom'
import
{
useDebounceFn
}
from
'ahooks'
import
{
useDebounceFn
}
from
'ahooks'
import
type
{
Answer
}
from
'@/types/chat'
import
type
{
Answer
}
from
'@/types/chat'
import
LikeIcon
from
'@/assets/svg/zan.svg?react'
import
LikeIcon
from
'@/assets/svg/zan.svg?react'
...
@@ -19,9 +18,7 @@ interface ChatAnswerOperateProps {
...
@@ -19,9 +18,7 @@ interface ChatAnswerOperateProps {
}
}
export
const
ChatAnswerOperate
:
React
.
FC
<
ChatAnswerOperateProps
>
=
({
answer
})
=>
{
export
const
ChatAnswerOperate
:
React
.
FC
<
ChatAnswerOperateProps
>
=
({
answer
})
=>
{
const
showToast
=
useToast
()
const
showToast
=
useToast
()
const
location
=
useLocation
()
// 兜底读取缓存的 tacticsMeta(会话从 tactics 打开的元信息)
const
searchParams
=
new
URLSearchParams
(
location
.
search
)
// 路由未携带 from=tactics 时,兜底读取缓存的 tacticsMeta
const
tacticsMetaFromStorage
=
useMemo
(()
=>
{
const
tacticsMetaFromStorage
=
useMemo
(()
=>
{
const
raw
=
sessionStorage
.
getItem
(
'tacticsMeta'
)
const
raw
=
sessionStorage
.
getItem
(
'tacticsMeta'
)
if
(
!
raw
)
if
(
!
raw
)
...
@@ -34,7 +31,22 @@ export const ChatAnswerOperate: React.FC<ChatAnswerOperateProps> = ({ answer })
...
@@ -34,7 +31,22 @@ export const ChatAnswerOperate: React.FC<ChatAnswerOperateProps> = ({ answer })
}
}
},
[])
},
[])
const
isFromTactics
=
searchParams
.
get
(
'from'
)
===
'tactics'
||
tacticsMetaFromStorage
?.
from
===
'tactics'
// 兜底读取缓存的 userMeta(会话从用户视角打开的元信息)
const
userMetaFromStorage
=
useMemo
(()
=>
{
const
raw
=
sessionStorage
.
getItem
(
'userMeta'
)
if
(
!
raw
)
return
undefined
try
{
return
JSON
.
parse
(
raw
)
}
catch
{
return
undefined
}
},
[])
// 规则:当 sessionStorage 中存在 userMeta 或 tacticsMeta 时,统一隐藏收藏按钮
const
shouldHideCollect
=
!!
userMetaFromStorage
||
!!
tacticsMetaFromStorage
const
[
isCollect
,
setIsCollect
]
=
useState
(
answer
.
collectionFlag
)
const
[
isCollect
,
setIsCollect
]
=
useState
(
answer
.
collectionFlag
)
const
[
isLike
,
setIsLike
]
=
useState
(
answer
.
feedbackStatus
===
'01'
)
const
[
isLike
,
setIsLike
]
=
useState
(
answer
.
feedbackStatus
===
'01'
)
const
[
isUnLike
,
setIsUnLike
]
=
useState
(
answer
.
feedbackStatus
===
'02'
)
const
[
isUnLike
,
setIsUnLike
]
=
useState
(
answer
.
feedbackStatus
===
'02'
)
...
@@ -153,8 +165,8 @@ export const ChatAnswerOperate: React.FC<ChatAnswerOperateProps> = ({ answer })
...
@@ -153,8 +165,8 @@ export const ChatAnswerOperate: React.FC<ChatAnswerOperateProps> = ({ answer })
<
Tooltip
color=
"foreground"
content=
"复制"
className=
"capitalize"
>
<
Tooltip
color=
"foreground"
content=
"复制"
className=
"capitalize"
>
<
Button
variant=
"light"
isIconOnly
aria
-
label=
"CopyIcon"
onPress=
{
handleCopy
}
><
CopyIcon
/></
Button
>
<
Button
variant=
"light"
isIconOnly
aria
-
label=
"CopyIcon"
onPress=
{
handleCopy
}
><
CopyIcon
/></
Button
>
</
Tooltip
>
</
Tooltip
>
{
/* 收藏(当路由未标记 from=tactics
时不
展示) */
}
{
/* 收藏(当路由未标记 from=tactics
且不存在 userMeta 缓存时才
展示) */
}
{
!
isFromTactics
&&
(
{
!
shouldHideCollect
&&
(
<
Tooltip
color=
"foreground"
content=
{
isCollect
?
'取消收藏'
:
'收藏'
}
className=
"capitalize"
>
<
Tooltip
color=
"foreground"
content=
{
isCollect
?
'取消收藏'
:
'收藏'
}
className=
"capitalize"
>
<
Button
variant=
"light"
isIconOnly
aria
-
label=
"CollectIcon"
onPress=
{
handleCollect
.
run
}
>
<
Button
variant=
"light"
isIconOnly
aria
-
label=
"CollectIcon"
onPress=
{
handleCollect
.
run
}
>
{
isCollect
?
<
CollectIconA
/>
:
<
CollectIcon
/>
}
{
isCollect
?
<
CollectIconA
/>
:
<
CollectIcon
/>
}
...
...
src/pages/ChatTactics/TacticsChat.tsx
View file @
48808e81
...
@@ -600,7 +600,7 @@ export const TacticsChat: React.FC = () => {
...
@@ -600,7 +600,7 @@ export const TacticsChat: React.FC = () => {
const
hasUserMeta
=
!!
userMeta
const
hasUserMeta
=
!!
userMeta
if
(
hasUserMeta
)
{
if
(
hasUserMeta
)
{
const
mappedNumberType
=
getNumberTypeWithUserMeta
(
'A02'
,
true
)
const
mappedNumberType
=
getNumberTypeWithUserMeta
(
'A02'
,
true
)
await
handleSubmitQuestion
(
'策略分析'
,
undefined
,
undefined
,
{
await
handleSubmitQuestion
(
undefined
,
undefined
,
undefined
,
{
busiType
:
'02'
,
busiType
:
'02'
,
recordType
:
mappedNumberType
,
recordType
:
mappedNumberType
,
includeQuestion
:
false
,
includeQuestion
:
false
,
...
@@ -609,7 +609,7 @@ export const TacticsChat: React.FC = () => {
...
@@ -609,7 +609,7 @@ export const TacticsChat: React.FC = () => {
})
})
}
}
else
{
else
{
await
handleSubmitQuestion
(
'策略分析'
,
undefined
,
undefined
,
{
await
handleSubmitQuestion
(
undefined
,
undefined
,
undefined
,
{
busiType
:
'02'
,
busiType
:
'02'
,
recordType
:
'A01'
,
recordType
:
'A01'
,
includeQuestion
:
false
,
includeQuestion
:
false
,
...
@@ -679,7 +679,7 @@ export const TacticsChat: React.FC = () => {
...
@@ -679,7 +679,7 @@ export const TacticsChat: React.FC = () => {
if
(
hasUserMeta
)
{
if
(
hasUserMeta
)
{
const
mappedNumberType
=
getNumberTypeWithUserMeta
(
'A02'
,
true
)
const
mappedNumberType
=
getNumberTypeWithUserMeta
(
'A02'
,
true
)
handleSubmitQuestion
(
handleSubmitQuestion
(
'策略分析'
,
undefined
,
undefined
,
undefined
,
undefined
,
undefined
,
{
{
...
@@ -693,7 +693,7 @@ export const TacticsChat: React.FC = () => {
...
@@ -693,7 +693,7 @@ export const TacticsChat: React.FC = () => {
}
}
else
{
else
{
handleSubmitQuestion
(
handleSubmitQuestion
(
'策略分析'
,
undefined
,
undefined
,
undefined
,
undefined
,
undefined
,
{
{
...
...
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