diff --git a/frontend-web/src/open-canvas/pages/AIWritingPage.tsx b/frontend-web/src/open-canvas/pages/AIWritingPage.tsx index 8df94935..c403bb45 100644 --- a/frontend-web/src/open-canvas/pages/AIWritingPage.tsx +++ b/frontend-web/src/open-canvas/pages/AIWritingPage.tsx @@ -217,6 +217,81 @@ function AIWritingLayout({ hideAdvancedFields, initialNotebookId, initialDocumen ); } +/** + * 写作页主体(侧栏 + 内容区)。放在 Provider 内部,以便读 useAIWriting 状态: + * 进入写作(status !== idle 或查看历史)后自动收起左侧研究模板栏,让写作区更宽。 + */ +function AIWritingBody({ hideAdvancedFields, initialNotebookId, initialDocumentIds, studioToken }: { hideAdvancedFields: boolean } & NotebookProps) { + const { state } = useAIWriting(); + const { isHistoryMode } = useAIWritingHistory(); + + // 需求 0616 #5:左栏点「笔记本 / 所有空间」→ 在右侧内嵌打开对应页,替换右侧内容 + // (写作布局不卸载,仅 display:none 隐藏,避免 WritingSetupChat 重挂丢线程)。 + const [rightView, setRightView] = useState(null); + const overlayActive = rightView != null; + const viewingNotebookId = rightView?.kind === 'notebook' ? rightView.id : null; + + // 进入写作(开始生成 / 查看历史)后收起研究模板侧栏;嵌入态(studioToken)始终不展示。 + const showSidebar = !studioToken && state.status === 'idle' && !isHistoryMode; + + return ( +
+ {/* 需求 0616 #5:课题研究左栏(研究模板 + 笔记本)。进入写作后收起。 */} + {showSidebar && ( + setRightView({ kind: 'notebook', id })} + onOpenAllSpaces={() => setRightView({ kind: 'allSpaces' })} + /> + )} + {/* 右侧:写作布局常驻(仅 display:none 隐藏,避免 WritingSetupChat 重挂丢线程), + 查看笔记本 / 所有空间时在其上叠加内嵌页。 */} +
+
+ +
+ {overlayActive && ( +
+
+ + {rightView.kind === 'notebook' && ( + + )} +
+
+ {rightView.kind === 'notebook' ? ( + // 笔记本详情页内部用 ChatBox(useArtifacts) → 需 ChatRuntime 提供 Provider。 + + + + ) : ( +
+ setRightView({ kind: 'notebook', id })} + /> +
+ )} +
+
+ )} +
+
+ ); +} + export default function AIWritingPage({ hideAdvancedFields = false, initialNotebookId, @@ -228,12 +303,6 @@ export default function AIWritingPage({ initialDocumentIds?: number[]; studioToken?: string; } = {}) { - // 需求 0616 #5:左栏点「笔记本 / 所有空间」→ 在右侧内嵌打开对应页,替换右侧内容 - // (写作布局不卸载,仅 display:none 隐藏,避免 WritingSetupChat 重挂丢线程)。 - const [rightView, setRightView] = useState(null); - const overlayActive = rightView != null; - const viewingNotebookId = rightView?.kind === 'notebook' ? rightView.id : null; - return ( @@ -247,60 +316,12 @@ export default function AIWritingPage({ >
-
- {/* 需求 0616 #5:课题研究左栏(研究模板 + 笔记本)。studio 嵌入态(studioToken)隐藏。 */} - {!studioToken && ( - setRightView({ kind: 'notebook', id })} - onOpenAllSpaces={() => setRightView({ kind: 'allSpaces' })} - /> - )} - {/* 右侧:写作布局常驻(仅 display:none 隐藏,避免 WritingSetupChat 重挂丢线程), - 查看笔记本 / 所有空间时在其上叠加内嵌页。 */} -
-
- -
- {overlayActive && ( -
-
- - {rightView.kind === 'notebook' && ( - - )} -
-
- {rightView.kind === 'notebook' ? ( - // 笔记本详情页内部用 ChatBox(useArtifacts) → 需 ChatRuntime 提供 Provider。 - - - - ) : ( -
- setRightView({ kind: 'notebook', id })} - /> -
- )} -
-
- )} -
-
+