fix: 修复质量检查发现的选择器与资源问题
修复浏览器通配符过滤和 ARIA 选择器转义,收敛表单窗口生命周期,释放邮件连接,清理日志复制定时器,并校准 Word COM 测试超时。
这个提交包含在:
1 父节点
745da55e4e
当前提交
cc28d49ab5
7 个文件已更改
+70
-43
没有与搜索条件相匹配的文件
+11
-11
@@ -1,7 +1,7 @@
|
||||
import { execFile } from "node:child_process";
|
||||
import { promisify } from "node:util";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
|
||||
import path from "node:path";
|
||||
import { app, BrowserWindow, screen } from "electron";
|
||||
import { RuntimeError } from "./engine/types";
|
||||
@@ -31,7 +31,7 @@ export async function pickDesktopElement(): Promise<DesktopPickResult> {
|
||||
const appWindows = BrowserWindow.getAllWindows().filter(w => !w.isDestroyed() && w.isVisible());
|
||||
for (const w of appWindows) w.minimize();
|
||||
const { stdout } = await run("powershell.exe", ["-NoProfile", "-STA", "-ExecutionPolicy", "Bypass", "-File", pickerScriptPath()], { timeout: 180000, windowsHide: false, maxBuffer: 4 * 1024 * 1024 });
|
||||
const jsonLine = stdout.trim().split(/\\r?\\n/).reverse().find(l => l.trim().startsWith("{"));
|
||||
const jsonLine = stdout.trim().split(/\r?\n/).reverse().find(l => l.trim().startsWith("{"));
|
||||
if (!jsonLine) throw new RuntimeError("picker_failed", "拾取未返回结果");
|
||||
const parsed = JSON.parse(jsonLine) as Omit<DesktopPickResult, "selector">;
|
||||
if (parsed.cancelled) return { ...parsed, selector: "" };
|
||||
@@ -45,7 +45,7 @@ export async function pickDesktopElement(): Promise<DesktopPickResult> {
|
||||
|
||||
export async function listVisibleWindows(): Promise<Array<{ title: string; process: string }>> {
|
||||
const { stdout } = await run("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", pickerScriptPath(), "-Mode", "windows"], { timeout: 30000, windowsHide: true, maxBuffer: 4 * 1024 * 1024 });
|
||||
const jsonLine = stdout.trim().split(/\\r?\\n/).reverse().find(l => l.trim().startsWith("["));
|
||||
const jsonLine = stdout.trim().split(/\r?\n/).reverse().find(l => l.trim().startsWith("["));
|
||||
if (!jsonLine) return [];
|
||||
return JSON.parse(jsonLine) as Array<{ title: string; process: string }>;
|
||||
}
|
||||
@@ -93,17 +93,17 @@ export async function pickScreenRegion(): Promise<{ x: number; y: number; width:
|
||||
win.destroy();
|
||||
if (!region) throw new RuntimeError("pick_cancelled", "未完成框选");
|
||||
await new Promise(r => setTimeout(r, 300));
|
||||
const outDir = "D:/RPA/test-output";
|
||||
const outDir = path.join(app.getPath("userData"), "region-picks");
|
||||
fs.mkdirSync(outDir, { recursive: true });
|
||||
const imagePath = outDir + "/pick-region-" + Date.now() + ".png";
|
||||
const imagePath = path.join(outDir, `pick-region-${Date.now()}.png`);
|
||||
const psScript = [
|
||||
"Add-Type -AssemblyName System.Drawing | Out-Null;",
|
||||
" = New-Object System.Drawing.Bitmap " + region.width + ", " + region.height + ";",
|
||||
" = [System.Drawing.Graphics]::FromImage();",
|
||||
".CopyFromScreen(" + region.x + ", " + region.y + ", 0, 0, .Size);",
|
||||
".Dispose();",
|
||||
".Save(" + JSON.stringify(imagePath) + ");",
|
||||
".Dispose();",
|
||||
"$bitmap = New-Object System.Drawing.Bitmap " + region.width + ", " + region.height + ";",
|
||||
"$graphics = [System.Drawing.Graphics]::FromImage();",
|
||||
"$graphics.CopyFromScreen(" + region.x + ", " + region.y + ", 0, 0, $bitmap.Size);",
|
||||
"$graphics.Dispose();",
|
||||
"$bitmap.Save(" + JSON.stringify(imagePath) + ");",
|
||||
"$bitmap.Dispose();",
|
||||
"Write-Output ok"
|
||||
].join("");
|
||||
await run("powershell.exe", ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", psScript], { timeout: 30000, windowsHide: true });
|
||||
|
||||
在新工单中引用
屏蔽一个用户