阶段2-断Electron依赖: human-dialog/window-extended/ai-service经HostBridge迁入包, external+transport迁包(session留宿主), 新增check:deps依赖护栏与包README留守清单
This commit is contained in:
1 parent
caa8e19332
commit
3decced268
21 files changed
+505
-236
No files matched your search
+28
-3
@@ -1,4 +1,4 @@
|
||||
import { app, BrowserWindow, dialog, ipcMain, shell } from "electron";
|
||||
import { app, BrowserWindow, dialog, ipcMain, screen, shell } from "electron";
|
||||
import path from "node:path";
|
||||
import type { AppInfo, AppSettings, FlowDefinition, FlowSaveOptions, FlowSaveResult } from "../shared/types";
|
||||
import {
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
import "./capabilities";
|
||||
import { catalogPath, loadCatalog } from "./catalog";
|
||||
import { createDemoFlow, createExampleFlows, createFlow, deleteFlow, getFlow, listFlows, saveFlow } from "./flows";
|
||||
import { capabilityCount, capabilityIds, setSubflowSource } from "@rpa/core";
|
||||
import { capabilityCount, capabilityIds, setHostBridge, setSubflowSource, type HostDialogWindow } from "@rpa/core";
|
||||
import { closeBrowserSession, setMainWindowGetter, startRun, stopRun } from "./run/manager";
|
||||
import { registerOverlayIpc } from "./overlay";
|
||||
import { fixtureUrl, startFixtureServer, stopFixtureServer } from "./fixture/server";
|
||||
@@ -24,6 +24,31 @@ import { logMain } from "./logger";
|
||||
// 子流程仓库在宿主(flows.ts),包内能力经 host-bridge 取用(阶段 2 正式化 HostBridge)
|
||||
setSubflowSource({ listFlows: async () => listFlows(), getFlow: async (id) => getFlow(id) });
|
||||
|
||||
// 宿主能力桥(决策点 4 最小面):人机交互窗口工厂 / DPI 坐标换算 / AI 配置读取
|
||||
setHostBridge({
|
||||
createFormWindow: ({ title }) => {
|
||||
const win = new BrowserWindow({
|
||||
width: 480, height: 0, useContentSize: true, autoHideMenuBar: true,
|
||||
title, alwaysOnTop: true,
|
||||
webPreferences: { contextIsolation: true, nodeIntegration: false, sandbox: true }
|
||||
});
|
||||
const dialogWindow: HostDialogWindow = {
|
||||
isDestroyed: () => win.isDestroyed(),
|
||||
destroy: () => { if (!win.isDestroyed()) win.destroy(); },
|
||||
loadURL: (url) => win.loadURL(url),
|
||||
on: (event, listener) => { win.on(event as "closed", listener); },
|
||||
executeJavaScript: (script) => win.webContents.executeJavaScript(script, true)
|
||||
};
|
||||
return dialogWindow;
|
||||
},
|
||||
dipToScreenPoint: (point) => screen.dipToScreenPoint(point),
|
||||
screenToDipPoint: (point) => screen.screenToDipPoint(point),
|
||||
loadAiConfig: () => {
|
||||
const ai = loadSettings().aiConfig;
|
||||
return { baseUrl: ai.baseUrl ?? "", apiKey: ai.apiKey ?? "", model: ai.model ?? "", visionModel: ai.visionModel ?? "" };
|
||||
}
|
||||
});
|
||||
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
|
||||
if (process.env.RPA_ENABLE_GPU !== "1") app.disableHardwareAcceleration();
|
||||
@@ -117,7 +142,7 @@ function registerIpc(): void {
|
||||
});
|
||||
type BrowserPickOptions = {
|
||||
url?: string;
|
||||
browser?: import("./browser/external").ExternalBrowserOptions;
|
||||
browser?: import("@rpa/core").ExternalBrowserOptions;
|
||||
};
|
||||
|
||||
ipcMain.handle("browser:pick-element", async (_event, options: BrowserPickOptions = {}) => {
|
||||
|
||||
Reference in new issue
Block a user