bug修复
This commit is contained in:
1 parent
1ece2c5a4f
commit
44cb118f95
5 files changed
+333
-244
No files matched your search
@@ -28,7 +28,7 @@ import { uuid } from '@/core/utils/uuid';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import { useArticleTypes } from '../../hooks/useArticleTypes';
|
||||
import { useWritingForm } from '../../contexts/WritingFormContext';
|
||||
import { useWritingFormOptional } from '../../contexts/WritingFormContext';
|
||||
import { WritingWelcome } from './WritingWelcome';
|
||||
|
||||
/**
|
||||
@@ -42,13 +42,25 @@ import { WritingWelcome } from './WritingWelcome';
|
||||
*
|
||||
* 这条线程只负责「帮用户把表单聊清」,与真正写作的 ai_writing graph 完全解耦。
|
||||
*/
|
||||
export function WritingSetupChat() {
|
||||
export function WritingSetupChat({
|
||||
onApprove: onApproveProp,
|
||||
title = '写作助手',
|
||||
hint = '描述你想写什么,我来帮你填好右侧配置',
|
||||
}: {
|
||||
/** 审批卡「应用」回调;缺省回填写作表单(需 WritingFormProvider)。传入则脱离表单上下文,
|
||||
* 用于复用到「新建研究模板」等场景,把建议字段写进调用方的表单。 */
|
||||
onApprove?: (payload: SetupWritingApprovalPayload) => void;
|
||||
title?: string;
|
||||
hint?: string;
|
||||
} = {}) {
|
||||
const threadId = useMemo(() => uuid(), []);
|
||||
const [threadPrepared, setThreadPrepared] = useState(false);
|
||||
const [chatModel, setChatModel] = useState('');
|
||||
const { models, isLoading: modelsLoading } = useModels();
|
||||
const { articleTypes } = useArticleTypes();
|
||||
const { applyProposal } = useWritingForm();
|
||||
// 缺省回填写作表单;onApprove 传入时脱离 WritingFormProvider(如模板创建页)。
|
||||
const formCtx = useWritingFormOptional();
|
||||
const applyProposal = onApproveProp ?? formCtx?.applyProposal;
|
||||
|
||||
// 首个模型可用时默认选中
|
||||
useEffect(() => {
|
||||
@@ -98,8 +110,8 @@ export function WritingSetupChat() {
|
||||
|
||||
const handleApprove = useCallback(
|
||||
async (payload: SetupWritingApprovalPayload) => {
|
||||
applyProposal(payload);
|
||||
toast.success('已应用到左侧表单,可继续编辑或开始写作');
|
||||
applyProposal?.(payload);
|
||||
toast.success('已应用到表单,可继续编辑');
|
||||
},
|
||||
[applyProposal],
|
||||
);
|
||||
@@ -119,8 +131,8 @@ export function WritingSetupChat() {
|
||||
{!showWelcome && (
|
||||
<header className="flex shrink-0 items-center gap-2 border-b px-4 py-3">
|
||||
<Sparkles className="size-4 text-primary" />
|
||||
<h2 className="text-sm font-semibold">写作助手</h2>
|
||||
<span className="text-muted-foreground text-xs">描述你想写什么,我来帮你填好右侧配置</span>
|
||||
<h2 className="text-sm font-semibold">{title}</h2>
|
||||
<span className="text-muted-foreground text-xs">{hint}</span>
|
||||
</header>
|
||||
)}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ export function WritingWelcome() {
|
||||
<div className="flex flex-1 flex-col justify-center gap-6">
|
||||
<div>
|
||||
<h2 className="text-2xl font-bold leading-snug tracking-tight text-slate-800 dark:text-white">
|
||||
欢迎使用「妙笔 AI」智力打字协作工坊
|
||||
欢迎使用「ai写作」智力打字协作工坊
|
||||
</h2>
|
||||
<p className="mt-2 max-w-xl text-sm leading-relaxed text-slate-500 dark:text-white/60">
|
||||
这是一个专业的自动化写作系统。你只需在下方对话框中
|
||||
|
||||
Reference in new issue
Block a user