diff --git a/src/main/index.ts b/src/main/index.ts index 6c3e9d9..719441a 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -12,7 +12,8 @@ import "./capabilities"; import { catalogPath, loadCatalog } from "./catalog"; import { createDemoFlow, createExampleFlows, createFlow, deleteFlow, getFlow, listFlows, saveFlow } from "./flows"; import { capabilityCount, capabilityIds } from "./engine/registry"; -import { closeBrowserSession, startRun, stopRun } from "./run/manager"; +import { closeBrowserSession, setMainWindowGetter, startRun, stopRun } from "./run/manager"; +import { registerOverlayIpc } from "./overlay"; import { fixtureUrl, startFixtureServer, stopFixtureServer } from "./fixture/server"; import { loadSettings, updateSettings } from "./settings"; import { closeLocalVisionWorkers, defaultUiModelPath } from "./local-vision/ui-detect-service"; @@ -101,6 +102,8 @@ function registerIpc(): void { ipcMain.handle("catalog:get", () => loadCatalog()); ipcMain.handle("run:start", (event, flow: FlowDefinition) => startRun(flow, event.sender)); + setMainWindowGetter(() => mainWindow); + registerOverlayIpc(() => mainWindow, () => { stopRun(); }); ipcMain.handle("run:stop", (_event, runId?: string) => stopRun(runId)); ipcMain.handle("run:capabilities", () => ({ count: capabilityCount(), ids: capabilityIds() })); ipcMain.handle("settings:get", () => loadSettings()); diff --git a/src/main/overlay.ts b/src/main/overlay.ts new file mode 100644 index 0000000..f021e24 --- /dev/null +++ b/src/main/overlay.ts @@ -0,0 +1,144 @@ +import { BrowserWindow, ipcMain } from "electron"; +import path from "node:path"; + +let overlayWindow: BrowserWindow | null = null; +let cachedProgress = { current: "", done: 0, total: 0 }; + +export function showRunOverlay(mainWindow: BrowserWindow | null): void { + if (mainWindow && !mainWindow.isDestroyed()) mainWindow.minimize(); + + if (overlayWindow && !overlayWindow.isDestroyed()) { + overlayWindow.show(); + return; + } + + const w = 320; + const h = 56; + const { + screen + } = require("electron") as typeof import("electron"); + const workArea = screen.getPrimaryDisplay().workArea; + const x = workArea.x + workArea.width - w - 16; + const y = workArea.y + workArea.height - h - 16; + + overlayWindow = new BrowserWindow({ + width: w, + height: h, + x, + y, + frame: false, + resizable: false, + movable: false, + minimizable: false, + maximizable: false, + closable: false, + skipTaskbar: true, + alwaysOnTop: true, + fullscreenable: false, + enableLargerThanScreen: false, + hasShadow: true, + transparent: false, + backgroundColor: "#1E2530", + webPreferences: { + preload: path.join(__dirname, "../preload/index.js"), + contextIsolation: true, + nodeIntegration: false, + sandbox: false + } + }); + overlayWindow.setAlwaysOnTop(true, "screen-saver"); + + const html = ` + +
+
+
准备运行…
+
+
+
0/0
+ +