From ab219116960863a922a1246a7e431edff19ebe72 Mon Sep 17 00:00:00 2001 From: fengxiangdebaozi <10845145+fengxiangdebaozi@user.noreply.gitee.com> Date: Tue, 16 Jun 2026 19:41:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(ai-writing):=20=E8=BF=9B=E5=85=A5=E5=86=99?= =?UTF-8?q?=E4=BD=9C=E5=90=8E=E8=87=AA=E5=8A=A8=E6=94=B6=E8=B5=B7=E7=A0=94?= =?UTF-8?q?=E7=A9=B6=E6=A8=A1=E6=9D=BF=E4=BE=A7=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 把侧栏+内容区抽成 Provider 内组件 AIWritingBody,读 useAIWriting 状态: status==='idle' && 非历史模式才显示研究模板侧栏;开始写作/查看历史后收起,写作区铺满。 Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/open-canvas/pages/AIWritingPage.tsx | 141 ++++++++++-------- 1 file changed, 81 insertions(+), 60 deletions(-) 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 })} - /> -
- )} -
-
- )} -
-
+