From 1644070e97af5df11a9cc655a93f4e3e778ae879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E8=A5=BF=E7=93=9Ci?= <5785714@qq.com> Date: Mon, 14 Oct 2024 20:33:16 +0800 Subject: [PATCH] =?UTF-8?q?add=20SSE=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 1 + .env.production | 1 + src/utils/sse.ts | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/.env.development b/.env.development index 05d6778..e94d5fa 100644 --- a/.env.development +++ b/.env.development @@ -30,3 +30,4 @@ VITE_APP_CLIENT_ID = 'e5cd7e4891bf95d1d19206ce24a7b32e' # websocket 开关 默认使用sse推送 VITE_APP_WEBSOCKET = false +VITE_APP_SSE = true diff --git a/.env.production b/.env.production index c6b1f85..0b487f6 100644 --- a/.env.production +++ b/.env.production @@ -33,3 +33,4 @@ VITE_APP_CLIENT_ID = 'e5cd7e4891bf95d1d19206ce24a7b32e' # websocket 开关 默认使用sse推送 VITE_APP_WEBSOCKET = false +VITE_APP_SSE = true diff --git a/src/utils/sse.ts b/src/utils/sse.ts index 0f74d0e..9174f0d 100644 --- a/src/utils/sse.ts +++ b/src/utils/sse.ts @@ -4,6 +4,10 @@ import useNoticeStore from '@/store/modules/notice'; // 初始化 export const initSSE = (url: any) => { + if (import.meta.env.VITE_APP_SSE === 'false') { + return; + } + url = url + '?Authorization=Bearer ' + getToken() + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID const { data,