隐藏文字编辑实现细节并接通侧栏快捷按钮
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-02-07 21:56:54 +08:00
parent 927514ad6b
commit a8b078b8ae
2 changed files with 31 additions and 4 deletions

View File

@ -293,14 +293,23 @@ export default function CanvasEditorPage({ params }: PageProps) {
});
};
// 处理图片操作(占位函数,后续实现具体逻辑)
// 处理图片操作(通过事件分发到选中图片节点执行)
const handleAction = (action: string) => {
if (!selectedImageNode) {
toast.error("请先选择一张图片");
return;
}
toast.info(`${action} 功能开发中...`);
// TODO: 实现具体的图片处理逻辑
if (typeof window !== "undefined") {
window.dispatchEvent(
new CustomEvent("canvas:image-action", {
detail: {
nodeId: selectedImageNode.id,
action,
},
}),
);
}
};
// AI 生成图片

View File

@ -742,6 +742,24 @@ export function ImageNode({ node, isSelected }: ImageNodeProps) {
}
};
useEffect(() => {
if (typeof window === "undefined") return;
const onExternalAction = (event: Event) => {
const customEvent = event as CustomEvent<{ nodeId?: string; action?: string }>;
const targetNodeId = customEvent.detail?.nodeId;
const action = customEvent.detail?.action;
if (!targetNodeId || !action || targetNodeId !== node.id) return;
void handleAction(action);
};
window.addEventListener("canvas:image-action", onExternalAction as EventListener);
return () => {
window.removeEventListener("canvas:image-action", onExternalAction as EventListener);
};
}, [handleAction, node.id]);
// 角度编辑完成回调
const handleAngleEditComplete = (resultUrl: string) => {
// 创建新的图片节点显示结果
@ -1437,7 +1455,7 @@ export function ImageNode({ node, isSelected }: ImageNodeProps) {
<div className="px-4 py-3 space-y-3 max-h-[360px] overflow-y-auto">
<p className="text-xs text-muted-foreground">
自动调用 Qwen3VL 识别图片文字。确认后将调用火山生图模型替换文字,并尽可能保持原字体形状。
识别图片文字后可逐条修改或删除,应用后会在保持画面风格的前提下完成文字更新。
</p>
{isDetectingText && (