|
|
@ -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<DeviceWorkStateMessage>('DeviceWorkState', handleDeviceState); |
|
|
|
}); |
|
|
|
ws.connect() |
|
|
|
ws.subscribe<DeviceWorkStateMessage>('DeviceWorkState', handleDeviceState) |
|
|
|
ws.subscribe<FooterMessageState>('MessageBoxState', handleFooterState) |
|
|
|
}) |
|
|
|
onDeactivated(() => { |
|
|
|
ws.unsubscribe<DeviceWorkStateMessage>('DeviceWorkState', handleDeviceState); |
|
|
|
ws.disconnect(); |
|
|
|
ws.unsubscribe<DeviceWorkStateMessage>('DeviceWorkState', handleDeviceState) |
|
|
|
ws.unsubscribe<FooterMessageState>('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) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped lang="less"> |
|
|
|