返回 DeepSeek-Reasonix
guestPreload.ts
根目录 / desktop / electron / src / main / browser / guestPreload.ts
1 import { ipcRenderer } from "electron";
2 import { IPC } from "../../shared/ipc.js";
3
4 // Runs in every frame of a website view. It exposes nothing to the page and
5 // only reports trusted user input so the shell can hand the tab to the user.
6 const KINDS = ["mousedown", "keydown", "wheel", "touchstart", "pointerdown"] as const;
7 const RATE_LIMIT_MS = 250;
8 let lastSentAt = 0;
9
10 for (const kind of KINDS) {
11 window.addEventListener(
12 kind,
13 (event) => {
14 if (!event.isTrusted) return;
15 const now = Date.now();
16 if (now - lastSentAt < RATE_LIMIT_MS) return;
17 lastSentAt = now;
18 ipcRenderer.send(IPC.browserTakeover, { kind });
19 },
20 { capture: true, passive: true },
21 );
22 }
23
23 lines TYPESCRIPT