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
55d8a609
Commit
55d8a609
authored
Aug 15, 2024
by
HoMeTown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: doc的跳转
parent
219000a0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
+28
-3
src/api/common.ts
+12
-0
src/pages/Chat/components/ChatItem/ChatAnswerAttchment.tsx
+15
-2
src/pages/Chat/components/ChatItem/ChatAnswerParser.tsx
+1
-1
No files found.
src/api/common.ts
View file @
55d8a609
...
...
@@ -29,3 +29,15 @@ export function fetchGetDocumentLinks(docIdList: string[]) {
docIdList
,
})
}
/**
* 获取文档链接
* @param recordId
* @returns
*/
export
function
fetchGetDocumentLink
(
docId
:
string
)
{
return
http
.
post
(
'/conversation/api/conversation/mobile/v1/get_document'
,
{
ossType
:
'private'
,
docId
,
})
}
src/pages/Chat/components/ChatItem/ChatAnswerAttchment.tsx
View file @
55d8a609
...
...
@@ -5,13 +5,15 @@ import AnswerProDetailIcon from '@/assets/svg/answerProDetail.svg?react'
import
CardNavImg
from
'@/assets/card-nav.png'
import
CardCalculation
from
'@/assets/card-calculation.png'
import
CardDetailImg
from
'@/assets/card-detail.png'
import
{
fetchGetDocumentLink
}
from
'@/api/common'
interface
ChatAnswerAttachmentProps
{
answer
:
Answer
isLastAnswer
?:
boolean
fromParser
?:
boolean
onSubmitQuestion
?:
(
question
:
string
,
productCode
?:
string
)
=>
void
}
export
const
ChatAnswerAttachment
:
React
.
FC
<
ChatAnswerAttachmentProps
>
=
({
answer
,
isLastAnswer
,
onSubmitQuestion
})
=>
{
export
const
ChatAnswerAttachment
:
React
.
FC
<
ChatAnswerAttachmentProps
>
=
({
fromParser
,
answer
,
isLastAnswer
,
onSubmitQuestion
})
=>
{
const
handleClickBoxItem
=
(
produceName
:
string
,
productCode
:
string
)
=>
{
if
(
onSubmitQuestion
)
{
onSubmitQuestion
(
produceName
,
productCode
)
...
...
@@ -21,6 +23,17 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ answ
const
handleClickCard
=
(
url
:
string
)
=>
{
window
.
open
(
url
)
}
const
handleClickDocLink
=
async
(
docId
:
string
)
=>
{
if
(
fromParser
)
{
const
res
=
await
fetchGetDocumentLink
(
docId
)
if
(
res
.
data
)
window
.
location
.
href
=
res
.
data
.
docUrl
}
else
{
window
.
location
.
href
=
docId
}
}
return
(
<
div
className=
"attachmentList flex flex-col gap-[20px]"
>
{
answer
.
attachmentList
&&
answer
.
attachmentList
.
map
((
attachment
,
index
)
=>
(
...
...
@@ -46,7 +59,7 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ answ
</
p
>
<
div
className=
"flex flex-col gap-[9px]"
>
{
attachment
.
content
.
docList
.
map
((
doc
,
docIdx
)
=>
(
<
Link
size=
"sm"
key=
{
doc
.
docId
}
isExternal
href=
{
doc
.
docId
}
showAnchorIcon
underline=
"hover"
>
<
Link
className=
"cursor-pointer"
onPress=
{
()
=>
handleClickDocLink
(
doc
.
docId
)
}
size=
"sm"
key=
{
doc
.
docId
}
isExternal
showAnchorIcon
underline=
"hover"
>
{
docIdx
+
1
}
.
{
' '
}
...
...
src/pages/Chat/components/ChatItem/ChatAnswerParser.tsx
View file @
55d8a609
...
...
@@ -139,7 +139,7 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
{
!
isTyping
&&
answer
.
attachmentList
&&
answer
.
attachmentList
?.
length
!==
0
&&
<
ChatAnswerAttachment
isLastAnswer=
{
isLastAnswer
}
onSubmitQuestion=
{
onSubmitQuestion
}
answer=
{
answer
}
/>
}
&&
<
ChatAnswerAttachment
fromParser
isLastAnswer=
{
isLastAnswer
}
onSubmitQuestion=
{
onSubmitQuestion
}
answer=
{
answer
}
/>
}
{
!
isTyping
&&
!
hideOperate
&&
<
ChatAnswerOperate
answer=
{
answer
}
/>
}
</
div
>
...
...
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