Commit e5d0da79 by Liu

fix:输入框placeHoulder&&常见问题tooltip

parent 107247b0
......@@ -57,6 +57,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
const [selectedToolId, setSelectedToolId] = useState<string | null>(null)
const [isToolBtnActive, setIsToolBtnActive] = useState<boolean>(true)
const currentToolId = useAppSelector((state: RootState) => state.conversation.currentToolId)
const [showToolQuestion, setShowToolQuestion] = useState<boolean>(false)
// 获取工具列表
const getToolList = async () => {
......@@ -163,6 +164,8 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
// 立即更新本地状态,让 UI 立即响应
setIsToolBtnActive(true)
setSelectedToolId(null)
sessionStorage.removeItem('showToolQuestion')
setShowToolQuestion(false)
try {
await dispatch(createConversation({
conversationData: {},
......@@ -182,9 +185,11 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
return
if (tool.toolName === '数据助手') {
sessionStorage.setItem('showToolQuestion', 'true')
setShowToolQuestion(true)
}
else {
sessionStorage.removeItem('showToolQuestion')
setShowToolQuestion(false)
}
dispatch(setCurrentToolId(tool.toolId))
setSelectedToolId(tool.toolId)
......@@ -222,6 +227,20 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
getToolList()
}, [])
// 监听 sessionStorage 中的 showToolQuestion
useEffect(() => {
const checkShowToolQuestion = () => {
const value = sessionStorage.getItem('showToolQuestion')
setShowToolQuestion(value === 'true')
}
checkShowToolQuestion()
// 监听 storage 事件以响应其他标签页的变化
window.addEventListener('storage', checkShowToolQuestion)
return () => {
window.removeEventListener('storage', checkShowToolQuestion)
}
}, [])
// 处理initialValue的变化
useEffect(() => {
if (initialValue && editorRef.current) {
......@@ -263,7 +282,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
onKeyDown={handleKeyDown}
onPaste={handlePaste}
suppressContentEditableWarning
data-placeholder="输入您想问的问题吧~"
data-placeholder={showToolQuestion ? '请输入您的问题' : '输入您想问的问题吧~'}
style={{
resize: 'none',
maxHeight: '48px',
......
import { Button } from '@heroui/react'
import { Button, Tooltip } from '@heroui/react'
import type React from 'react'
import { Image } from '@heroui/image'
import { motion } from 'framer-motion'
......@@ -188,10 +188,12 @@ const QuestionListBase: React.FC<QuestionListProps & WithAuthProps> = ({
variant="light"
className="text-left bg-[#F8FBFF] w-full text-[#333] rounded-[23px] data-[hover=true]:bg-[#F0F8FF] data-[hover=true]:text-primary h-8"
>
<Tooltip color="foreground" content={item} placement="top">
<div className="w-full text-nowrap text-ellipsis overflow-hidden">
<span className="w-[6px] h-[6px] rounded-full inline-block mr-[6px]" style={{ backgroundColor: dotColor }}></span>
<span className="ml-[8px]">{item}</span>
</div>
</Tooltip>
</Button>
</motion.li>
))}
......
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