update 优化 websocket 代码实现

This commit is contained in:
疯狂的狮子Li
2023-12-23 19:49:17 +08:00
parent 1d557a24f9
commit 772885de35
2 changed files with 9 additions and 12 deletions

View File

@ -26,14 +26,7 @@ import SideBar from './components/Sidebar/index.vue';
import { AppMain, Navbar, Settings, TagsView } from './components';
import useAppStore from '@/store/modules/app';
import useSettingsStore from '@/store/modules/settings';
import { initWebSocket } from '@/utils/websocket';
import useNoticeStore from '@/store/modules/notice';
onMounted(() => {
let protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
initWebSocket(protocol + window.location.host + import.meta.env.VITE_APP_BASE_API + '/resource/websocket', useNoticeStore());
});
const settingsStore = useSettingsStore();
const theme = computed(() => settingsStore.theme);
@ -73,6 +66,11 @@ onMounted(() => {
});
});
onMounted(() => {
let protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
initWebSocket(protocol + window.location.host + import.meta.env.VITE_APP_BASE_API + '/resource/websocket');
});
const handleClickOutside = () => {
useAppStore().closeSideBar({ withoutAnimation: false });
};