diff --git a/src/components/DebateChat.tsx b/src/components/DebateChat.tsx new file mode 100644 index 0000000..97780c0 --- /dev/null +++ b/src/components/DebateChat.tsx @@ -0,0 +1,43 @@ +import { useAppSelector } from '@/hooks/redux'; +import React from 'react'; + +const DebateChat: React.FC = ({ messages }) => { + const fontSize = useAppSelector(state => state.env.envData.fontSize) + + return ( +
+
+ {messages.map((message, index) => ( +
+
+

+ {message.side === 'pro' ? '正方' : '反方'} +

+

{message.content}

+
+
+
+ ))} +
+
+ ); +}; + +export default DebateChat; \ No newline at end of file diff --git a/src/components/SegmentCard.tsx b/src/components/SegmentCard.tsx index c30ca46..4c827fd 100644 --- a/src/components/SegmentCard.tsx +++ b/src/components/SegmentCard.tsx @@ -2,7 +2,7 @@ import React, {MutableRefObject, useCallback, useEffect, useMemo, useRef} from ' import {useAppDispatch, useAppSelector} from '../hooks/redux' import {setFloatKeyPointsSegIdx, setSegmentFold, setTempData} from '../redux/envReducer' import classNames from 'classnames' -import {FaClipboardList} from 'react-icons/fa' +import {FaClipboardList, FaComments} from 'react-icons/fa' import {PAGE_MAIN, PAGE_SETTINGS, SUMMARIZE_THRESHOLD, SUMMARIZE_TYPES} from '../consts/const' import useTranslate from '../hooks/useTranslate' import {BsDashSquare, BsPlusSquare, CgFileDocument, FaQuestion, GrOverview, RiFileCopy2Line} from 'react-icons/all' @@ -12,6 +12,7 @@ import {useInViewport} from 'ahooks' import SegmentItem from './SegmentItem' import {stopPopFunc} from '../utils/util' import useSubtitle from '../hooks/useSubtitle' +import DebateChat from './DebateChat' const SummarizeItemOverview = (props: { segment: Segment @@ -113,6 +114,8 @@ const Summarize = (props: {
{question.a}
)} } + {summary?.type === 'debate' && (summary.content != null) && + }
{segment.text.length < SUMMARIZE_THRESHOLD &&
文字过短,无法总结.
} @@ -200,6 +203,12 @@ const SegmentCard = (props: { })) }, [dispatch]) + const onSelDebate = useCallback(() => { + dispatch(setTempData({ + curSummaryType: 'debate' + })) + }, [dispatch]) + return
@@ -215,6 +224,7 @@ const SegmentCard = (props: { 概览 要点 问题 + 辩论
}
{ } else if (summary.type === 'question') { const content: any[] = summary.content??[] return content.length === 0 + } else if (summary.type === 'debate') { + const content: Array<{ side: string, content: string }> = summary.content ?? [] + return content.length === 0 } return true } @@ -107,7 +110,12 @@ export const getSummaryStr = (summary: Summary) => { s += content.map(item => { return item.q + '\n' + item.a + '\n' }).join('\n') - } + } else if (summary.type === 'debate') { + const content: Array<{ side: string, content: string }> = summary.content ?? [] + s += content.map(item => { + return (item.side === 'pro'?'正方:':'反方:') + item.content + '\n' + }).join('\n') + } return s }