feat: 增加轨迹

This commit is contained in:
2026-09-17 09:09:06 +08:00
parent b9fd289caf
commit e74cf6d28b
42 changed files with 4010 additions and 570 deletions

View File

@@ -1,9 +1,9 @@
import "./styles/index.css";
import { useEffect } from "react";
import { X } from "lucide-react";
import { DirectorDeskShell } from "./app/layout/DirectorDeskShell";
import { DirectorCanvas } from "./editor/canvas/DirectorCanvas";
import { initDirectorDeskHostBridge } from "./editor/io/hostBridge";
import { addKeyframeAtPlayhead } from "./editor/runtime/keyframeCommand";
import { useDirectorStore } from "./editor/store/directorStore";
function isEditableShortcutTarget(target: EventTarget | null) {
@@ -21,13 +21,20 @@ export default function App() {
window.parent?.postMessage({ type: "storyai:director-desk-ready" }, window.location.origin);
}, []);
function handleClose() {
window.parent?.postMessage({ type: "storyai:director-desk-close" }, window.location.origin);
}
useEffect(() => {
function handleKeyDown(event: KeyboardEvent) {
if (event.defaultPrevented || isEditableShortcutTarget(event.target)) return;
// 录制时(悬浮时间轴 = 录制面板打开)按 K:在当前时间指针处打一个关键帧。
// 只在录制面板打开时生效,避免平时打字/其它操作误触;长按不重复打点。
if (event.key.toLowerCase() === "k" && !event.metaKey && !event.ctrlKey && !event.altKey) {
if (event.repeat || !useDirectorStore.getState().timelineVisible) return;
if (addKeyframeAtPlayhead()) {
event.preventDefault();
}
return;
}
if (!event.metaKey && !event.ctrlKey) return;
const key = event.key.toLowerCase();
@@ -82,17 +89,6 @@ export default function App() {
</button>
</div>
</div>
<div className="top-bar-actions">
<button
className="top-bar-action-button"
type="button"
aria-label="关闭"
title="关闭"
onClick={handleClose}
>
<X aria-hidden="true" size={16} strokeWidth={1.8} />
</button>
</div>
</header>
<DirectorDeskShell>
<DirectorCanvas />