Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-middle-front
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
1
Merge Requests
1
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
xingmin
yd-middle-front
Commits
15b5f869
Commit
15b5f869
authored
Apr 07, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
19f1170e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
12 deletions
+26
-12
src/views/ai/index.vue
+26
-12
No files found.
src/views/ai/index.vue
View file @
15b5f869
...
...
@@ -323,26 +323,40 @@ export default {
const
lines
=
buffer
.
split
(
'
\
n'
)
buffer
=
lines
.
pop
()
||
''
// 在 sendMessage 中,解析 SSE 时增加对 event 的处理
let
currentEvent
=
null
;
for
(
let
line
of
lines
)
{
line
=
line
.
trim
()
if
(
line
===
''
)
continue
line
=
line
.
trim
()
;
if
(
line
===
''
)
continue
;
let
content
=
''
if
(
line
.
startsWith
(
'event:'
))
{
currentEvent
=
line
.
slice
(
6
).
trim
();
continue
;
}
let
content
=
''
;
if
(
line
.
startsWith
(
'data:'
))
{
content
=
line
.
slice
(
5
).
trim
()
if
(
content
===
'[DONE]'
)
continue
content
=
line
.
slice
(
5
).
trim
()
;
if
(
content
===
'[DONE]'
)
continue
;
}
else
if
(
line
.
startsWith
(
'message:'
))
{
content
=
line
.
slice
(
8
).
trim
()
}
else
if
(
line
.
startsWith
(
'event:'
))
{
continue
content
=
line
.
slice
(
8
).
trim
();
}
else
{
content
=
line
content
=
line
;
}
if
(
content
)
{
accumulatedContent
+=
content
this
.
messages
[
assistantMessageIndex
].
content
=
accumulatedContent
this
.
scrollToBottom
()
if
(
currentEvent
===
'sensitive_notification'
)
{
// 收到通知敏感词事件,移除刚添加的空消息,展示产品列表
this
.
messages
.
pop
();
await
this
.
fetchAndShowProducts
(
userQuestion
);
currentEvent
=
null
;
// 结束流式处理,不再继续
return
;
}
else
{
accumulatedContent
+=
content
;
this
.
messages
[
assistantMessageIndex
].
content
=
accumulatedContent
;
this
.
scrollToBottom
();
}
}
}
}
...
...
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