import DisableDevtool from 'disable-devtool' import { ElMessageBox } from 'element-plus' /** * 安全警告的HTML模板, 使用Tailwind CSS样式 */ const SECURITY_WARNING_TEMPLATE = `

不合规操作,系统将在5秒后自动关闭退出!

如您频繁此类操作,系统将记录上报。

` /** * Element Plus 消息框配置选项 */ const ALERT_OPTIONS = { type: 'error', showClose: false, center: true, closeOnClickModal: false, closeOnPressEscape: false, dangerouslyUseHTMLString: true, } export default () => { if (import.meta.env.VITE_APP_DEBUG_SWITCH === 'false') return const debugKey = import.meta.env.VITE_APP_DEBUG_KEY let flag = false DisableDevtool({ md5: DisableDevtool.md5(debugKey), disableMenu: false, ondevtoolopen: (type, next) => { if (!flag) ElMessageBox.alert(SECURITY_WARNING_TEMPLATE, '安全警告', ALERT_OPTIONS) flag = true setTimeout(() => { next() }, 5000) }, }) }