diff --git a/frontend-web/src/open-canvas/components/ai-writing/AIWritingForm.tsx b/frontend-web/src/open-canvas/components/ai-writing/AIWritingForm.tsx index 53237d53..91bee967 100644 --- a/frontend-web/src/open-canvas/components/ai-writing/AIWritingForm.tsx +++ b/frontend-web/src/open-canvas/components/ai-writing/AIWritingForm.tsx @@ -97,13 +97,10 @@ export function AIWritingForm({ [models, modelName], ); - // initialNotebookId 存在时自动切换素材来源为「我的笔记」 - useEffect(() => { - if (initialNotebookId != null) { - setMaterialSource('notebook'); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + // studioToken / initialNotebookId 存在时强制使用「我的笔记」 + const effectiveMaterialSource: MaterialSource = studioToken ?? initialNotebookId != null + ? 'notebook' + : materialSource; // 初始化时加载文章类型 useEffect(() => { @@ -172,11 +169,11 @@ export function AIWritingForm({ wordCountTarget: wordCount, keywordCount: DEFAULT_KEYWORD_COUNT, writingMode: hideAdvancedFields ? 'loose' : strictMode ? 'strict' : 'loose', - materialSource, + materialSource: effectiveMaterialSource, modelName: selectedModel?.name || modelName || undefined, // 只有选了"我的笔记"才传笔记参数 - noteSearchSpaceId: materialSource === 'notebook' ? (selectedNotebookId ?? undefined) : undefined, - noteSourceIds: materialSource === 'notebook' && selectedNotebookId != null ? selectedDocumentIds : undefined, + noteSearchSpaceId: effectiveMaterialSource === 'notebook' ? (selectedNotebookId ?? undefined) : undefined, + noteSourceIds: effectiveMaterialSource === 'notebook' && selectedNotebookId != null ? selectedDocumentIds : undefined, }); } @@ -284,33 +281,26 @@ export function AIWritingForm({
- {/* studioToken 模式:素材来源已锁定为「我的笔记」,不可切换 */} - {studioToken ? ( -
- 我的笔记 -
- ) : ( - - )} + {/* 选了"我的笔记"才展示笔记本 / 文档选择器 */} - {materialSource === 'notebook' && ( + {effectiveMaterialSource === 'notebook' && (
{/* studioToken 模式:笔记本已锁定,不展示选择器 */} {!studioToken && (