Commit bb6b1466 by Liu

feat:重新分析按钮保持与提问按钮逻辑一致

parent aa90f3a8
......@@ -42,6 +42,7 @@ export const TacticsChat: React.FC = () => {
shouldNavigateToNewConversation,
currentConversationId,
} = useAppSelector((state: RootState) => state.tactics)
const isAsking = useAppSelector((state: RootState) => state.chat.isAsking)
const [searchParams] = useSearchParams()
const hasFetched = useRef(false)
// 使用 useLocalStorageState 管理 token,与原有逻辑保持一致
......@@ -583,6 +584,16 @@ export const TacticsChat: React.FC = () => {
}, [dispatch, getConversationExtra])
const handleReanalyze = useCallback(async () => {
// 正在回答或尚未就绪时不触发重新分析
if (!currentIdRef.current || isLoading || isAsking) {
// eslint-disable-next-line no-console
console.log('[TacticsChat] handleReanalyze blocked', {
currentId: currentIdRef.current,
isLoading,
isAsking,
})
return
}
// 重新触发一次提问,与首次自动调用保持一致:
// - 无 userMeta:沿用原逻辑,传 recordType=A02,使用 tacticsMeta
// - 有 userMeta:按 userMeta.numberType 映射 numberType(A03/A05/A07/A09),不传 recordType,仅传 userMeta
......@@ -610,7 +621,7 @@ export const TacticsChat: React.FC = () => {
if (currentIdRef.current) {
navigate(`/tactics/chat/${currentIdRef.current}`)
}
}, [dispatch, navigate, handleSubmitQuestion, userMeta, getNumberTypeWithUserMeta])
}, [dispatch, navigate, handleSubmitQuestion, userMeta, getNumberTypeWithUserMeta, isLoading, isAsking])
const handleCancelClear = useCallback(() => {
setShowClearConfirm(false)
......@@ -812,7 +823,12 @@ export const TacticsChat: React.FC = () => {
<button
type="button"
onClick={handleReanalyze}
className="flex items-center gap-[4px] text-[#4A90E2] text-[14px] hover:opacity-80 transition-opacity cursor-pointer bg-transparent border-none outline-none"
disabled={!currentIdRef.current || isLoading || isAsking}
className={`flex items-center gap-[4px] text-[14px] transition-opacity bg-transparent border-none outline-none ${
!currentIdRef.current || isLoading || isAsking
? 'text-[#B2B8C1] cursor-not-allowed opacity-60'
: 'text-[#4A90E2] hover:opacity-80 cursor-pointer'
}`}
>
<RefreshIcon className="w-[16px] h-[16px] text-[#B2B8C1]" />
<span>重新分析</span>
......
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