Skip to content

Commit 66808c0

Browse files
committed
refactor(window-recognition): 阶段一接入评分组合入口(行为兼容)
1 parent 255ffcd commit 66808c0

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎client/electron/screenCaptureHandlers.ts‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type { ScreenCaptureOptions, ScreenshotFrameData } from './screenCapture.
1414
import { safeHandle, getMainWindowId } from './ipcUtils.js';
1515
import { logger } from './logger.js';
1616
import { scoreAndFilterWindows } from './windowScorer.js';
17+
import type { WindowSignalInput } from './windowRules.js';
1718
import { getCaptureRateScale, onPerformanceModeChange } from './performanceMode.js';
1819

1920
// ================================================================
@@ -64,6 +65,16 @@ function applyRateScale(options: ScreenCaptureOptions): ScreenCaptureOptions {
6465
return scaled;
6566
}
6667

68+
/**
69+
* 构建 source id → 评分信号的映射。
70+
* @ai-context: 阶段一为空映射(纯标题评分);阶段二接入 native 窗口枚举后填充
71+
* 进程名/几何/前台信号。信号源缺失时返回空 Map,评分自动降级。
72+
*/
73+
function buildSignalMap(sources: Electron.DesktopCapturerSource[]): Map<string, WindowSignalInput> {
74+
void sources;
75+
return new Map();
76+
}
77+
6778
/** 销毁旧实例并按其参数/推送目标重建采集(start 与性能模式重启共用) */
6879
function startCaptureWith(senderWin: BrowserWindow | null, options: ScreenCaptureOptions): void {
6980
if (activeCapture) {
@@ -193,8 +204,8 @@ export function registerScreenCaptureHandlers(): void {
193204
};
194205
});
195206

196-
// 智能评分、过滤与排序
197-
return scoreAndFilterWindows(rawWindows);
207+
// 智能评分、过滤与排序(阶段一:空信号映射,纯标题评分)
208+
return scoreAndFilterWindows(rawWindows, { signalsBySourceId: buildSignalMap(sources) });
198209
} catch (err) {
199210
logger.error('[IPC] screen_list_windows failed:', err);
200211
return [];
@@ -230,7 +241,7 @@ export function registerScreenCaptureHandlers(): void {
230241
return { id: src.id, title: src.name, thumbnail: thumb.toDataURL() };
231242
});
232243

233-
const scored = scoreAndFilterWindows(rawWindows);
244+
const scored = scoreAndFilterWindows(rawWindows, { signalsBySourceId: buildSignalMap(sources) });
234245

235246
// 推送到渲染进程
236247
const mainWindowId = getMainWindowId();

0 commit comments

Comments
 (0)