fix 修复 websocket 非index页面刷新无法重连问题

This commit is contained in:
疯狂的狮子Li
2023-12-23 19:38:34 +08:00
parent 70a3348954
commit 597f2b4461
3 changed files with 13 additions and 13 deletions

View File

@ -27,6 +27,14 @@ 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);
const sidebar = computed(() => useAppStore().sidebar);