代码修改

This commit is contained in:
董宏凯 committed 2026-07-23 14:29:12 +08:00
1 parent 56740ecf56
commit b60d9ed09e
10 files changed
+691 -96

No files matched your search

@@ -65,6 +65,35 @@ import type {
} from "@/roundtable-planning/api/multi-agent";
import type { IntentSummary } from "@/roundtable-planning/api/intent";
/**
* Step 1 输入区的受控数据与行为契约。
*
* 默认输入区继续由 Step1Panel 渲染;嵌入式页面可通过 `inputArea` 复用相同的
* 发送、附件和阶段按钮行为,同时拥有完全独立的 DOM 与视觉样式。
*/
export interface Step1InputAreaProps {
value: string;
onValueChange: (value: string) => void;
attachedFiles: File[];
onAddFiles: (files: File[]) => void;
onRemoveFile: (index: number) => void;
charactersLeft: number;
isSending: boolean;
canSend: boolean;
pendingClarification: boolean;
onSend: () => void;
onStop: () => void;
onFollowUp: () => void;
onSkip: () => void;
onEnterRoundtable: () => void;
enterButtonLabel: string;
intentReady: object | null;
footerAction?: React.ReactNode;
hideEnterRoundtable: boolean;
onManualSave: () => void;
onTriggerToast: (message: string) => void;
}
export interface Step1PanelProps {
// ─── State ────────────────────────────────────────────────────
/**
@@ -94,6 +123,11 @@ export interface Step1PanelProps {
footerAction?: React.ReactNode;
/** 已进入后续工作流时,隐藏默认的「进入研讨」动作。 */
hideEnterRoundtable?: boolean;
/**
* 仅替换输入区的渲染插槽。消息列表、意图状态及附件状态仍由 Step1Panel
* 统一管理,因此岗位会商定制样式时不会分叉或复制 Step 1 的业务逻辑。
*/
inputArea?: (props: Step1InputAreaProps) => React.ReactNode;
onManualSave: () => void;
onTriggerToast: (msg: string) => void;
submitIntentClarifications: (
@@ -122,6 +156,7 @@ export function Step1Panel(props: Step1PanelProps) {
enterButtonLabel = "进入多智能体研讨 >",
footerAction,
hideEnterRoundtable = false,
inputArea,
onManualSave,
onTriggerToast,
submitIntentClarifications,
@@ -144,8 +179,7 @@ export function Step1Panel(props: Step1PanelProps) {
const charactersLeft = inputText.length;
const handlePickFiles = (e: React.ChangeEvent<HTMLInputElement>) => {
const picked = Array.from(e.target.files ?? []);
const addAttachedFiles = (picked: File[]) => {
if (picked.length > 0) {
// 去重(按 名称+大小),追加到已选列表。
setAttachedFiles((prev) => {
@@ -153,6 +187,10 @@ export function Step1Panel(props: Step1PanelProps) {
return [...prev, ...picked.filter((f) => !seen.has(`${f.name}:${f.size}`))];
});
}
};
const handlePickFiles = (e: React.ChangeEvent<HTMLInputElement>) => {
addAttachedFiles(Array.from(e.target.files ?? []));
// 清空 input 值,允许再次选同名文件。
e.target.value = "";
};
@@ -216,6 +254,30 @@ export function Step1Panel(props: Step1PanelProps) {
</div>
{/* Bottom input area */}
{inputArea ? (
inputArea({
value: inputText,
onValueChange: setInputText,
attachedFiles,
onAddFiles: addAttachedFiles,
onRemoveFile: removeAttachedFile,
charactersLeft,
isSending: isIntentSending,
canSend: !isIntentSending && Boolean(intentThreadId),
pendingClarification: Boolean(pendingIntentClarificationMsgId),
onSend: handleSend,
onStop: onStopIntent,
onFollowUp,
onSkip: onSkipQuestion,
onEnterRoundtable,
enterButtonLabel,
intentReady,
footerAction,
hideEnterRoundtable,
onManualSave,
onTriggerToast,
})
) : (
<div className="shrink-0 p-4 border-t border-slate-100 bg-[#fcfcfd]">
<div className="relative border border-slate-200 focus-within:border-primary focus-within:ring-2 focus-within:ring-[var(--brand-200)]/50 transition-all rounded-xl overflow-hidden bg-white px-3 py-2.5">
{/* 已选附件预览(点发送时随消息上传) */}
@@ -366,6 +428,7 @@ export function Step1Panel(props: Step1PanelProps) {
</button>
</div>
</div>
)}
</div>
);
}