diff --git a/src/config/axios/config.ts b/src/config/axios/config.ts index 8116508..fc3d6c9 100644 --- a/src/config/axios/config.ts +++ b/src/config/axios/config.ts @@ -7,7 +7,7 @@ const config: { /** * api请求基础路径 */ - base_url: import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL, + base_url: `http://${window.location.hostname}:48080` + import.meta.env.VITE_API_URL, /** * 接口成功返回状态码 */ diff --git a/src/main.ts b/src/main.ts index d45d5cb..87c2991 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,3 +1,6 @@ +// 动态生成 baseUrl 并共享给其他模块 +const baseUrl = `http://${window.location.hostname}:48080`; + // 引入unocss css import '@/plugins/unocss' diff --git a/src/views/Home/Index.vue b/src/views/Home/Index.vue index 09a450c..42d33f5 100644 --- a/src/views/Home/Index.vue +++ b/src/views/Home/Index.vue @@ -257,11 +257,6 @@ const getShortcut = async () => { icon: 'ep:pointer', url: 'logistics/stock' }, - { - name: '实时视频', - icon: 'ep:magic-stick', - url: 'cameraTree/cameraStreet' - }, { name: '巷道管理', icon: 'fa-solid:rainbow', @@ -292,24 +287,6 @@ const laneInventoryLineOptions = ref({}) const orderChartOption = ref({}) -let eventSource: any = null -const sseUid = ref(`${Date.now()}-${Math.floor(Math.random() * 10000)}`) -const sse = ()=>{ - // 创建一个 EventSource 实例,连接到后端的 SSE 路径 - eventSource = new EventSource('http://192.168.0.10:48080/app-api/sse/createSse?uid=' + sseUid.value ); - - // 监听来自后端的消息 - eventSource.onmessage = (event) => { - const data = JSON.parse(event.data); - console.log(data); - -}; - -// 处理错误 -eventSource.onerror = (error) => { - console.error('SSE 连接发生错误:', error); -}; -} // 盘点饼状图选项 const stockPieOptions = reactive({ @@ -415,14 +392,12 @@ onMounted(() => { CameraApi.getCameraList().then((res) => { cameraList.value = res }) - sse() + }) onUnmounted(() => { // 在组件销毁时关闭 EventSource 连接 - if (eventSource) { - eventSource.close(); - } + })