fix(frontend): 禁止 disabled 状态下发送消息

- 恢复 PromptInputSubmit 的 disabled 绑定,避免按钮可点击提交
- 在 PromptInput handleSubmit 增加 disabled 兜底拦截
- 确保点击与回车两种路径在 disabled=true 时都不会发送
This commit is contained in:
肖应宇 2026-04-02 16:25:24 +08:00
parent b11819d765
commit 9710bd904c
4 changed files with 11 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -8,8 +8,8 @@ import { I18nProvider } from "@/core/i18n/context";
import { detectLocaleServer } from "@/core/i18n/server"; import { detectLocaleServer } from "@/core/i18n/server";
export const metadata: Metadata = { export const metadata: Metadata = {
title: "DeerFlow", title: "XClaw",
description: "A LangChain-based framework for building super agents.", description: "Desscriptions of XClawDesscriptions of XClawDesscriptions of XClaw",
}; };
export default async function RootLayout({ export default async function RootLayout({

View File

@ -752,6 +752,9 @@ export const PromptInput = ({
const handleSubmit: FormEventHandler<HTMLFormElement> = (event) => { const handleSubmit: FormEventHandler<HTMLFormElement> = (event) => {
event.preventDefault(); event.preventDefault();
if (disabled) {
return;
}
const form = event.currentTarget; const form = event.currentTarget;
const text = usingProvider const text = usingProvider
@ -1081,9 +1084,9 @@ export const PromptInputSubmit = ({
: false; : false;
// 正在 streaming 时不允许发送 // 正在 streaming 时不允许发送
// const isStreaming = status === "streaming" || status === "submitted"; const isStreaming = status === "streaming" || status === "submitted";
// const isDisabled = disabled || !hasContent || isStreaming; const isDisabled = disabled || !hasContent || isStreaming;
let Icon = <ArrowUpIcon className="size-4" />; let Icon = <ArrowUpIcon className="size-4" />;
@ -1109,15 +1112,15 @@ export const PromptInputSubmit = ({
// 被button{bgc:#fff}覆盖了,只能加"!" // 被button{bgc:#fff}覆盖了,只能加"!"
className={cn( className={cn(
"h-[40px] w-[140px] rounded-[10px] border-0 font-bold transition-all", "h-[40px] w-[140px] rounded-[10px] border-0 font-bold transition-all",
// isDisabled isDisabled
// ? "cursor-not-allowed !bg-gray-200 text-gray-400": ? "cursor-not-allowed !bg-gray-200 text-gray-400":
"!bg-[#F0E8FB] text-[#8E47F0] hover:!bg-[#8E47F0] hover:text-[#FFFFFF]", "!bg-[#F0E8FB] text-[#8E47F0] hover:!bg-[#8E47F0] hover:text-[#FFFFFF]",
className, className,
)} )}
size={size} size={size}
type="submit" type="submit"
variant={variant} variant={variant}
// disabled={isDisabled} disabled={isDisabled}
{...props} {...props}
> >
{/* {children ?? Icon} */} {/* {children ?? Icon} */}

View File

@ -515,7 +515,7 @@ export function ArtifactFilePreview({
if (language === "markdown") { if (language === "markdown") {
return ( return (
<div <div
className={cn("w-full mb-[207px] p-[20px]")} className={cn("w-full bg-white mb-[207px] p-[20px]")}
style={{ "--zoom-scale": zoomScale } as React.CSSProperties} style={{ "--zoom-scale": zoomScale } as React.CSSProperties}
> >
<Streamdown <Streamdown