update 优化代码

This commit is contained in:
疯狂的狮子Li 2024-10-07 10:45:25 +08:00
parent 9726df3966
commit 364dfb969d
2 changed files with 4 additions and 8 deletions

View File

@ -73,7 +73,7 @@ onMounted(() => {
}); });
onMounted(() => { onMounted(() => {
initSSE(import.meta.env.VITE_APP_BASE_API + '/resource/sse') initSSE(import.meta.env.VITE_APP_BASE_API + '/resource/sse');
}); });
const handleClickOutside = () => { const handleClickOutside = () => {

View File

@ -2,8 +2,6 @@ import { getToken } from '@/utils/auth';
import { ElNotification } from 'element-plus'; import { ElNotification } from 'element-plus';
import useNoticeStore from '@/store/modules/notice'; import useNoticeStore from '@/store/modules/notice';
let message = '';
// 初始化 // 初始化
export const initSSE = (url: any) => { export const initSSE = (url: any) => {
url = url + '?Authorization=Bearer ' + getToken() + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID url = url + '?Authorization=Bearer ' + getToken() + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID
@ -15,13 +13,13 @@ export const initSSE = (url: any) => {
retries: 10, retries: 10,
delay: 3000, delay: 3000,
onFailed() { onFailed() {
console.log('Failed to connect after 10 retries') console.log('Failed to connect after 10 retries');
}, }
} }
}); });
watch(error, () => { watch(error, () => {
console.log('SSE connection error:', error.value) console.log('SSE connection error:', error.value);
error.value = null; error.value = null;
}); });
@ -41,5 +39,3 @@ export const initSSE = (url: any) => {
data.value = null; data.value = null;
}); });
}; };