feat(editor): настройки экрана презентации при запуске сессии
Выбор монитора и полноэкранного режима в настройках; при «Запустить» окно презентации открывается на выбранном дисплее автоматически. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import fs from 'node:fs';
|
||||
|
||||
import type { PresentationSettings } from '../../shared/types/presentationSettings';
|
||||
import { DEFAULT_PRESENTATION_SETTINGS } from '../../shared/types/presentationSettings';
|
||||
import { preferencesPath } from '../license/paths';
|
||||
|
||||
type StoredPreferences = {
|
||||
eulaAcceptedVersion?: number;
|
||||
presentation?: Partial<PresentationSettings>;
|
||||
};
|
||||
|
||||
function readAll(userData: string): StoredPreferences {
|
||||
try {
|
||||
const raw = fs.readFileSync(preferencesPath(userData), 'utf8');
|
||||
return JSON.parse(raw) as StoredPreferences;
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function writeAll(userData: string, prefs: StoredPreferences): void {
|
||||
fs.mkdirSync(userData, { recursive: true });
|
||||
fs.writeFileSync(preferencesPath(userData), `${JSON.stringify(prefs, null, 2)}\n`, 'utf8');
|
||||
}
|
||||
|
||||
export function readPresentationSettings(userData: string): PresentationSettings {
|
||||
const prefs = readAll(userData);
|
||||
return {
|
||||
...DEFAULT_PRESENTATION_SETTINGS,
|
||||
...prefs.presentation,
|
||||
};
|
||||
}
|
||||
|
||||
export function writePresentationSettings(
|
||||
userData: string,
|
||||
patch: Partial<PresentationSettings>,
|
||||
): PresentationSettings {
|
||||
const prefs = readAll(userData);
|
||||
const next: PresentationSettings = {
|
||||
...DEFAULT_PRESENTATION_SETTINGS,
|
||||
...prefs.presentation,
|
||||
...patch,
|
||||
};
|
||||
prefs.presentation = next;
|
||||
writeAll(userData, prefs);
|
||||
return next;
|
||||
}
|
||||
Reference in New Issue
Block a user