(dd: IDisableDevtool)
| 17 | let time = 0; |
| 18 | |
| 19 | export function initInterval (dd: IDisableDevtool) { |
| 20 | let _pause = false; |
| 21 | const pause = () => {_pause = true;}; |
| 22 | const goon = () => {_pause = false;}; |
| 23 | hackAlert(pause, goon); // 防止 alert等方法触发了debug延迟计算 |
| 24 | onPageShowHide(goon, pause); // 防止切后台触发了debug延迟计算 |
| 25 | |
| 26 | interval = window.setInterval(() => { |
| 27 | if (dd.isSuspend || _pause || isIgnored()) return; |
| 28 | for (const detector of calls) { |
| 29 | clearDevToolOpenState(detector.type); |
| 30 | detector.detect(time++); |
| 31 | }; |
| 32 | clearLog(); |
| 33 | checkOnDevClose(); |
| 34 | }, config.interval); |
| 35 | // stopIntervalTime 之后判断 如果不是pc去掉定时器interval,为了优化移动端的性能 |
| 36 | // 如果控制面板被打开了该定时器timer会被清除 |
| 37 | timer = setTimeout(() => { |
| 38 | if (!IS.pc && !DebugLib.isUsing()) { |
| 39 | clearDDInterval(); |
| 40 | } |
| 41 | }, config.stopIntervalTime); |
| 42 | } |
| 43 | |
| 44 | export function registInterval (detector: Detector) { |
| 45 | calls.push(detector); |
no test coverage detected