<script setup lang="ts">
import { ref } from 'vue'
import { RouterLink, RouterView } from 'vue-router'
import HelloWorld from './components/HelloWorld.vue'
import TbcSSE from '@21tb/tbc-sse'
const message = ref('')
const onmessage = (data: any) => {
message.value += data.data || ''
console.log('onmessage', data)
}
const eventStreamHelperInstance = new TbcSSE()
eventStreamHelperInstance.subscribe('onopen', onmessage)
eventStreamHelperInstance.subscribe('onmessage', onmessage)
eventStreamHelperInstance.subscribe('onend', onmessage)
eventStreamHelperInstance.subscribe('onerror', onmessage)
eventStreamHelperInstance.subscribe('oncancel', onmessage)
eventStreamHelperInstance.subscribe('ontimeout', onmessage)
eventStreamHelperInstance.subscribe('onfinally', onmessage)
const params = {
sendMsg: '我说的是什么',
sessionId: '82627b9a-ee51-408d-a474-3305dd193378',
types: 'LOCAL',
resourceType: '',
resourceId: '',
convId: '',
boxType: 'AT_013',
elnSessionId: 'elnSessionId.544e67f4bf564997a5f5436efbfa50f2'
}
const send = () => {
eventStreamHelperInstance.sendSSE({
url: `http://cloud.21tb.com/gpt/chat/sendMsgSteam`,
params,
timeout: 1000 * 60 * 3
})
}
const stop = () => {
eventStreamHelperInstance.terminateRequest()
}
</script>
@yugu/tbc-sse
0.0.1 • Public • Published Readme
Keywords
nonePackage Sidebar
Install
npm i @yugu/tbc-sse
Weekly Downloads
4
Version
0.0.1
License
ISC
Unpacked Size
63.5 kB
Total Files
11