Commit 5b8c978b by Liu

fix:策略分析&用户分析时不展示收藏按钮

parent b9deab47
import { Button, Tooltip } from '@heroui/react'
import { useRef, useState } from 'react'
import { useLocation } from 'react-router-dom'
import { useDebounceFn } from 'ahooks'
import type { Answer } from '@/types/chat'
import LikeIcon from '@/assets/svg/zan.svg?react'
......@@ -18,6 +19,9 @@ interface ChatAnswerOperateProps {
}
export const ChatAnswerOperate: React.FC<ChatAnswerOperateProps> = ({ answer }) => {
const showToast = useToast()
const location = useLocation()
const searchParams = new URLSearchParams(location.search)
const isFromTactics = searchParams.get('from') === 'tactics'
const [isCollect, setIsCollect] = useState(answer.collectionFlag)
const [isLike, setIsLike] = useState(answer.feedbackStatus === '01')
const [isUnLike, setIsUnLike] = useState(answer.feedbackStatus === '02')
......@@ -136,12 +140,14 @@ export const ChatAnswerOperate: React.FC<ChatAnswerOperateProps> = ({ answer })
<Tooltip color="foreground" content="复制" className="capitalize">
<Button variant="light" isIconOnly aria-label="CopyIcon" onPress={handleCopy}><CopyIcon /></Button>
</Tooltip>
{/* 收藏 */}
<Tooltip color="foreground" content={isCollect ? '取消收藏' : '收藏'} className="capitalize">
<Button variant="light" isIconOnly aria-label="CollectIcon" onPress={handleCollect.run}>
{isCollect ? <CollectIconA /> : <CollectIcon />}
</Button>
</Tooltip>
{/* 收藏(当路由未标记 from=tactics 时展示) */}
{!isFromTactics && (
<Tooltip color="foreground" content={isCollect ? '取消收藏' : '收藏'} className="capitalize">
<Button variant="light" isIconOnly aria-label="CollectIcon" onPress={handleCollect.run}>
{isCollect ? <CollectIconA /> : <CollectIcon />}
</Button>
</Tooltip>
)}
{/* 重新生成 */}
{/* <Tooltip color="foreground" content="重新生成" className="capitalize">
<Button variant="light" isIconOnly aria-label="ReloadIcon"><ReloadIcon /></Button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment