import { app } from '../ai'; import { Sender, XProvider, Bubble } from '@ant-design/x'; import { useEffect, useMemo, useRef, useState } from 'react'; import { postChat } from './chat'; import { Nav } from '../nav'; import { ToastContainer } from 'react-toastify'; import { useHomeStore } from './store'; import { nanoid } from 'nanoid'; import { Beian } from '../beian'; const useFocus = () => { const inputRef = useRef(null); useEffect(() => { // Focus the input element inside Sender component const focusInput = () => { if (inputRef.current) { const input = inputRef.current.querySelector('input, textarea') as HTMLInputElement | HTMLTextAreaElement; if (input) { input.focus(); } } }; // Focus on mount focusInput(); // Also focus after a short delay to ensure everything is rendered const timeoutId = setTimeout(focusInput, 100); return () => clearTimeout(timeoutId); }, []); return inputRef; } export const App = () => { const inputRef = useFocus(); const [content, setContent] = useState(''); const { inputValue, setInputValue, isLoading, setLoading, messages, addMessage } = useHomeStore(); const msg = useMemo(() => { return }, [messages]); return
{ console.log('Submitted', message); setLoading(true); addMessage({ role: 'user', content: message, key: nanoid() }); const res = await postChat(message); setContent(res || ' '); setLoading(false); addMessage({ role: 'assistant', content: res || ' ', key: nanoid() }); }} />
{msg}
; } export const AppProvider = () => { return