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