Commit e5d0da79 by Liu

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

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