2026-05-28 20:44:53 +08:00
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
2026-05-29 10:39:12 +08:00
|
|
|
import router from '@/routers'
|
2026-05-28 20:44:53 +08:00
|
|
|
import type { DetectionLockHolder } from '@/stores/modules/detectionLock'
|
2026-05-29 10:39:12 +08:00
|
|
|
import mittBus, { STOP_DETECTION_TIMER_EVENT } from '@/utils/mittBus'
|
|
|
|
|
|
|
|
|
|
const stopDetectionTimer = () => {
|
|
|
|
|
mittBus.emit(STOP_DETECTION_TIMER_EVENT)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const goResourceManage = async () => {
|
|
|
|
|
if (router.hasRoute('resourceManage')) {
|
|
|
|
|
await router.push({ name: 'resourceManage' })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
await router.push('/resourceManage')
|
|
|
|
|
}
|
2026-05-28 20:44:53 +08:00
|
|
|
|
|
|
|
|
/**
|
2026-05-29 10:39:12 +08:00
|
|
|
* S1: 他人正在做检测, 自己抢锁被挡
|
2026-05-28 20:44:53 +08:00
|
|
|
*/
|
|
|
|
|
export const showLockBusyDialog = (holder: DetectionLockHolder) => {
|
2026-05-29 10:39:12 +08:00
|
|
|
stopDetectionTimer()
|
|
|
|
|
|
|
|
|
|
ElMessageBox.confirm(`「${holder.holderUserName}」正在做检测,请稍后。`, '检测进行中', {
|
|
|
|
|
confirmButtonText: '观看检测视频教学',
|
|
|
|
|
cancelButtonText: '我知道了',
|
|
|
|
|
type: 'warning',
|
|
|
|
|
distinguishCancelAndClose: true,
|
|
|
|
|
customClass: 'detection-lock-busy-dialog'
|
|
|
|
|
})
|
2026-05-28 20:44:53 +08:00
|
|
|
.then(() => {
|
2026-05-29 10:39:12 +08:00
|
|
|
return goResourceManage()
|
2026-05-28 20:44:53 +08:00
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
// 用户点了"我知道了"或关闭,什么都不做
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-29 10:39:12 +08:00
|
|
|
* S2: 未开始检测就调中间接口
|
2026-05-28 20:44:53 +08:00
|
|
|
*/
|
|
|
|
|
export const showLockNotStartedToast = () => {
|
|
|
|
|
ElMessage.warning('请先点击"开始检测"按钮启动本轮检测')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-29 10:39:12 +08:00
|
|
|
* S3: 自己暂停超 10 分钟, 被 WS 推 STOP_TIMEOUT 强制结束
|
2026-05-28 20:44:53 +08:00
|
|
|
*/
|
|
|
|
|
export const showPauseTimeoutDialog = () => {
|
2026-05-29 10:39:12 +08:00
|
|
|
stopDetectionTimer()
|
|
|
|
|
|
2026-05-28 20:44:53 +08:00
|
|
|
ElMessageBox.alert('暂停超过 10 分钟未恢复,系统已自动结束本次检测。\n\n如需继续,请重新发起检测。', '本次检测已结束', {
|
|
|
|
|
confirmButtonText: '我知道了',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).catch(() => {})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-29 10:39:12 +08:00
|
|
|
* S4: 被管理员强制释放
|
|
|
|
|
* - holder 为 null: 强释后无人接手
|
|
|
|
|
* - holder 非 null: 强释后被别人立刻抢占
|
2026-05-28 20:44:53 +08:00
|
|
|
*/
|
|
|
|
|
export const showForceReleasedDialog = (holder: DetectionLockHolder | null) => {
|
2026-05-29 10:39:12 +08:00
|
|
|
stopDetectionTimer()
|
|
|
|
|
|
2026-05-28 20:44:53 +08:00
|
|
|
if (holder) {
|
2026-05-29 10:39:12 +08:00
|
|
|
ElMessageBox.confirm(`当前「${holder.holderUserName}」正在做检测,您无法继续检测,请稍后。`, '检测已被中止', {
|
|
|
|
|
confirmButtonText: '观看检测视频教学',
|
|
|
|
|
cancelButtonText: '我知道了',
|
|
|
|
|
type: 'warning',
|
|
|
|
|
distinguishCancelAndClose: true
|
|
|
|
|
})
|
2026-05-28 20:44:53 +08:00
|
|
|
.then(() => {
|
2026-05-29 10:39:12 +08:00
|
|
|
return goResourceManage()
|
2026-05-28 20:44:53 +08:00
|
|
|
})
|
|
|
|
|
.catch(() => {})
|
|
|
|
|
} else {
|
|
|
|
|
ElMessageBox.alert('您的检测已被管理员强制结束。\n如需继续,请重新发起检测。', '检测已被中止', {
|
|
|
|
|
confirmButtonText: '我知道了',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).catch(() => {})
|
|
|
|
|
}
|
|
|
|
|
}
|