24 lines
1.3 KiB
JavaScript
24 lines
1.3 KiB
JavaScript
const fs = require('fs');
|
|
let code = fs.readFileSync('src/components/TerminalPanel.vue', 'utf8');
|
|
|
|
const globalTracker = `
|
|
// --- 极致全局监听器,抓出是谁吃掉了 move ---
|
|
const globalEventDebug = (e: Event) => {
|
|
// 若这是消失的 move 事件,打出到底在哪被拦截了
|
|
if (e.type === "touchmove" || e.type === "pointermove" || e.type === "touchcancel" || e.type === "pointercancel") {
|
|
// 为了不刷屏,如果是 pointermove 我们只在 touch 活跃时打印
|
|
if (e.type === "pointermove" && (e as PointerEvent).pointerType !== "touch") return;
|
|
|
|
console.log(\`[GLOBAL INTERCEPT] \${e.type} | Phase: \${e.eventPhase} | Cancelable: \${e.cancelable} | Target: \${(e.target as Element)?.className || (e.target as Element)?.tagName}\`);
|
|
}
|
|
};
|
|
|
|
['touchmove', 'touchstart', 'touchend', 'touchcancel', 'pointerdown', 'pointermove', 'pointerup', 'pointercancel'].forEach(type => {
|
|
// 用最顶级的 window capture 拦截,这样在任何人(包括 xterm 内部那些黑盒代码)前面执行
|
|
window.addEventListener(type, globalEventDebug, { capture: true, passive: false });
|
|
});
|
|
`;
|
|
|
|
code = code.replace(/function initTerminal\(\)\: void \{/, `function initTerminal(): void {\n${globalTracker}`);
|
|
fs.writeFileSync('src/components/TerminalPanel.vue', code);
|