Files
2026-09-30 08:53:48 +08:00

51 lines
1.7 KiB
TypeScript

import React, { useEffect, useState } from 'react';
import { ipcChannels, type SessionState } from '../../shared/ipc/contracts';
import { getDndApi } from '../shared/dndApi';
import { PresentationView } from '../shared/PresentationView';
import styles from './PresentationApp.module.css';
export function PresentationApp() {
const [session, setSession] = useState<SessionState | null>(null);
const api = getDndApi();
useEffect(() => {
void api.invoke(ipcChannels.project.get, {}).then((res) => {
setSession({
project: res.project,
currentSceneId: res.project?.currentSceneId ?? null,
});
});
return api.on(ipcChannels.session.stateChanged, ({ state }) => setSession(state));
}, [api]);
useEffect(() => {
const onKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
e.preventDefault();
void api.invoke(ipcChannels.windows.requestCloseMultiWindowConfirm, {});
return;
}
if (e.altKey && (e.key === 'Enter' || e.code === 'Enter' || e.code === 'NumpadEnter')) {
e.preventDefault();
void api.invoke(ipcChannels.windows.togglePresentationFullscreen, {});
}
};
window.addEventListener('keydown', onKeyDown);
return () => window.removeEventListener('keydown', onKeyDown);
}, [api]);
return (
<div
className={styles.root}
onDoubleClick={() => void api.invoke(ipcChannels.windows.togglePresentationFullscreen, {})}
>
{/* Презентация только для просмотра: никаких кликов/drag по сцене и оверлеям. */}
<div className={styles.viewPassthrough}>
<PresentationView session={session} showTitle={false} />
</div>
</div>
);
}