diff --git a/.env.development b/.env.development index 05d6778..14e1335 100644 --- a/.env.development +++ b/.env.development @@ -30,3 +30,6 @@ VITE_APP_CLIENT_ID = 'e5cd7e4891bf95d1d19206ce24a7b32e' # websocket 开关 默认使用sse推送 VITE_APP_WEBSOCKET = false + +# sse 开关 +VITE_APP_SSE = true diff --git a/.env.production b/.env.production index c6b1f85..1109bc6 100644 --- a/.env.production +++ b/.env.production @@ -33,3 +33,6 @@ VITE_APP_CLIENT_ID = 'e5cd7e4891bf95d1d19206ce24a7b32e' # websocket 开关 默认使用sse推送 VITE_APP_WEBSOCKET = false + +# sse 开关 +VITE_APP_SSE = true diff --git a/src/layout/index.vue b/src/layout/index.vue index 0919aad..ce47a30 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -73,7 +73,7 @@ onMounted(() => { }); onMounted(() => { - initSSE(import.meta.env.VITE_APP_BASE_API + '/resource/sse') + initSSE(import.meta.env.VITE_APP_BASE_API + '/resource/sse'); }); const handleClickOutside = () => { diff --git a/src/types/env.d.ts b/src/types/env.d.ts index 777c858..1fb9f62 100644 --- a/src/types/env.d.ts +++ b/src/types/env.d.ts @@ -19,6 +19,7 @@ interface ImportMetaEnv { VITE_APP_RSA_PRIVATE_KEY: string; VITE_APP_CLIENT_ID: string; VITE_APP_WEBSOCKET: string; + VITE_APP_SSE: string; } interface ImportMeta { readonly env: ImportMetaEnv; diff --git a/src/utils/sse.ts b/src/utils/sse.ts index a08f282..9174f0d 100644 --- a/src/utils/sse.ts +++ b/src/utils/sse.ts @@ -2,10 +2,12 @@ import { getToken } from '@/utils/auth'; import { ElNotification } from 'element-plus'; import useNoticeStore from '@/store/modules/notice'; -let message = ''; - // 初始化 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, @@ -15,13 +17,13 @@ export const initSSE = (url: any) => { retries: 10, delay: 3000, onFailed() { - console.log('Failed to connect after 10 retries') - }, + console.log('Failed to connect after 10 retries'); + } } }); watch(error, () => { - console.log('SSE connection error:', error.value) + console.log('SSE connection error:', error.value); error.value = null; }); @@ -41,5 +43,3 @@ export const initSSE = (url: any) => { data.value = null; }); }; - - diff --git a/src/views/monitor/logininfor/index.vue b/src/views/monitor/logininfor/index.vue index 03d0d8f..4cc890d 100644 --- a/src/views/monitor/logininfor/index.vue +++ b/src/views/monitor/logininfor/index.vue @@ -198,7 +198,7 @@ const handleExport = () => { { ...queryParams.value }, - `config_${new Date().getTime()}.xlsx` + `logininfor_${new Date().getTime()}.xlsx` ); }; diff --git a/src/views/workflow/leave/leaveEdit.vue b/src/views/workflow/leave/leaveEdit.vue index a4ed946..55556fd 100644 --- a/src/views/workflow/leave/leaveEdit.vue +++ b/src/views/workflow/leave/leaveEdit.vue @@ -23,10 +23,12 @@ @@ -190,8 +192,8 @@ const handleStartWorkFlow = async (data: LeaveVO) => { taskVariables.value = { entity: data, leaveDays: data.leaveDays, - userList: [1, 3], - userList2: [1, 3] + userList: ["1", "3"], + userList2: ["1", "3"] }; submitFormData.value.variables = taskVariables.value; const resp = await startWorkFlow(submitFormData.value);