diff --git a/src/pages/Index/Index.vue b/src/pages/Index/Index.vue
index ddfa97f..b72bceb 100644
--- a/src/pages/Index/Index.vue
+++ b/src/pages/Index/Index.vue
@@ -86,8 +86,14 @@
-
-
+
+
@@ -211,7 +217,9 @@ import {
import { User } from '../../types/Index'
import { useConsumablesStore, useDeviceStore } from '../../store'
import { createWebSocket } from '../../websocket/socket'
-import type { AppEventMessage } from '../../websocket/socket'
+import type {
+ AppEventMessage
+} from '../../websocket/socket'
import { getServerInfo } from '../../utils/getServerInfo'
import { eventBus } from '../../eventBus'
import { logout } from '@/services/Login/login'
@@ -312,6 +320,7 @@ const saveIdInfo = async () => {
const showInitDeviceAlert = () => {
showModal.value = true
}
+
onMounted(() => {
eventBus.on('initDevice', showInitDeviceAlert)
ws.connect()
diff --git a/src/pages/Index/Regular.vue b/src/pages/Index/Regular.vue
index 7833574..6b8a9d7 100644
--- a/src/pages/Index/Regular.vue
+++ b/src/pages/Index/Regular.vue
@@ -15,10 +15,13 @@
import TabBar from './components/Consumables/TabBar.vue'
import { createWebSocket } from '@/websocket/socket'
import { getServerInfo } from '@/utils/getServerInfo'
-import { onMounted, onDeactivated } from 'vue';
-import type { DeviceWorkStateMessage } from '@/websocket/socket';
-import { useDeviceStore, useSettingTestTubeStore } from '@/store/index';
-import { getBloodTypes, getProjectInfo } from '@/services/Index/testTube';
+import { onMounted, onDeactivated } from 'vue'
+import type {
+ DeviceWorkStateMessage,
+ FooterMessageState,
+} from '@/websocket/socket'
+import { useDeviceStore, useSettingTestTubeStore } from '@/store/index'
+import { getBloodTypes, getProjectInfo } from '@/services/Index/testTube'
const deviceStore = useDeviceStore()
const settingTubeStore = useSettingTestTubeStore()
@@ -28,17 +31,23 @@ const ws = createWebSocket(wsUrl)
const handleDeviceState = (data: DeviceWorkStateMessage['data']) => {
deviceStore.setDeviceState(data)
}
+const handleFooterState = (data: FooterMessageState['data']) => {
+ deviceStore.setMessageState(data)
+}
+
onMounted(() => {
getProjectList()
getBloodTypeList()
- ws.connect();
- ws.subscribe('DeviceWorkState', handleDeviceState);
-});
+ ws.connect()
+ ws.subscribe('DeviceWorkState', handleDeviceState)
+ ws.subscribe('MessageBoxState', handleFooterState)
+})
onDeactivated(() => {
- ws.unsubscribe('DeviceWorkState', handleDeviceState);
- ws.disconnect();
+ ws.unsubscribe('DeviceWorkState', handleDeviceState)
+ ws.unsubscribe('MessageBoxState', handleFooterState)
+ ws.disconnect()
console.log('🚀 ~ onBeforeUnmount ~ regular页面销毁:')
-});
+})
const getProjectList = async () => {
const res = await getProjectInfo()
@@ -52,7 +61,6 @@ const getBloodTypeList = async () => {
settingTubeStore.setBloodTypes(res.data)
}
}
-