Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sdream-ai-fe
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
侯明涛
sdream-ai-fe
Commits
ef8fbf4b
Commit
ef8fbf4b
authored
Aug 12, 2024
by
HoMeTown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 问问题
parent
752d01fe
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
13 deletions
+85
-13
rsbuild.config.ts
+7
-7
src/layouts/HistoryBar/HistoryBar.tsx
+63
-3
src/pages/Chat/Chat.tsx
+13
-3
src/pages/Chat/components/ChatItem/ChatAnswerBox.tsx
+2
-0
No files found.
rsbuild.config.ts
View file @
ef8fbf4b
...
@@ -31,13 +31,13 @@ export default defineConfig({
...
@@ -31,13 +31,13 @@ export default defineConfig({
favicon
:
'./src/assets/logo.png'
,
favicon
:
'./src/assets/logo.png'
,
appIcon
:
'./src/assets/logo.png'
,
appIcon
:
'./src/assets/logo.png'
,
meta
:
{
meta
:
{
'viewport'
:
'viewport-fit=cover, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'
,
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'
,
keywords
:
'晓得,sdream,ai,众耳,insurebank,保险,智能,条款解析,人工智能大模型,AI聊天机器人,AI聊天,国内大模型公司,AI聊天,AI助手,context'
,
'description'
:
'晓得 是一个智能助手,知晓市场脉搏,引领行业潮流,晓得AI助手全方位为您保驾护航| 晓得. - 晓得解惑,让沟通更智能。'
,
description
:
'晓得 是一个智能助手,知晓市场脉搏,引领行业潮流,晓得AI助手全方位为您保驾护航| 晓得. - 晓得解惑,让沟通更智能。'
,
'apple-mobile-web-app-capable'
:
'yes'
,
//
'apple-mobile-web-app-capable': 'yes',
'apple-mobile-web-app-status-bar-style'
:
'black'
,
//
'apple-mobile-web-app-status-bar-style': 'black',
'format-detection'
:
'telephone=no,email=no'
,
//
'format-detection': 'telephone=no,email=no',
'apple-mobile-web-app-title'
:
'晓得'
,
//
'apple-mobile-web-app-title': '晓得',
},
},
},
},
tools
:
{
tools
:
{
...
...
src/layouts/HistoryBar/HistoryBar.tsx
View file @
ef8fbf4b
import
{
AnimatePresence
,
motion
}
from
'framer-motion'
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
{
variants
}
from
'./motionAnimate'
import
{
HistoryBarList
}
from
'./components/HistoryBarList'
import
{
HistoryBarList
}
from
'./components/HistoryBarList'
import
SearchIcon
from
'@/assets/svg/search.svg?react'
import
SearchIcon
from
'@/assets/svg/search.svg?react'
...
@@ -10,6 +11,8 @@ interface HistoryBarProps {
...
@@ -10,6 +11,8 @@ interface HistoryBarProps {
}
}
export
const
HistoryBar
:
React
.
FC
<
HistoryBarProps
>
=
({
isVisible
})
=>
{
export
const
HistoryBar
:
React
.
FC
<
HistoryBarProps
>
=
({
isVisible
})
=>
{
// const [isSelected, setIsSelected] = useState(false)
const
[
isOpen
,
setIsOpen
]
=
useState
(
false
)
return
(
return
(
<
AnimatePresence
>
<
AnimatePresence
>
{
isVisible
&&
(
{
isVisible
&&
(
...
@@ -28,14 +31,71 @@ export const HistoryBar: React.FC<HistoryBarProps> = ({ isVisible }) => {
...
@@ -28,14 +31,71 @@ export const HistoryBar: React.FC<HistoryBarProps> = ({ isVisible }) => {
<
HistoryBarList
/>
<
HistoryBarList
/>
</
div
>
</
div
>
<
div
className=
"text-[12px] border-t-solid border-t-[1px] border-t-[#82969C12] w-full h-[48px] flex items-center justify-center"
>
<
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
>
<
span
className=
"text-[#82969C]"
>
管理对话记录
</
span
>
</
Button
>
</
Button
>
</
div
>
</
div
>
</
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
>
</
motion
.
div
>
)
}
)
}
</
AnimatePresence
>
</
AnimatePresence
>
)
)
}
}
src/pages/Chat/Chat.tsx
View file @
ef8fbf4b
...
@@ -20,6 +20,7 @@ import { clearShouldSendQuestion } from '@/store/conversationSlice'
...
@@ -20,6 +20,7 @@ import { clearShouldSendQuestion } from '@/store/conversationSlice'
import
type
{
RootState
}
from
'@/store'
// 假设你的 store 文件导出了 RootState 类型
import
type
{
RootState
}
from
'@/store'
// 假设你的 store 文件导出了 RootState 类型
export
const
Chat
:
React
.
FC
=
()
=>
{
export
const
Chat
:
React
.
FC
=
()
=>
{
let
ignore
=
false
const
{
id
}
=
useParams
<
{
id
:
string
}
>
()
const
{
id
}
=
useParams
<
{
id
:
string
}
>
()
const
[
isLoading
,
setIsLoading
]
=
useState
(
false
)
const
[
isLoading
,
setIsLoading
]
=
useState
(
false
)
const
[
allItems
,
setAllItems
]
=
useState
<
ChatRecord
[]
>
([])
const
[
allItems
,
setAllItems
]
=
useState
<
ChatRecord
[]
>
([])
...
@@ -67,11 +68,15 @@ export const Chat: React.FC = () => {
...
@@ -67,11 +68,15 @@ export const Chat: React.FC = () => {
// 创建最后一项的新对象,合并现有数据和新的 answer
// 创建最后一项的新对象,合并现有数据和新的 answer
newItems
[
lastIndex
]
=
{
newItems
[
lastIndex
]
=
{
...
newItems
[
lastIndex
],
...
newItems
[
lastIndex
],
question
,
answerList
:
[
{
...
msg
.
content
.
data
,
...
msg
.
content
.
data
,
answer
:
(
newItems
[
lastIndex
].
answer
||
''
)
+
msg
.
content
.
data
.
answer
,
answer
:
(
newItems
[
lastIndex
].
answerList
[
0
].
answer
||
''
)
+
msg
.
content
.
data
.
answer
,
},
],
}
}
}
}
return
newItems
return
newItems
})
})
}
}
...
@@ -101,9 +106,14 @@ export const Chat: React.FC = () => {
...
@@ -101,9 +106,14 @@ export const Chat: React.FC = () => {
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
id
)
{
if
(
id
)
{
if
(
!
ignore
)
{
getUserQaRecordPage
(
id
)
getUserQaRecordPage
(
id
)
}
}
},
[
id
,
getUserQaRecordPage
])
return
()
=>
{
ignore
=
true
}
}
},
[
id
])
return
(
return
(
<
div
className=
{
`${styles.chatPage} relative`
}
>
<
div
className=
{
`${styles.chatPage} relative`
}
>
...
...
src/pages/Chat/components/ChatItem/ChatAnswerBox.tsx
View file @
ef8fbf4b
...
@@ -3,6 +3,7 @@ import { motion } from 'framer-motion'
...
@@ -3,6 +3,7 @@ import { motion } from 'framer-motion'
import
ReactMarkdown
from
'react-markdown'
import
ReactMarkdown
from
'react-markdown'
import
rehypeRaw
from
'rehype-raw'
import
rehypeRaw
from
'rehype-raw'
import
rehypeSanitize
from
'rehype-sanitize'
import
rehypeSanitize
from
'rehype-sanitize'
import
remarkGfm
from
'remark-gfm'
import
{
formatMarkdown
}
from
'./markdownFormatter'
import
{
formatMarkdown
}
from
'./markdownFormatter'
import
type
{
ChatRecord
}
from
'@/types/chat'
import
type
{
ChatRecord
}
from
'@/types/chat'
import
AvatarBot
from
'@/assets/avatarBot.png'
import
AvatarBot
from
'@/assets/avatarBot.png'
...
@@ -30,6 +31,7 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex
...
@@ -30,6 +31,7 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex
<
div
className=
"content"
>
<
div
className=
"content"
>
<
ReactMarkdown
<
ReactMarkdown
rehypePlugins=
{
[
rehypeRaw
,
rehypeSanitize
]
}
rehypePlugins=
{
[
rehypeRaw
,
rehypeSanitize
]
}
remarkPlugins=
{
[
remarkGfm
]
}
className=
"markdown-content"
className=
"markdown-content"
>
>
{
formatMarkdown
(
item
.
answer
||
''
)
}
{
formatMarkdown
(
item
.
answer
||
''
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment