Commit cd5986e5 authored by 沈翠玲's avatar 沈翠玲

websocket

parent 808025bd
...@@ -102,14 +102,19 @@ ...@@ -102,14 +102,19 @@
import { getAppEnvConfig } from '@/utils/env'; import { getAppEnvConfig } from '@/utils/env';
const envs = getAppEnvConfig(); const envs = getAppEnvConfig();
const { userInfo } = useUserStore(); const { userInfo } = useUserStore();
if (!socketStore.ws && userInfo.id) { watch(
let url = `ws://8.152.205.9:8080/websocket/${userInfo.id}`; userInfo,
console.log('url', url); (newValue, oldValue) => {
socketStore.connection(url); console.log('asdsa', userInfo)
} if (userInfo.id) {
if (socketStore.ws) { let url = window.location.origin?.replace('https://', 'wss://').replace('http://', 'ws://') + '/api/websocket/' + userInfo.id;
socketStore.sendMsg({ aa: 44 }); socketStore.connection(url);
} }
if (socketStore.ws) {
socketStore.sendMsg({ aa: 44 });
}
}
,{ immediate: true });
const clickMsg = () => { const clickMsg = () => {
visible.value = false; visible.value = false;
newMsgList.value = []; newMsgList.value = [];
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { initDynamicRouter } from '@/router/modules/dynamicRouter'; import { initDynamicRouter } from '@/router/modules/dynamicRouter';
import { useUserStore } from '@/stores/modules/user'; import { useUserStore } from '@/stores/modules/user';
import useSocketStore from '@/stores/modules/websocket'; // import useSocketStore from '@/stores/modules/websocket';
import { useTabsStore } from '@/stores/modules/tabs'; import { useTabsStore } from '@/stores/modules/tabs';
import { useKeepAliveStore } from '@/stores/modules/keepAlive'; import { useKeepAliveStore } from '@/stores/modules/keepAlive';
import { HOME_URL } from '@/config'; import { HOME_URL } from '@/config';
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
import { getAppEnvConfig } from '@/utils/env'; import { getAppEnvConfig } from '@/utils/env';
const envs = getAppEnvConfig(); const envs = getAppEnvConfig();
const userStore = useUserStore(); const userStore = useUserStore();
const socketStore = useSocketStore(); // const socketStore = useSocketStore();
const tabsStore = useTabsStore(); const tabsStore = useTabsStore();
const keepAliveStore = useKeepAliveStore(); const keepAliveStore = useKeepAliveStore();
const tenantRef = ref(); const tenantRef = ref();
...@@ -142,8 +142,8 @@ ...@@ -142,8 +142,8 @@
const { result: userInfo } = await getUserInfo(); const { result: userInfo } = await getUserInfo();
userStore.setUserInfo(userInfo); userStore.setUserInfo(userInfo);
let url = `ws://8.152.205.9:8080/websocket/${userInfo.id}`; // let url = `ws://8.152.205.9:8080/websocket/${userInfo.id}`;
socketStore.connection(url); // socketStore.connection(url);
// 如果有多个调解中心,需要选择调解中心进入系统 // 如果有多个调解中心,需要选择调解中心进入系统
if (userInfo.tenants.length > 1) { if (userInfo.tenants.length > 1) {
tenantRef.value.openModal(userInfo.tenants); tenantRef.value.openModal(userInfo.tenants);
......
...@@ -58,6 +58,7 @@ export default defineConfig(({ command, mode }) => { ...@@ -58,6 +58,7 @@ export default defineConfig(({ command, mode }) => {
// target: 'http://192.168.31.187:8080', // target: 'http://192.168.31.187:8080',
// target: 'http://192.168.31.128:8080', // target: 'http://192.168.31.128:8080',
target: 'http://8.152.205.9:8080', target: 'http://8.152.205.9:8080',
ws:true,
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''), rewrite: (path) => path.replace(/^\/api/, ''),
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment