gerson
2025-01-21 c9071fc1d8ae01496f4715adda6989a71b503a3d
src/utils/sse/index.ts
@@ -1,16 +1,12 @@
import { onMounted, onUnmounted } from 'vue';
import { SSEClient } from './SSEClient';
import { MAIN_URL } from '/@/constants';
// 创建实例
const sseClient = new SSEClient(
   '/events',
   {
      retries: 3,
      retryDelay: 1000,
      timeout: 30000,
      autoReconnect: true,
   `${MAIN_URL}events`,
   },
   {},
   {
      onMessage: (data) => {
         console.log('Received message:', data);
@@ -33,10 +29,8 @@
// 在 Vue 组件中使用
export function useSSE() {
   // 建立连接
   sseClient.connect({
      userId: 'xxx',
      sessionId: 'xxx',
   });
   sseClient.connect({});
   // onMounted(() => {
   //    // 建立连接