mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-16 14:12:51 +00:00
perf: ai聊天小概率出现重复推流的情况
This commit is contained in:
parent
bb251c8aee
commit
423594e20c
5
resources/assets/js/store/actions.js
vendored
5
resources/assets/js/store/actions.js
vendored
@ -2858,6 +2858,9 @@ export default {
|
|||||||
if (!/^https*:\/\//i.test(streamUrl)) {
|
if (!/^https*:\/\//i.test(streamUrl)) {
|
||||||
streamUrl = $A.apiUrl(`..${streamUrl}`)
|
streamUrl = $A.apiUrl(`..${streamUrl}`)
|
||||||
}
|
}
|
||||||
|
if (state.dialogSseList.find(item => item.streamUrl == streamUrl)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const sse = new SSEClient(streamUrl)
|
const sse = new SSEClient(streamUrl)
|
||||||
sse.subscribe(['append', 'replace', 'done'], (type, e) => {
|
sse.subscribe(['append', 'replace', 'done'], (type, e) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -2886,7 +2889,7 @@ export default {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
state.dialogSseList.push({sse, time: $A.Time()})
|
state.dialogSseList.push({sse, streamUrl, time: $A.Time()})
|
||||||
if (state.dialogSseList.length > 10) {
|
if (state.dialogSseList.length > 10) {
|
||||||
state.dialogSseList.shift().sse.close()
|
state.dialogSseList.shift().sse.close()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user