update at 2026-03-04 13:25:26
This commit is contained in:
23
pxterm/scripts/archive/cjs_tools/test_global_capture.cjs
Normal file
23
pxterm/scripts/archive/cjs_tools/test_global_capture.cjs
Normal file
@@ -0,0 +1,23 @@
|
||||
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);
|
||||
Reference in New Issue
Block a user