补充观看教学视频路由跳转功能,检测页面微调
This commit is contained in:
@@ -122,7 +122,8 @@
|
||||
<script lang="tsx" setup name="test">
|
||||
import {InfoFilled, Loading} from '@element-plus/icons-vue'
|
||||
import CompareDataCheckSingleChannelSingleTestPopup from './compareDataCheckSingleChannelSingleTestPopup.vue'
|
||||
import {computed, ComputedRef, nextTick, onBeforeMount, onMounted, reactive, ref, toRef, watch} from 'vue'
|
||||
import {computed, nextTick, onBeforeMount, onBeforeUnmount, onMounted, reactive, ref, toRef, watch} from 'vue'
|
||||
import type { ComputedRef } from 'vue'
|
||||
import {dialogBig} from '@/utils/elementBind'
|
||||
import {CheckData} from '@/api/check/interface'
|
||||
import {useCheckStore} from '@/stores/modules/check'
|
||||
@@ -132,6 +133,7 @@ import {getAutoGenerate, getCanCoefficient, startCoefficient} from '@/api/user/l
|
||||
import { generateDevReport } from '@/api/plan/plan'
|
||||
import {useModeStore} from '@/stores/modules/mode' // 引入模式 store
|
||||
import {useDictStore} from '@/stores/modules/dict'
|
||||
import mittBus, { STOP_DETECTION_TIMER_EVENT } from '@/utils/mittBus'
|
||||
const checkStore = useCheckStore()
|
||||
const modeStore = useModeStore()
|
||||
const dictStore = useDictStore()
|
||||
@@ -740,6 +742,10 @@ const stopTimeCount = (type: number) => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleStopDetectionTimer = () => {
|
||||
stopTimeCount(1)
|
||||
}
|
||||
|
||||
// 将秒数转换为 HH:MM:SS 格式
|
||||
const secondToTime = (second: number) => {
|
||||
let h: string | number = Math.floor(second / 3600) // 小时
|
||||
@@ -898,6 +904,7 @@ const initializeParameters = async () => {
|
||||
|
||||
//
|
||||
onMounted(() => {
|
||||
mittBus.on(STOP_DETECTION_TIMER_EVENT, handleStopDetectionTimer)
|
||||
|
||||
if (!checkStore.selectTestItems.preTest) {
|
||||
// 判断是否预检测
|
||||
@@ -905,6 +912,10 @@ onMounted(() => {
|
||||
}
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
mittBus.off(STOP_DETECTION_TIMER_EVENT, handleStopDetectionTimer)
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
initializeParameters,
|
||||
handlePause,
|
||||
|
||||
@@ -148,6 +148,7 @@ import { useCheckStore } from '@/stores/modules/check'
|
||||
import { contrastTest, pauseTest, resumeTest, startPreTest } from '@/api/socket/socket'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import { JwtUtil } from '@/utils/jwtUtil'
|
||||
import mittBus, { STOP_DETECTION_TIMER_EVENT } from '@/utils/mittBus'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const checkStore = useCheckStore()
|
||||
@@ -165,6 +166,14 @@ const preTestStatus = ref('waiting') //预检测执行状态
|
||||
const TestStatus = ref('waiting') //正式检测执行状态
|
||||
const webMsgSend = ref() //webSocket推送的数据
|
||||
|
||||
const hideInitializingButton = () => {
|
||||
if (TestStatus.value === 'test_init') {
|
||||
TestStatus.value = 'waiting'
|
||||
}
|
||||
}
|
||||
|
||||
mittBus.on(STOP_DETECTION_TIMER_EVENT, hideInitializingButton)
|
||||
|
||||
const dialogTitle = ref('')
|
||||
const showComponent = ref(true)
|
||||
const preTestRef = ref<InstanceType<typeof ComparePreTest> | null>(null)
|
||||
@@ -187,6 +196,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
mittBus.off(STOP_DETECTION_TIMER_EVENT, hideInitializingButton)
|
||||
window.removeEventListener('resize', handleResize)
|
||||
})
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ import { InfoFilled, Loading } from '@element-plus/icons-vue'
|
||||
// 单通道单测试项详情弹窗组件
|
||||
import dataCheckSingleChannelSingleTestPopup from './dataCheckSingleChannelSingleTestPopup.vue'
|
||||
// Vue 3 Composition API
|
||||
import { computed, reactive, ref, toRef, watch } from 'vue'
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref, toRef, watch } from 'vue'
|
||||
// 对话框大小绑定工具
|
||||
import { dialogBig } from '@/utils/elementBind'
|
||||
// 检测数据类型定义
|
||||
@@ -120,6 +120,7 @@ import { getAutoGenerate } from '@/api/user/login'
|
||||
import { generateDevReport } from '@/api/plan/plan'
|
||||
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import mittBus, { STOP_DETECTION_TIMER_EVENT } from '@/utils/mittBus'
|
||||
|
||||
// 获取检测状态管理实例
|
||||
const checkStore = useCheckStore()
|
||||
@@ -1176,6 +1177,10 @@ const stopTimeCount = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleStopDetectionTimer = () => {
|
||||
stopTimeCount()
|
||||
}
|
||||
|
||||
|
||||
// 恢复计时(用于暂停后继续)
|
||||
const resumeTimeCount = () => {
|
||||
@@ -1199,8 +1204,14 @@ const secondToTime = (second: number) => {
|
||||
return h + ':' + m + ':' + s
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
mittBus.on(STOP_DETECTION_TIMER_EVENT, handleStopDetectionTimer)
|
||||
})
|
||||
|
||||
// 组件卸载前清理定时器和响应式引用
|
||||
onBeforeUnmount(() => {
|
||||
mittBus.off(STOP_DETECTION_TIMER_EVENT, handleStopDetectionTimer)
|
||||
|
||||
// 清理定时器
|
||||
if (timer) {
|
||||
clearInterval(timer)
|
||||
|
||||
@@ -172,6 +172,7 @@ import { useCheckStore } from '@/stores/modules/check'
|
||||
import { pauseTest, resumeTest, startPreTest } from '@/api/socket/socket'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import { JwtUtil } from '@/utils/jwtUtil'
|
||||
import mittBus, { STOP_DETECTION_TIMER_EVENT } from '@/utils/mittBus'
|
||||
|
||||
// ====================== 状态管理 ======================
|
||||
const userStore = useUserStore()
|
||||
@@ -200,6 +201,14 @@ const channelsTestStatus = ref('waiting') // 通道系数校准执行状态
|
||||
const TestStatus = ref('waiting') // 正式检测执行状态
|
||||
const webMsgSend = ref() // webSocket推送的数据,用于组件间通信
|
||||
|
||||
const hideInitializingButton = () => {
|
||||
if (TestStatus.value === 'test_init') {
|
||||
TestStatus.value = 'waiting'
|
||||
}
|
||||
}
|
||||
|
||||
mittBus.on(STOP_DETECTION_TIMER_EVENT, hideInitializingButton)
|
||||
|
||||
// ====================== WebSocket 相关 ======================
|
||||
const dataSocket = reactive<{
|
||||
socketServe: typeof socketClient.Instance | null
|
||||
@@ -705,6 +714,7 @@ const handleClose = () => {
|
||||
* 确保路由切换或组件销毁时正确关闭WebSocket连接
|
||||
*/
|
||||
onBeforeUnmount(() => {
|
||||
mittBus.off(STOP_DETECTION_TIMER_EVENT, hideInitializingButton)
|
||||
closeWebSocket() // 组件销毁前关闭WebSocket连接
|
||||
})
|
||||
|
||||
@@ -767,4 +777,4 @@ defineExpose({ open }) // 只暴露open方法供父组件调用
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user