Commit ef8fbf4b by HoMeTown

feat: 问问题

parent 752d01fe
......@@ -31,13 +31,13 @@ export default defineConfig({
favicon: './src/assets/logo.png',
appIcon: './src/assets/logo.png',
meta: {
'viewport': 'viewport-fit=cover, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0',
'keywords': '晓得,sdream,ai,众耳,insurebank,保险,智能,条款解析,人工智能大模型,AI聊天机器人,AI聊天,国内大模型公司,AI聊天,AI助手,context',
'description': '晓得 是一个智能助手,知晓市场脉搏,引领行业潮流,晓得AI助手全方位为您保驾护航| 晓得. - 晓得解惑,让沟通更智能。',
'apple-mobile-web-app-capable': 'yes',
'apple-mobile-web-app-status-bar-style': 'black',
'format-detection': 'telephone=no,email=no',
'apple-mobile-web-app-title': '晓得',
viewport: 'viewport-fit=cover, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0',
keywords: '晓得,sdream,ai,众耳,insurebank,保险,智能,条款解析,人工智能大模型,AI聊天机器人,AI聊天,国内大模型公司,AI聊天,AI助手,context',
description: '晓得 是一个智能助手,知晓市场脉搏,引领行业潮流,晓得AI助手全方位为您保驾护航| 晓得. - 晓得解惑,让沟通更智能。',
// 'apple-mobile-web-app-capable': 'yes',
// 'apple-mobile-web-app-status-bar-style': 'black',
// 'format-detection': 'telephone=no,email=no',
// 'apple-mobile-web-app-title': '晓得',
},
},
tools: {
......
import { AnimatePresence, motion } from 'framer-motion'
import { Button, Input } from '@nextui-org/react'
import { Button, Input, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, Table, TableBody, TableCell, TableColumn, TableHeader, TableRow } from '@nextui-org/react'
import React, { useState } from 'react'
import { variants } from './motionAnimate'
import { HistoryBarList } from './components/HistoryBarList'
import SearchIcon from '@/assets/svg/search.svg?react'
......@@ -10,6 +11,8 @@ interface HistoryBarProps {
}
export const HistoryBar: React.FC<HistoryBarProps> = ({ isVisible }) => {
// const [isSelected, setIsSelected] = useState(false)
const [isOpen, setIsOpen] = useState(false)
return (
<AnimatePresence>
{isVisible && (
......@@ -28,14 +31,71 @@ export const HistoryBar: React.FC<HistoryBarProps> = ({ isVisible }) => {
<HistoryBarList />
</div>
<div className="text-[12px] border-t-solid border-t-[1px] border-t-[#82969C12] w-full h-[48px] flex items-center justify-center">
<Button className="w-full" color="primary" variant="light" startContent={<HistoryMenuIcon />}>
<Button onClick={() => setIsOpen(true)} className="w-full" color="primary" variant="light" startContent={<HistoryMenuIcon />}>
<span className="text-[#82969C]">管理对话记录</span>
</Button>
</div>
</div>
<Modal backdrop="blur" size="3xl" isOpen={isOpen} onClose={() => setIsOpen(false)}>
<ModalContent>
{onClose => (
<>
<ModalHeader className="flex flex-col gap-1">
<div>
管理对话记录
<span className="text-[#8D9795] text-[14px]">(共11条)</span>
</div>
</ModalHeader>
<ModalBody className="text-[#27353C]">
<Table
removeWrapper
selectionMode="multiple"
defaultSelectedKeys={[]}
aria-label="Example static collection table"
>
<TableHeader>
<TableColumn>NAME</TableColumn>
<TableColumn>ROLE</TableColumn>
<TableColumn>STATUS</TableColumn>
</TableHeader>
<TableBody>
<TableRow key="1">
<TableCell>Tony Reichert</TableCell>
<TableCell>CEO</TableCell>
<TableCell>Active</TableCell>
</TableRow>
<TableRow key="2">
<TableCell>Zoey Lang</TableCell>
<TableCell>Technical Lead</TableCell>
<TableCell>Paused</TableCell>
</TableRow>
<TableRow key="3">
<TableCell>Jane Fisher</TableCell>
<TableCell>Senior Developer</TableCell>
<TableCell>Active</TableCell>
</TableRow>
<TableRow key="4">
<TableCell>William Howard</TableCell>
<TableCell>Community Manager</TableCell>
<TableCell>Vacation</TableCell>
</TableRow>
</TableBody>
</Table>
</ModalBody>
<ModalFooter>
<Button onPress={onClose}>
取消
</Button>
<Button color="primary">
删除所选
</Button>
</ModalFooter>
</>
)}
</ModalContent>
</Modal>
</motion.div>
)}
</AnimatePresence>
)
}
......@@ -20,6 +20,7 @@ import { clearShouldSendQuestion } from '@/store/conversationSlice'
import type { RootState } from '@/store' // 假设你的 store 文件导出了 RootState 类型
export const Chat: React.FC = () => {
let ignore = false
const { id } = useParams<{ id: string }>()
const [isLoading, setIsLoading] = useState(false)
const [allItems, setAllItems] = useState<ChatRecord[]>([])
......@@ -67,11 +68,15 @@ export const Chat: React.FC = () => {
// 创建最后一项的新对象,合并现有数据和新的 answer
newItems[lastIndex] = {
...newItems[lastIndex],
...msg.content.data,
answer: (newItems[lastIndex].answer || '') + msg.content.data.answer,
question,
answerList: [
{
...msg.content.data,
answer: (newItems[lastIndex].answerList[0].answer || '') + msg.content.data.answer,
},
],
}
}
return newItems
})
}
......@@ -101,9 +106,14 @@ export const Chat: React.FC = () => {
useEffect(() => {
if (id) {
getUserQaRecordPage(id)
if (!ignore) {
getUserQaRecordPage(id)
}
return () => {
ignore = true
}
}
}, [id, getUserQaRecordPage])
}, [id])
return (
<div className={`${styles.chatPage} relative`}>
......
......@@ -3,6 +3,7 @@ import { motion } from 'framer-motion'
import ReactMarkdown from 'react-markdown'
import rehypeRaw from 'rehype-raw'
import rehypeSanitize from 'rehype-sanitize'
import remarkGfm from 'remark-gfm'
import { formatMarkdown } from './markdownFormatter'
import type { ChatRecord } from '@/types/chat'
import AvatarBot from '@/assets/avatarBot.png'
......@@ -30,6 +31,7 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex
<div className="content">
<ReactMarkdown
rehypePlugins={[rehypeRaw, rehypeSanitize]}
remarkPlugins={[remarkGfm]}
className="markdown-content"
>
{formatMarkdown(item.answer || '')}
......
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