746b862cb9
Выбор монитора и полноэкранного режима в настройках; при «Запустить» окно презентации открывается на выбранном дисплее автоматически. Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
853 B
TypeScript
28 lines
853 B
TypeScript
import { screen, type Display } from 'electron';
|
|
|
|
import type { DisplayInfo } from '../../shared/types/presentationSettings';
|
|
|
|
export function listDisplayInfos(): DisplayInfo[] {
|
|
const primaryId = screen.getPrimaryDisplay().id;
|
|
return screen.getAllDisplays().map((d) => displayToInfo(d, d.id === primaryId));
|
|
}
|
|
|
|
function displayToInfo(display: Display, isPrimary: boolean): DisplayInfo {
|
|
const label = display.label?.trim() || `Display ${String(display.id)}`;
|
|
return {
|
|
id: display.id,
|
|
label,
|
|
width: display.bounds.width,
|
|
height: display.bounds.height,
|
|
isPrimary,
|
|
};
|
|
}
|
|
|
|
export function resolvePresentationDisplay(displayId: number | null): Display {
|
|
if (displayId != null) {
|
|
const found = screen.getAllDisplays().find((d) => d.id === displayId);
|
|
if (found) return found;
|
|
}
|
|
return screen.getPrimaryDisplay();
|
|
}
|