Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d603f1ed
authored
May 21, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【优化】AI 对话中,不允许切换对话
parent
8f2b81bb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletions
+14
-1
src/views/ai/chat/index.vue
+14
-1
No files found.
src/views/ai/chat/index.vue
View file @
d603f1ed
...
@@ -150,7 +150,6 @@ const textRoll = async () => {
...
@@ -150,7 +150,6 @@ const textRoll = async () => {
textSpeed
.
value
=
10
textSpeed
.
value
=
10
}
}
console
.
log
(
`diff
${
diff
}
速度
${
textSpeed
.
value
}
`
)
// console.log('index
<
fullText
.
value
.
length
'
,
index
<
fullText
.
value
.
length
,
conversationInProgress
.
value
)
// console.log('index
<
fullText
.
value
.
length
'
,
index
<
fullText
.
value
.
length
,
conversationInProgress
.
value
)
if
(
index
<
fullText
.
value
.
length
)
{
if
(
index
<
fullText
.
value
.
length
)
{
...
@@ -341,12 +340,14 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
...
@@ -341,12 +340,14 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
await
scrollToBottom
()
await
scrollToBottom
()
},
},
(
error
)
=>
{
(
error
)
=>
{
console
.
log
(
'onError'
)
// 标记对话结束
// 标记对话结束
conversationInProgress
.
value
=
false
conversationInProgress
.
value
=
false
// 结束 stream 对话
// 结束 stream 对话
conversationInAbortController
.
value
.
abort
()
conversationInAbortController
.
value
.
abort
()
},
},
()
=>
{
()
=>
{
console
.
log
(
'onClose'
)
// 标记对话结束
// 标记对话结束
conversationInProgress
.
value
=
false
conversationInProgress
.
value
=
false
// 结束 stream 对话
// 结束 stream 对话
...
@@ -358,6 +359,7 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
...
@@ -358,6 +359,7 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
}
}
const
stopStream
=
async
()
=>
{
const
stopStream
=
async
()
=>
{
console
.
log
(
'stopStream...'
)
// tip:如果 stream 进行中的 message,就需要调用 controller 结束
// tip:如果 stream 进行中的 message,就需要调用 controller 结束
if
(
conversationInAbortController
.
value
)
{
if
(
conversationInAbortController
.
value
)
{
conversationInAbortController
.
value
.
abort
()
conversationInAbortController
.
value
.
abort
()
...
@@ -416,13 +418,24 @@ const handlerTitleSuccess = async () => {
...
@@ -416,13 +418,24 @@ const handlerTitleSuccess = async () => {
* 对话 - 点击
* 对话 - 点击
*/
*/
const
handleConversationClick
=
async
(
conversation
:
ChatConversationVO
)
=>
{
const
handleConversationClick
=
async
(
conversation
:
ChatConversationVO
)
=>
{
// 对话进行中,不允许切换
if
(
conversationInProgress
.
value
)
{
await
message
.
alert
(
"对话中,不允许切换!"
)
return
false
}
// 更新选中的对话 id
// 更新选中的对话 id
activeConversationId
.
value
=
conversation
.
id
activeConversationId
.
value
=
conversation
.
id
activeConversation
.
value
=
conversation
activeConversation
.
value
=
conversation
// 处理进行中的对话
if
(
conversationInProgress
.
value
)
{
await
stopStream
()
}
// 刷新 message 列表
// 刷新 message 列表
await
getMessageList
()
await
getMessageList
()
// 滚动底部
// 滚动底部
scrollToBottom
(
true
)
scrollToBottom
(
true
)
return
true
}
}
/**
/**
...
...
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