Commit f2729c4c by HoMeTown

feat: 优化功能

parent 08186cd0
import React, { useEffect, useRef, useState } from 'react' import React, { useEffect, useRef, useState } from 'react'
import { AnimatePresence, motion } from 'framer-motion' import { AnimatePresence, motion } from 'framer-motion'
import { Button } from '@nextui-org/react' import { Button, Tooltip } from '@nextui-org/react'
import { useToggle } from 'ahooks' import { useLocalStorageState, useToggle } from 'ahooks'
import { LoginModal } from '../LoginModal' import { LoginModal } from '../LoginModal'
import type { RootState } from '@/store' import type { RootState } from '@/store'
import SendIcon from '@/assets/svg/send.svg?react' import SendIcon from '@/assets/svg/send.svg?react'
...@@ -13,9 +13,10 @@ interface ChatEditorProps { ...@@ -13,9 +13,10 @@ interface ChatEditorProps {
onFocus?: () => void onFocus?: () => void
onSubmit?: (value: string) => void onSubmit?: (value: string) => void
placeholders: string[] placeholders: string[]
showContentTips?: boolean
} }
const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth, onChange, onFocus, onSubmit, placeholders }) => { const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth, onChange, onFocus, onSubmit, placeholders, showContentTips = false }) => {
// const dispatch = useAppDispatch() // const dispatch = useAppDispatch()
const [content, setContent] = useState('') const [content, setContent] = useState('')
const editorRef = useRef<HTMLDivElement>(null) const editorRef = useRef<HTMLDivElement>(null)
...@@ -97,6 +98,15 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth, ...@@ -97,6 +98,15 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
// } // }
} }
}, [content]) }, [content])
const [token] = useLocalStorageState<string | undefined>(
'__TOKEN__',
{
defaultValue: '',
listenStorageChange: true,
},
)
return ( return (
<div className="ask-input flex items-end w-full h-auto relative mx-auto bg-white rounded-[36px] overflow-hidden transition duration-200 py-[8px] pl-[12px] pr-[12px] sm:py-[12px] sm:pl-[32px] sm:pr-[20px]"> <div className="ask-input flex items-end w-full h-auto relative mx-auto bg-white rounded-[36px] overflow-hidden transition duration-200 py-[8px] pl-[12px] pr-[12px] sm:py-[12px] sm:pl-[32px] sm:pr-[20px]">
<div <div
...@@ -113,10 +123,12 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth, ...@@ -113,10 +123,12 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
resize: 'none', resize: 'none',
}} }}
/> />
<Tooltip isOpen={Boolean(token) && showContentTips && !isAsking && !content} color="foreground" content="请输入您的问题📖" placement="top">
<Button className="ask-send" onClick={handleSubmit} radius="full" isDisabled={!content || isAsking} isIconOnly color="primary"> <Button className="ask-send" onClick={handleSubmit} radius="full" isDisabled={!content || isAsking} isIconOnly color="primary">
<SendIcon /> <SendIcon />
</Button> </Button>
</Tooltip>
<div className="absolute inset-0 flex items-center rounded-full pointer-events-none"> <div className="absolute inset-0 flex items-center rounded-full pointer-events-none">
<AnimatePresence mode="wait"> <AnimatePresence mode="wait">
{!content && ( {!content && (
......
...@@ -8,7 +8,7 @@ export default function JoyrideStep() { ...@@ -8,7 +8,7 @@ export default function JoyrideStep() {
const steps = [ const steps = [
{ {
target: '.layoutNavBarJoyride', target: '.layoutNavBarJoyride',
content: '点击logo 解锁更多功能 🎉', content: '登录解锁更多功能 🎉',
}, },
] ]
......
...@@ -79,7 +79,7 @@ export const Home: React.FC = () => { ...@@ -79,7 +79,7 @@ export const Home: React.FC = () => {
{/* /> */} {/* /> */}
</div> </div>
<div className="box-border px-[0] mx-auto iptContainer w-full max-w-[912px] flex-shrink-0 sm:px-0 pb-[18px]"> <div className="box-border px-[0] mx-auto iptContainer w-full max-w-[912px] flex-shrink-0 sm:px-0 pb-[18px]">
<ChatEditor onSubmit={handleCreateConversation} placeholders={RECOMMEND_QUESTIONS_OTHER} /> <ChatEditor showContentTips onSubmit={handleCreateConversation} placeholders={RECOMMEND_QUESTIONS_OTHER} />
<div className="w-full text-center mt-[12px] text-[#3333334d] text-[12px]"> <div className="w-full text-center mt-[12px] text-[#3333334d] text-[12px]">
内容由AI模型生成,其准确性和完整性无法保证,仅供参考 内容由AI模型生成,其准确性和完整性无法保证,仅供参考
</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