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
3551e115
Commit
3551e115
authored
Oct 21, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:恢复点赞点踩复制功能
parent
e259f8d3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
44 deletions
+66
-44
src/pages/Chat/components/ChatItem/ChatAnswerOperate.tsx
+66
-44
No files found.
src/pages/Chat/components/ChatItem/ChatAnswerOperate.tsx
View file @
3551e115
...
...
@@ -2,10 +2,15 @@ import { Button, Tooltip } from '@heroui/react'
import
{
useRef
,
useState
}
from
'react'
import
{
useDebounceFn
}
from
'ahooks'
import
type
{
Answer
}
from
'@/types/chat'
import
LikeIcon
from
'@/assets/svg/zan.svg?react'
import
LikeIconA
from
'@/assets/svg/zanA.svg?react'
import
UnLikeIcon
from
'@/assets/svg/cai.svg?react'
import
UnLikeIconA
from
'@/assets/svg/caiA.svg?react'
import
CopyIcon
from
'@/assets/svg/copy.svg?react'
import
CollectIcon
from
'@/assets/svg/shouc.svg?react'
import
CollectIconA
from
'@/assets/svg/shoucA.svg?react'
import
useToast
from
'@/hooks/useToast'
import
{
fetchCancelCollection
,
fetchSubmitCollection
}
from
'@/api/chat'
import
{
fetchCancelCollection
,
fetchSubmitCollection
,
fetchSubmitFeedback
}
from
'@/api/chat'
import
{
UnLikeModal
}
from
'@/components/UnLikeModal'
interface
ChatAnswerOperateProps
{
...
...
@@ -14,8 +19,8 @@ interface ChatAnswerOperateProps {
export
const
ChatAnswerOperate
:
React
.
FC
<
ChatAnswerOperateProps
>
=
({
answer
})
=>
{
const
showToast
=
useToast
()
const
[
isCollect
,
setIsCollect
]
=
useState
(
answer
.
collectionFlag
)
//
const [isLike, setIsLike] = useState(answer.feedbackStatus === '01')
//
const [isUnLike, setIsUnLike] = useState(answer.feedbackStatus === '02')
const
[
isLike
,
setIsLike
]
=
useState
(
answer
.
feedbackStatus
===
'01'
)
const
[
isUnLike
,
setIsUnLike
]
=
useState
(
answer
.
feedbackStatus
===
'02'
)
const
[
isOpenUnLikeModal
,
setIsOpenUnLikeOpen
]
=
useState
(
false
)
const
isProcessingRef
=
useRef
(
false
)
...
...
@@ -53,42 +58,42 @@ export const ChatAnswerOperate: React.FC<ChatAnswerOperateProps> = ({ answer })
}
},
{
wait
:
200
})
//
const handleLike = useDebounceFn(async () => {
//
if (!isLike) {
//
setIsLike(true)
//
setIsUnLike(false)
//
await fetchSubmitFeedback({
//
recordId: answer.recordId,
//
feedbackStatus: '01',
//
content: '',
//
})
//
showToast('感谢您的反馈', 'success', {
//
icon: '🙏🏻',
//
})
//
}
//
else {
//
setIsLike(false)
//
await fetchSubmitFeedback({
//
recordId: answer.recordId,
//
feedbackStatus: '00',
//
content: '',
//
})
//
}
//
})
const
handleLike
=
useDebounceFn
(
async
()
=>
{
if
(
!
isLike
)
{
setIsLike
(
true
)
setIsUnLike
(
false
)
await
fetchSubmitFeedback
({
recordId
:
answer
.
recordId
,
feedbackStatus
:
'01'
,
content
:
''
,
})
showToast
(
'感谢您的反馈'
,
'success'
,
{
icon
:
'🙏🏻'
,
})
}
else
{
setIsLike
(
false
)
await
fetchSubmitFeedback
({
recordId
:
answer
.
recordId
,
feedbackStatus
:
'00'
,
content
:
''
,
})
}
})
//
const handleUnLike = async () => {
//
if (!isUnLike) {
//
setIsOpenUnLikeOpen(true)
//
}
//
else {
//
setIsUnLike(false)
//
await fetchSubmitFeedback({
//
recordId: answer.recordId,
//
feedbackStatus: '00',
//
content: '',
//
})
//
}
//
}
const
handleUnLike
=
async
()
=>
{
if
(
!
isUnLike
)
{
setIsOpenUnLikeOpen
(
true
)
}
else
{
setIsUnLike
(
false
)
await
fetchSubmitFeedback
({
recordId
:
answer
.
recordId
,
feedbackStatus
:
'00'
,
content
:
''
,
})
}
}
const
handleClose
=
(
isSubmit
?:
boolean
)
=>
{
setIsOpenUnLikeOpen
(
false
)
...
...
@@ -100,24 +105,41 @@ export const ChatAnswerOperate: React.FC<ChatAnswerOperateProps> = ({ answer })
})
}
}
const
handleCopy
=
async
()
=>
{
try
{
await
navigator
.
clipboard
.
writeText
(
answer
.
answer
)
showToast
(
'复制成功!'
,
'success'
)
}
catch
{
// 如果 clipboard API 不可用,使用传统方法
const
textArea
=
document
.
createElement
(
'textarea'
)
textArea
.
value
=
answer
.
answer
document
.
body
.
appendChild
(
textArea
)
textArea
.
select
()
document
.
execCommand
(
'copy'
)
document
.
body
.
removeChild
(
textArea
)
showToast
(
'复制成功!'
,
'success'
)
}
}
return
(
<
div
className=
"sm:mt-[12px] flex gap-[4px] justify-end"
>
{
/* 点赞 */
}
{
/*
<Tooltip color="foreground" content={isLike ? '取消点赞' : '点赞'} className="capitalize">
<
Tooltip
color=
"foreground"
content=
{
isLike
?
'取消点赞'
:
'点赞'
}
className=
"capitalize"
>
<
Button
variant=
"light"
isIconOnly
aria
-
label=
"LikeIcon"
onPress=
{
handleLike
.
run
}
>
{
isLike
?
<
LikeIconA
/>
:
<
LikeIcon
/>
}
</
Button
>
</Tooltip>
*/
}
</
Tooltip
>
{
/* 点踩 */
}
{
/*
<Tooltip color="foreground" content={isUnLike ? '取消点踩' : '点踩'} className="capitalize">
<
Tooltip
color=
"foreground"
content=
{
isUnLike
?
'取消点踩'
:
'点踩'
}
className=
"capitalize"
>
<
Button
variant=
"light"
isIconOnly
aria
-
label=
"UnLikeIcon"
onPress=
{
handleUnLike
}
>
{
isUnLike
?
<
UnLikeIconA
/>
:
<
UnLikeIcon
/>
}
</
Button
>
</Tooltip>
*/
}
</
Tooltip
>
{
/* 复制 */
}
{
/*
<Tooltip color="foreground" content="复制" className="capitalize">
<
Tooltip
color=
"foreground"
content=
"复制"
className=
"capitalize"
>
<
Button
variant=
"light"
isIconOnly
aria
-
label=
"CopyIcon"
onPress=
{
handleCopy
}
><
CopyIcon
/></
Button
>
</Tooltip>
*/
}
</
Tooltip
>
{
/* 收藏 */
}
<
Tooltip
color=
"foreground"
content=
{
isCollect
?
'取消收藏'
:
'收藏'
}
className=
"capitalize"
>
<
Button
variant=
"light"
isIconOnly
aria
-
label=
"CollectIcon"
onPress=
{
handleCollect
.
run
}
>
...
...
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