Commit 973af7cc by HoMeTown

chore: 更新heroui事件click to press

parent 90d0c62f
......@@ -127,7 +127,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
/>
<Tooltip isOpen={Boolean(token) && showContentTips && !isAsking && !content} color="foreground" content="请输入您的问题📖" placement="top-end">
<Button className="ask-send" onClick={handleSubmit} radius="full" isDisabled={!content || isAsking} isIconOnly color="primary">
<Button className="ask-send" onPress={handleSubmit} radius="full" isDisabled={!content || isAsking} isIconOnly color="primary">
<SendIcon />
</Button>
</Tooltip>
......
......@@ -89,7 +89,7 @@ export const ConversationModal: React.FC<ConversationModalProps> = ({ isOpen, on
<Button onPress={onClose}>
取消
</Button>
<Button isDisabled={[...selectedKeys].length === 0} color="primary" onClick={handleDelete}>
<Button isDisabled={[...selectedKeys].length === 0} color="primary" onPress={handleDelete}>
删除所选
</Button>
</ModalFooter>
......
......@@ -48,8 +48,8 @@ export const LoginModal: React.FC<LoginModalProps> = ({ isOpen, onClose }) => {
>
</Checkbox>
我已阅读并同意
<Link isExternal onClick={() => handleJump2Protocol('01')} showAnchorIcon underline="hover">《服务协议》</Link>
<Link isExternal onClick={() => handleJump2Protocol('02')} showAnchorIcon underline="hover">《隐私政策》</Link>
<Link isExternal onPress={() => handleJump2Protocol('01')} showAnchorIcon underline="hover">《服务协议》</Link>
<Link isExternal onPress={() => handleJump2Protocol('02')} showAnchorIcon underline="hover">《隐私政策》</Link>
</p>
</ModalBody>
<ModalFooter>
......
......@@ -64,7 +64,7 @@ export const UnLikeModal: React.FC<UnLikeModalProps> = ({ isOpen, onClose, answe
color="primary"
variant="light"
className={`bg-[#F8F8F8] text-left text-[#333] rounded-[23px] data-[hover=true]:bg-[#E5F6FF] data-[hover=true]:text-primary ${item.answerValue === '1' ? 'bg-[#E5F6FF] text-primary' : ''}`}
onClick={() => handleClick(item, index)}
onPress={() => handleClick(item, index)}
>
<div className="w-full text-nowrap text-ellipsis overflow-hidden">
<span>{item.answerName}</span>
......@@ -85,7 +85,7 @@ export const UnLikeModal: React.FC<UnLikeModalProps> = ({ isOpen, onClose, answe
<Button onPress={onClose}>
取消
</Button>
<Button onClick={onSubmit} color="primary">
<Button onPress={onSubmit} color="primary">
提交
</Button>
</ModalFooter>
......
......@@ -43,7 +43,7 @@ export const HistoryBar: React.FC<HistoryBarProps> = ({ isVisible, onSetHistoryV
<div className="pt-[24px] flex flex-col h-full">
<div className="flex gap-[12px] px-[32px] h-[40px] sm:block">
<Input value={searchValue} onValueChange={setSearchValue} classNames={{ inputWrapper: ['bg-white', 'data-[hover=true]:bg-[#fff]', 'group-data-[focus=true]:bg-white', 'rounded-[24px]'] }} placeholder="搜索历史记录" startContent={<SearchIcon />} />
<Button className="flex sm:hidden" onClick={() => onSetHistoryVisible(false)} isIconOnly color="danger">
<Button className="flex sm:hidden" onPress={() => onSetHistoryVisible(false)} isIconOnly color="danger">
<CloseIcon />
</Button>
</div>
......@@ -51,7 +51,7 @@ export const HistoryBar: React.FC<HistoryBarProps> = ({ isVisible, onSetHistoryV
<HistoryBarList onSetHistoryVisible={onSetHistoryVisible} searchValue={searchValue} />
</div>
<div className="text-[12px] border-t-solid border-t-[1px] border-t-[#82969C12] w-full h-[48px] flex items-center justify-center">
<Button onClick={handleOpen} className="w-full" color="primary" variant="light" startContent={<HistoryMenuIcon />}>
<Button onPress={handleOpen} className="w-full" color="primary" variant="light" startContent={<HistoryMenuIcon />}>
<span className="text-[#82969C]">管理对话记录</span>
</Button>
</div>
......
......@@ -62,7 +62,7 @@ export const HistoryBarList: React.FC<HistoryBarListProps> = ({ searchValue, onS
color="primary"
variant="light"
className={`text-left w-full text-[#333] rounded-[23px] data-[hover=true]:bg-[#E5F6FF] data-[hover=true]:text-primary ${currentConversationId === item.conversationId ? 'bg-[#E5F6FF] text-primary' : ''}`}
onClick={() => handleClick(item)}
onPress={() => handleClick(item)}
>
<div className="w-full text-nowrap text-ellipsis overflow-hidden">
<span>{item.conversationTitle}</span>
......
......@@ -60,7 +60,7 @@ export const NavBarItem: React.FC<NavBarItemProps> = ({ isHistoryVisible, onClic
<motion.div className={`${styles.NavBarItem}`}>
<div className={`${styles.icon}`}>
<Tooltip color="foreground" content={label} placement="right">
<Button className={handleActive() ? 'bg-[#e4e4e5]' : ''} onClick={() => onClick(type)} variant="light" isIconOnly aria-label="Like">
<Button className={handleActive() ? 'bg-[#e4e4e5]' : ''} onPress={() => onClick(type)} variant="light" isIconOnly aria-label="Like">
{React.createElement(icon)}
</Button>
</Tooltip>
......
......@@ -91,7 +91,7 @@ const UserNotLoginBase: React.FC<WithAuthProps> = ({ showLoginTip, checkAuth })
return (
<Tooltip isOpen={navBarVisible && showLoginTip && !isMobile()} color="foreground" content="登录体验更多功能" placement="right">
<Button onClick={checkAuth} variant="light" isIconOnly aria-label="Like">
<Button onPress={checkAuth} variant="light" isIconOnly aria-label="Like">
<UserIcon />
</Button>
</Tooltip>
......
......@@ -3,7 +3,6 @@ import { useParams } from 'react-router-dom'
import { Button } from '@heroui/react'
import { motion } from 'framer-motion'
import { useScroll } from 'ahooks'
import { toast } from 'react-hot-toast'
import styles from './Chat.module.less'
import { ChatSlogan } from './components/ChatSlogan'
import { ChatMaskBar } from './components/ChatMaskBar'
......@@ -16,13 +15,12 @@ import { ChatEditor } from '@/components/ChatEditor'
import type { ChatRecord } from '@/types/chat'
import { fetchUserQaRecordPage } from '@/api/conversation'
import { fetchCheckTokenApi, fetchStreamResponse } from '@/api/chat'
import { clearShouldSendQuestion, createConversation, fetchConversations } from '@/store/conversationSlice'
import { clearShouldSendQuestion, fetchConversations } from '@/store/conversationSlice'
import type { RootState } from '@/store'
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 AddNewChat from '@/assets/svg/addNewChat.svg?react'
export const Chat: React.FC = () => {
let ignore = false
......@@ -59,33 +57,33 @@ export const Chat: React.FC = () => {
/** 处理超过最大条数的数据 */
const handleChatMaxCount = (msg: any, question: string) => {
toast(t => (
<div className="flex items-center">
<p className="text-[14px]">⚠️ 超过最大轮数上限!请新建对话 👉🏻</p>
<Button
color="primary"
size="sm"
variant="light"
isIconOnly
onClick={() => {
dispatch(createConversation({
conversationData: {},
shouldNavigate: true,
shouldSendQuestion: '',
}))
toast.dismiss(t.id)
}}
>
<AddNewChat />
</Button>
</div>
), {
position: 'bottom-center',
duration: 0,
style: {
marginBottom: '120px',
},
})
// toast(t => (
// <div className="flex items-center">
// <p className="text-[14px]">⚠️ 超过最大轮数上限!请新建对话 👉🏻</p>
// <Button
// color="primary"
// size="sm"
// variant="light"
// isIconOnly
// onClick={() => {
// dispatch(createConversation({
// conversationData: {},
// shouldNavigate: true,
// shouldSendQuestion: '',
// }))
// toast.dismiss(t.id)
// }}
// >
// <AddNewChat />
// </Button>
// </div>
// ), {
// position: 'bottom-center',
// duration: 0,
// style: {
// marginBottom: '120px',
// },
// })
setAllItems((prevItems) => {
const newItems = [...prevItems] // 创建数组的浅拷贝
const lastIndex = newItems.length - 1
......@@ -243,7 +241,7 @@ export const Chat: React.FC = () => {
}}
transition={{ duration: 0.3, ease: 'easeInOut' }}
>
<Button onClick={scrollToBottom} radius="full" isIconOnly color="primary">
<Button onPress={scrollToBottom} radius="full" isIconOnly color="primary">
<ScrollBtoIcon />
</Button>
</motion.div>
......
......@@ -87,7 +87,7 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ from
<motion.li
key={product.productCode}
>
<Button onClick={() => handleClickBoxItem(product.productName, product.productCode)} isDisabled={!isLastAnswer} color="primary" variant="light" className="text-left bg-[#F7FCFF] w-full text-[#333] rounded-[23px] data-[hover=true]:bg-[#E5F6FF] data-[hover=true]:text-primary">
<Button onPress={() => handleClickBoxItem(product.productName, product.productCode)} isDisabled={!isLastAnswer} color="primary" variant="light" className="text-left bg-[#F7FCFF] w-full text-[#333] rounded-[23px] data-[hover=true]:bg-[#E5F6FF] data-[hover=true]:text-primary">
<div className="w-full text-nowrap text-ellipsis overflow-hidden">
<span className="ml-[8px]">{product.productName}</span>
</div>
......
......@@ -3,6 +3,7 @@ import { useEffect, useState } from 'react'
import { ChatAnswerShower } from './ChatAnswerShower'
import { ChatAnswerParser } from './ChatAnswerParser'
import { ChatAnswerRecommend } from './ChatAnswerRecommend'
import { ChatMaxCount } from './ChatMaxCount'
import type { Answer, ChatRecord } from '@/types/chat'
import AvatarBot from '@/assets/avatarBot.png'
import { useAppDispatch } from '@/store/hook'
......@@ -61,7 +62,7 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex,
<div className="content">
{item.isShow && <ChatAnswerShower onSubmitQuestion={onSubmitQuestion} isLastAnswer={isLastAnswer} answer={item} />}
{!item.isShow && !item.isChatMaxCount && <ChatAnswerParser onSubmitQuestion={onSubmitQuestion} isLastAnswer={isLastAnswer} isStopTyping={item.isStopTyping} onTyping={handleTyping} onComplate={() => handleComplate(item)} answer={item} />}
{!item.isShow && item.isChatMaxCount && <div>{item.answer}</div>}
{!item.isShow && item.isChatMaxCount && <ChatMaxCount />}
</div>
)
: <SdreamLoading />}
......@@ -71,7 +72,7 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex,
</div>
{isTyping && (
<div className="sm:pl-[62px] mt-[12px]">
<Button onClick={handleStopTyping} color="primary" variant="bordered">
<Button onPress={handleStopTyping} color="primary" variant="bordered">
停止生成
</Button>
</div>
......
......@@ -98,23 +98,23 @@ export const ChatAnswerOperate: React.FC<ChatAnswerOperateProps> = ({ answer })
<div className="sm:mt-[12px] flex gap-[4px] justify-end">
{/* 点赞 */}
<Tooltip color="foreground" content={isLike ? '取消点赞' : '点赞'} className="capitalize">
<Button variant="light" isIconOnly aria-label="LikeIcon" onClick={handleLike.run}>
<Button variant="light" isIconOnly aria-label="LikeIcon" onPress={handleLike.run}>
{isLike ? <LikeIconA /> : <LikeIcon />}
</Button>
</Tooltip>
{/* 点踩 */}
<Tooltip color="foreground" content={isUnLike ? '取消点踩' : '点踩'} className="capitalize">
<Button variant="light" isIconOnly aria-label="UnLikeIcon" onClick={handleUnLike}>
<Button variant="light" isIconOnly aria-label="UnLikeIcon" onPress={handleUnLike}>
{isUnLike ? <UnLikeIconA /> : <UnLikeIcon />}
</Button>
</Tooltip>
{/* 复制 */}
<Tooltip color="foreground" content="复制" className="capitalize">
<Button variant="light" isIconOnly aria-label="CopyIcon" onClick={handleCopy}><CopyIcon /></Button>
<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" onClick={handleCollect.run}>
<Button variant="light" isIconOnly aria-label="CollectIcon" onPress={handleCollect.run}>
{isCollect ? <CollectIconA /> : <CollectIcon />}
</Button>
</Tooltip>
......
......@@ -33,7 +33,7 @@ export const ChatAnswerRecommend: React.FC<ChatAnswerRecommendProps> = ({ answer
<div className="flex flex-col gap-[8px]">
{
questionList.map((item, index) => (
<Button onClick={() => onSubmitQuestion(item)} key={index} color="primary" variant="light" className="text-left bg-[#fff] w-fit max-w-full text-[#333] rounded-[8px] data-[hover=true]:bg-[#F6F6F8] data-[hover=true]:text-[#333]">
<Button onPress={() => onSubmitQuestion(item)} key={index} color="primary" variant="light" className="text-left bg-[#fff] w-fit max-w-full text-[#333] rounded-[8px] data-[hover=true]:bg-[#F6F6F8] data-[hover=true]:text-[#333]">
<div className="w-full sm:w-full text-nowrap text-ellipsis overflow-hidden">
{item}
</div>
......
import { Alert } from '@heroui/alert'
import { Button } from '@heroui/react'
import { useAppDispatch } from '@/store/hook'
import { createConversation } from '@/store/conversationSlice'
export const ChatMaxCount: React.FC = () => {
const dispatch = useAppDispatch()
return (
<div>
<div className="flex items-center">
<p className="text-[14px] mr-[12px]">⚠️ 超过最大轮数上限!请您新建对话~</p>
</div>
<div className="flex items-center justify-center">
<Alert
color="warning"
description="超过最大轮数上限"
title="提示"
variant="faded"
endContent={(
<Button
color="warning"
size="sm"
variant="flat"
className="ml-[12px]"
onPress={() => {
dispatch(createConversation({
conversationData: {},
shouldNavigate: true,
shouldSendQuestion: '',
}))
}}
>
新建对话
</Button>
)}
>
</Alert>
</div>
)
}
......@@ -138,10 +138,10 @@ export const Collect: React.FC = () => {
</div>
<div>
<Tooltip color="foreground" content="复制" className="capitalize">
<Button variant="light" isIconOnly aria-label="CopyIcon" onClick={() => handleCopy(item)}><CopyIcon /></Button>
<Button variant="light" isIconOnly aria-label="CopyIcon" onPress={() => handleCopy(item)}><CopyIcon /></Button>
</Tooltip>
<Tooltip color="foreground" content="删除" className="capitalize">
<Button variant="light" isIconOnly aria-label="DeleteIcon" onClick={() => handleDelete(item)}><DeleteIcon /></Button>
<Button variant="light" isIconOnly aria-label="DeleteIcon" onPress={() => handleDelete(item)}><DeleteIcon /></Button>
</Tooltip>
</div>
</div>
......@@ -165,7 +165,7 @@ export const Collect: React.FC = () => {
{
!isLoading && collectList.length < total && (
<div className="w-full max-w-[912px] mx-auto flex justify-center mt-[24px]">
<Button onClick={handleLoadMore} color="primary" variant="light">
<Button onPress={handleLoadMore} color="primary" variant="light">
加载更多
</Button>
</div>
......
......@@ -88,7 +88,7 @@ const QuestionListBase: React.FC<QuestionListProps & WithAuthProps> = ({ checkAu
showRefresh
? (
<Button
onClick={handleRefresh}
onPress={handleRefresh}
isDisabled={isRotating}
isIconOnly
color="primary"
......@@ -130,7 +130,7 @@ const QuestionListBase: React.FC<QuestionListProps & WithAuthProps> = ({ checkAu
layout
className="w-full"
>
<Button onClick={() => handleClick(item)} color="primary" variant="light" className="text-left bg-[#F7FCFF] w-full text-[#333] rounded-[23px] data-[hover=true]:bg-[#E5F6FF] data-[hover=true]:text-primary">
<Button onPress={() => handleClick(item)} color="primary" variant="light" className="text-left bg-[#F7FCFF] w-full text-[#333] rounded-[23px] data-[hover=true]:bg-[#E5F6FF] data-[hover=true]:text-primary">
<div className="w-full text-nowrap text-ellipsis overflow-hidden">
<span style={{ color: dotColor }}>·</span>
<span className="ml-[8px]">{item}</span>
......
......@@ -77,7 +77,7 @@ const WelcomeWordBase: React.FC<WithAuthProps> = ({ checkAuth }) => {
<div className="px-[18px] pt-[58px] pb-[18px] relative z-[1] box-border sm:pb-0 sm:px-[24px] sm:pt-[68px]">
<SayHi />
<p className="mt-[16px] text-[#27353C] text-[15px] sm:mt-[24px] mb-[16px]">作为您的智能保险伙伴,您有各类专业相关的问题都可以抛给我哟~让我们互相帮助共同成长吧~</p>
<Button className="bg-white w-full text-[#20ABD9] font-medium rounded-[20px] sm:w-auto" onClick={handleGo}>立即前往 ➔</Button>
<Button className="bg-white w-full text-[#20ABD9] font-medium rounded-[20px] sm:w-auto" onPress={handleGo}>立即前往 ➔</Button>
</div>
</div>
)
......
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