Commit 69e6c37f by HoMeTown

feat: loading

parent 8f0d869b
import React from 'react'
import LoadingGif from '@/assets/tetsloading.gif'
const SdreamLoading: React.FC = () => {
return (
<img className="w-[26px] h-[26px]" src={LoadingGif} alt="" />
)
}
export default SdreamLoading
import React, { useCallback, useEffect, useRef, useState } from 'react'
import { useParams } from 'react-router-dom'
import { Button, Spinner } from '@nextui-org/react'
import { Button } from '@nextui-org/react'
import { motion } from 'framer-motion'
import { useScroll } from 'ahooks'
import styles from './Chat.module.less'
......@@ -20,6 +20,7 @@ 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'
export const Chat: React.FC = () => {
let ignore = false
......@@ -141,7 +142,7 @@ export const Chat: React.FC = () => {
<ChatSlogan />
<ChatMaskBar />
<div className={styles.content}>
{isLoading && <div className="w-full h-full flex justify-center"><Spinner /></div>}
{isLoading && <div className="w-full h-full flex justify-center items-center"><SdreamLoading /></div>}
{!isLoading && (
<motion.div
ref={scrollableRef}
......
import { Avatar, Button, Spinner } from '@nextui-org/react'
import { Avatar, Button } from '@nextui-org/react'
import { motion } from 'framer-motion'
import { useEffect, useState } from 'react'
import { ChatAnswerShower } from './ChatAnswerShower'
......@@ -8,6 +8,7 @@ import type { Answer, ChatRecord } from '@/types/chat'
import AvatarBot from '@/assets/avatarBot.png'
import { useAppDispatch } from '@/store/hook'
import { setIsAsking } from '@/store/chatSlice'
import SdreamLoading from '@/components/SdreamLoading'
interface ChatAnswerBoxProps {
record: ChatRecord
......@@ -62,7 +63,7 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex,
{!item.isShow && <ChatAnswerParser onSubmitQuestion={onSubmitQuestion} isLastAnswer={isLastAnswer} isStopTyping={item.isStopTyping} onTyping={handleTyping} onComplate={() => handleComplate(item)} answer={item} />}
</div>
)
: <Spinner size="sm" />}
: <SdreamLoading />}
</motion.div>
<div className="w-[65px] flex-shrink-0"></div>
</div>
......
......@@ -85,14 +85,14 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
setIsImageAnswer(true)
const timer = setTimeout(() => {
setCurrentIndex(prevIndex => prevIndex + 1)
}, 20) // 调整此值以改变打字速度
}, 10) // 调整此值以改变打字速度
return () => clearTimeout(timer)
}
else {
const timer = setTimeout(() => {
setDisplayedText(formatAnswer.slice(0, currentIndex + 1))
setCurrentIndex(prevIndex => prevIndex + 1)
}, 20) // 调整此值以改变打字速度
}, 10) // 调整此值以改变打字速度
return () => clearTimeout(timer)
}
}
......
import { useEffect, useState } from 'react'
import { Button, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, Spinner, Tooltip } from '@nextui-org/react'
import { Button, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, Tooltip } from '@nextui-org/react'
import { motion } from 'framer-motion'
import { ChatMaskBar } from '../Chat/components/ChatMaskBar'
import { ChatSlogan } from '../Chat/components/ChatSlogan'
......@@ -17,6 +17,7 @@ import AIcon from '@/assets/svg/aicon.svg?react'
import QIcon from '@/assets/svg/qicon.svg?react'
import EmptyIcon from '@/assets/svg/empty.svg?react'
import ShineBorder from '@/components/ShineBorder'
import SdreamLoading from '@/components/SdreamLoading'
export const Collect: React.FC = () => {
const [isLoading, setIsLoading] = useState(false)
......@@ -155,7 +156,7 @@ export const Collect: React.FC = () => {
</div>
)
}
{isLoading && <div className="w-full flex justify-center"><Spinner /></div>}
{isLoading && <div className="w-full flex justify-center items-center"><SdreamLoading /></div>}
{
!isLoading && collectList.length < total && (
<div className="w-full max-w-[1000px] mx-auto flex justify-center mt-[24px]">
......
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