diff --git a/web/src/layout/navBars/breadcrumb/user.vue b/web/src/layout/navBars/breadcrumb/user.vue index 92e68c6..5f167dc 100644 --- a/web/src/layout/navBars/breadcrumb/user.vue +++ b/web/src/layout/navBars/breadcrumb/user.vue @@ -60,11 +60,9 @@
- - - - - + + + {{ userInfos.username === '' ? 'common' : userInfos.username }} @@ -125,9 +123,6 @@ const layoutUserFlexNum = computed(() => { return num; }); -// 定义变量内容 -const { isSocketOpen } = storeToRefs(useUserInfo()); - // 全屏点击时 const onScreenfullClick = () => { if (!screenfull.isEnabled) { @@ -226,12 +221,21 @@ import { getBaseURL } from '/@/utils/baseUrl'; const messageCenter = messageCenterStore(); let eventSource: EventSource | null = null; // 存储 EventSource 实例 const token = Session.get('token'); +const isConnected = ref(false); // 标志变量,记录是否已连接过 const getMessageCenterCount = () => { // 创建 EventSource 实例并连接到后端 SSE 端点 - eventSource = new EventSource(`${getBaseURL()}/sse/?token=${token}`); // 替换为你的后端地址 - + eventSource = new EventSource(`${getBaseURL()}sse/?token=${token}`); // 替换为你的后端地址 + // 首次连接成功时打印一次 + eventSource.onopen = function () { + if (!isConnected.value) { + console.log('SSE 首次连接成功'); + isConnected.value = true; // 设置标志为已连接 + } + }; // 监听消息事件 eventSource.onmessage = function (event) { + console.log(event.data); + messageCenter.setUnread(+event.data); // 更新总记录数 }; diff --git a/web/src/layout/navBars/breadcrumb/userNews.vue b/web/src/layout/navBars/breadcrumb/userNews.vue index aa1b067..c51d477 100644 --- a/web/src/layout/navBars/breadcrumb/userNews.vue +++ b/web/src/layout/navBars/breadcrumb/userNews.vue @@ -48,9 +48,8 @@ const getLastMsg = () => { params: {}, }).then((res: any) => { const { data } = res; - console.log(data); + if (data) state.newsList = [data]; - state.newsList = [data]; }); }; onMounted(() => { diff --git a/web/src/stores/interface/index.ts b/web/src/stores/interface/index.ts index 9f73c92..5083cf4 100644 --- a/web/src/stores/interface/index.ts +++ b/web/src/stores/interface/index.ts @@ -23,7 +23,6 @@ export interface UserInfosState { } export interface UserInfosStates { userInfos: UserInfosState; - isSocketOpen: boolean } // 路由缓存列表 diff --git a/web/src/stores/userInfo.ts b/web/src/stores/userInfo.ts index a33d8cb..bdaf4bc 100644 --- a/web/src/stores/userInfo.ts +++ b/web/src/stores/userInfo.ts @@ -32,7 +32,6 @@ export const useUserInfo = defineStore('userInfo', { }, ], }, - isSocketOpen: false }), actions: { async setPwdChangeCount(count: number) { diff --git a/web/src/theme/element.scss b/web/src/theme/element.scss index 6cdebc9..741d731 100644 --- a/web/src/theme/element.scss +++ b/web/src/theme/element.scss @@ -1,4 +1,4 @@ -@import 'mixins/index.scss'; +@use 'mixins/index.scss' as index; /* Button 按钮 ------------------------------- */ @@ -100,7 +100,7 @@ .el-sub-menu .iconfont, .el-menu-item .fa, .el-sub-menu .fa { - @include generalIcon; + @include index.generalIcon; } // 水平菜单、横向菜单高亮 背景色,鼠标 hover 时,有子级菜单的背景色 .el-menu-item.is-active, diff --git a/web/src/theme/index.scss b/web/src/theme/index.scss index a94595c..80b7ce0 100644 --- a/web/src/theme/index.scss +++ b/web/src/theme/index.scss @@ -1,8 +1,8 @@ -@import './app.scss'; -@import 'common/transition.scss'; -@import './other.scss'; -@import './element.scss'; -@import './media/media.scss'; -@import './waves.scss'; -@import './dark.scss'; -@import './fa/css/font-awesome.min.css'; +@use './app.scss'; +@use 'common/transition.scss'; +@use './other.scss'; +@use './element.scss'; +@use './media/media.scss'; +@use './waves.scss'; +@use './dark.scss'; +@use './fa/css/font-awesome.min.css'; diff --git a/web/src/theme/media/chart.scss b/web/src/theme/media/chart.scss index 8485e39..7988339 100644 --- a/web/src/theme/media/chart.scss +++ b/web/src/theme/media/chart.scss @@ -1,8 +1,8 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于768px ------------------------------- */ -@media screen and (max-width: $sm) { +@media screen and (max-width: index.$sm) { .big-data-down-left { width: 100% !important; flex-direction: unset !important; @@ -51,7 +51,7 @@ /* 页面宽度大于768px小于1200px ------------------------------- */ -@media screen and (min-width: $sm) and (max-width: $lg) { +@media screen and (min-width: index.$sm) and (max-width: index.$lg) { .chart-warp-bottom { .big-data-down-left { width: 50% !important; @@ -72,7 +72,7 @@ /* 页面宽度小于1200px ------------------------------- */ -@media screen and (max-width: $lg) { +@media screen and (max-width: index.$lg) { .chart-warp-top { .up-left { display: none; diff --git a/web/src/theme/media/cityLinkage.scss b/web/src/theme/media/cityLinkage.scss index 1394156..edc6d11 100644 --- a/web/src/theme/media/cityLinkage.scss +++ b/web/src/theme/media/cityLinkage.scss @@ -1,8 +1,8 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于576px ------------------------------- */ -@media screen and (max-width: $xs) { +@media screen and (max-width: index.$xs) { .el-cascader__dropdown.el-popper { overflow: auto; max-width: 100%; diff --git a/web/src/theme/media/date.scss b/web/src/theme/media/date.scss index 1a50397..4b3c5e8 100644 --- a/web/src/theme/media/date.scss +++ b/web/src/theme/media/date.scss @@ -1,8 +1,8 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于768px ------------------------------- */ -@media screen and (max-width: $sm) { +@media screen and (max-width: index.$sm) { // 时间选择器适配 .el-date-range-picker { width: 100vw; diff --git a/web/src/theme/media/dialog.scss b/web/src/theme/media/dialog.scss index 023ccae..6435503 100644 --- a/web/src/theme/media/dialog.scss +++ b/web/src/theme/media/dialog.scss @@ -1,4 +1,4 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于800px ------------------------------- */ diff --git a/web/src/theme/media/error.scss b/web/src/theme/media/error.scss index f35015f..3ee65db 100644 --- a/web/src/theme/media/error.scss +++ b/web/src/theme/media/error.scss @@ -1,8 +1,8 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于768px ------------------------------- */ -@media screen and (max-width: $sm) { +@media screen and (max-width: index.$sm) { .error { .error-flex { flex-direction: column-reverse !important; @@ -26,7 +26,7 @@ /* 页面宽度大于768px小于992px ------------------------------- */ -@media screen and (min-width: $sm) and (max-width: $md) { +@media screen and (min-width: index.$sm) and (max-width: index.$md) { .error { .error-flex { padding-left: 30px !important; @@ -36,7 +36,7 @@ /* 页面宽度小于1200px ------------------------------- */ -@media screen and (max-width: $lg) { +@media screen and (max-width: index.$lg) { .error { .error-flex { padding: 0 30px; diff --git a/web/src/theme/media/form.scss b/web/src/theme/media/form.scss index eb1d883..ab382f2 100644 --- a/web/src/theme/media/form.scss +++ b/web/src/theme/media/form.scss @@ -1,8 +1,8 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于576px ------------------------------- */ -@media screen and (max-width: $xs) { +@media screen and (max-width: index.$xs) { .el-form-item__label { width: 100% !important; text-align: left !important; diff --git a/web/src/theme/media/home.scss b/web/src/theme/media/home.scss index 5a2417e..88a9669 100644 --- a/web/src/theme/media/home.scss +++ b/web/src/theme/media/home.scss @@ -1,8 +1,8 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于768px ------------------------------- */ -@media screen and (max-width: $sm) { +@media screen and (max-width: index.$sm) { .home-media, .home-media-sm { margin-top: 15px; @@ -11,7 +11,7 @@ /* 页面宽度小于1200px ------------------------------- */ -@media screen and (max-width: $lg) { +@media screen and (max-width: index.$lg) { .home-media-lg { margin-top: 15px; } diff --git a/web/src/theme/media/layout.scss b/web/src/theme/media/layout.scss index df8ce56..620991b 100644 --- a/web/src/theme/media/layout.scss +++ b/web/src/theme/media/layout.scss @@ -1,8 +1,8 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于576px ------------------------------- */ -@media screen and (max-width: $xs) { +@media screen and (max-width: index.$xs) { // MessageBox 弹框 .el-message-box { width: 80% !important; @@ -11,7 +11,7 @@ /* 页面宽度小于768px ------------------------------- */ -@media screen and (max-width: $sm) { +@media screen and (max-width: index.$sm) { // Breadcrumb 面包屑 .layout-navbars-breadcrumb-hide { display: none; diff --git a/web/src/theme/media/login.scss b/web/src/theme/media/login.scss index 29cdbb0..f041ffa 100644 --- a/web/src/theme/media/login.scss +++ b/web/src/theme/media/login.scss @@ -1,8 +1,8 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于1200px ------------------------------- */ -@media screen and (max-width: $lg) and (min-width: $xs) { +@media screen and (max-width: index.$lg) and (min-width: index.$xs) { .login-container { .login-left { .login-left-img { @@ -23,7 +23,7 @@ /* 页面宽度小于576px ------------------------------- */ -@media screen and (max-width: $xs) { +@media screen and (max-width: index.$xs) { .login-container { .login-left { display: none; @@ -59,7 +59,7 @@ /* 页面宽度小于375px ------------------------------- */ -@media screen and (max-width: $us) { +@media screen and (max-width: index.$us) { .login-container { .login-right { .login-right-warp { diff --git a/web/src/theme/media/media.scss b/web/src/theme/media/media.scss index bed1c35..f5f00c7 100644 --- a/web/src/theme/media/media.scss +++ b/web/src/theme/media/media.scss @@ -1,13 +1,13 @@ -@import './login.scss'; -@import './error.scss'; -@import './layout.scss'; -@import './personal.scss'; -@import './tagsView.scss'; -@import './home.scss'; -@import './chart.scss'; -@import './form.scss'; -@import './scrollbar.scss'; -@import './pagination.scss'; -@import './dialog.scss'; -@import './cityLinkage.scss'; -@import './date.scss'; +@use './login.scss'; +@use './error.scss'; +@use './layout.scss'; +@use './personal.scss'; +@use './tagsView.scss'; +@use './home.scss'; +@use './chart.scss'; +@use './form.scss'; +@use './scrollbar.scss'; +@use './pagination.scss'; +@use './dialog.scss'; +@use './cityLinkage.scss'; +@use './date.scss'; diff --git a/web/src/theme/media/pagination.scss b/web/src/theme/media/pagination.scss index 37af75f..1077039 100644 --- a/web/src/theme/media/pagination.scss +++ b/web/src/theme/media/pagination.scss @@ -1,8 +1,8 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于576px ------------------------------- */ -@media screen and (max-width: $xs) { +@media screen and (max-width: index.$xs) { .el-pager, .el-pagination__jump { display: none !important; diff --git a/web/src/theme/media/personal.scss b/web/src/theme/media/personal.scss index 7ec0d4a..d5c1d8e 100644 --- a/web/src/theme/media/personal.scss +++ b/web/src/theme/media/personal.scss @@ -1,8 +1,8 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于768px ------------------------------- */ -@media screen and (max-width: $sm) { +@media screen and (max-width: index.$sm) { .personal-info { padding-left: 0 !important; margin-top: 15px; diff --git a/web/src/theme/media/scrollbar.scss b/web/src/theme/media/scrollbar.scss index 968a79d..9a36d80 100644 --- a/web/src/theme/media/scrollbar.scss +++ b/web/src/theme/media/scrollbar.scss @@ -1,8 +1,8 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于768px ------------------------------- */ -@media screen and (max-width: $sm) { +@media screen and (max-width: index.$sm) { // 滚动条的宽度 ::-webkit-scrollbar { width: 3px !important; diff --git a/web/src/theme/media/tagsView.scss b/web/src/theme/media/tagsView.scss index b71674e..ad531da 100644 --- a/web/src/theme/media/tagsView.scss +++ b/web/src/theme/media/tagsView.scss @@ -1,8 +1,8 @@ -@import './index.scss'; +@use './index.scss' as index; /* 页面宽度小于768px ------------------------------- */ -@media screen and (max-width: $sm) { +@media screen and (max-width: index.$sm) { .tags-view-form { .tags-view-form-col { margin-bottom: 20px; diff --git a/web/src/utils/service.ts b/web/src/utils/service.ts index 4207572..0080f78 100644 --- a/web/src/utils/service.ts +++ b/web/src/utils/service.ts @@ -172,20 +172,20 @@ function createRequestFunction(service: any) { return function (config: any) { const configDefault = { headers: { - 'Content-Type': get(config, 'headers.Content-Type', 'application/json'), + 'Content-Type': 'application/json', }, timeout: 5000, baseURL: getBaseURL(), data: {}, }; - + Object.assign(configDefault, config); // const token = userStore.getToken; const token = Session.get('token'); if (token != null) { // @ts-ignore configDefault.headers.Authorization = 'JWT ' + token; } - return service(Object.assign(configDefault, config)); + return service(configDefault); }; } diff --git a/web/src/views/system/login/component/oauth2.vue b/web/src/views/system/login/component/oauth2.vue index 1b0c0c6..1a2c6cb 100644 --- a/web/src/views/system/login/component/oauth2.vue +++ b/web/src/views/system/login/component/oauth2.vue @@ -40,7 +40,7 @@ export default defineComponent({ // }; onMounted(() => { - getBackends(); + // getBackends(); }); return { ...toRefs(state), diff --git a/web/src/views/system/login/index.vue b/web/src/views/system/login/index.vue index 897ddc4..36acbe6 100644 --- a/web/src/views/system/login/index.vue +++ b/web/src/views/system/login/index.vue @@ -47,10 +47,10 @@