JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix:文件上传错误提示3s自动消失
xiaoyao42b911067f3152
diff --git a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/ChatPanel.css b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/ChatPanel.cssindex ac209b4dd6..5f5ed6a110 100644--- a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/ChatPanel.css+++ b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/ChatPanel.css@@ -2593,21 +2593,17 @@ overflow: hidden;.chat-input-local-alerts {position: absolute;+ top: 24px;left: 50%;- bottom: calc(100% + 16px);- z-index: 30;+ z-index: 40;display: flex;flex-direction: column;gap: 10px;- width: min(620px, calc(100vw - 64px));+ width: min(620px, calc(100% - 32px));transform: translateX(-50%);pointer-events: none;}-.chat-welcome__composer .chat-input-local-alerts {- bottom: calc(100% + 104px);-}-.chat-input-local-alert {display: grid;grid-template-columns: 18px minmax(0, 1fr) 22px;diff --git a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsxindex 7bb1bf2255..34f612277d 100644--- a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx@@ -126,6 +126,7 @@ interface InputAreaProps {const ACCEPTED_IMAGE_TYPES = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/gif']);const MAX_IMAGE_BYTES = 10 * 1024 * 1024;const MAX_IMAGE_COUNT = 20;+const ATTACHMENT_ALERT_DURATION_MS = 3000;type AttachmentStatus = 'uploading' | 'ready' | 'error';@@ -218,6 +219,11 @@ function getImageValidationError(file: File): string | null {return null;}+function clearAttachmentAlertTimers(timers: Map<string, number>): void {+ timers.forEach((timeoutId) => window.clearTimeout(timeoutId));+ timers.clear();+}+function readImageFile(file: File): Promise<Pick<AttachmentDraft, 'base64Data' | 'previewUrl'> | null> {if (getImageValidationError(file)) {return Promise.resolve(null);@@ -257,6 +263,7 @@ export function InputArea({const [isModeMenuOpen, setIsModeMenuOpen] = useState(false);const [attachments, setAttachments] = useState<AttachmentDraft[]>([]);const [attachmentAlerts, setAttachmentAlerts] = useState<AttachmentAlert[]>([]);+ const attachmentAlertTimersRef = useRef<Map<string, number>>(new Map());const [attachmentMenuId, setAttachmentMenuId] = useState<string | null>(null);const fileInputRef = useRef<HTMLInputElement>(null);const [workMenuOpen, setWorkMenuOpen] = useState<'project' | null>(null);@@ -491,15 +498,39 @@ export function InputArea({if (attachmentMenuTimerRef.current) {clearTimeout(attachmentMenuTimerRef.current);}+ clearAttachmentAlertTimers(attachmentAlertTimersRef.current);};}, []);const pushAttachmentAlert = useCallback((message: string) => {const id = `${Date.now()}-${Math.random().toString(36).slice(2)}`;- setAttachmentAlerts((prev) => [...prev, { id, message }].slice(-3));+ const timers = attachmentAlertTimersRef.current;+ while (timers.size >= 3) {+ const oldestId = timers.keys().next().value;+ if (oldestId === undefined) break;+ const oldestTimeoutId = timers.get(oldestId);+ if (oldestTimeoutId !== undefined) {+ window.clearTimeout(oldestTimeoutId);+ }+ timers.delete(oldestId);+ }+ const timeoutId = window.setTimeout(() => {+ timers.delete(id);+ setAttachmentAlerts((prev) => prev.filter((item) => item.id !== id));+ }, ATTACHMENT_ALERT_DURATION_MS);+ timers.set(id, timeoutId);+ setAttachmentAlerts((prev) => [+ ...prev.filter((item) => timers.has(item.id)),+ { id, message },+ ].slice(-3));}, []);const dismissAttachmentAlert = useCallback((id: string) => {+ const timeoutId = attachmentAlertTimersRef.current.get(id);+ if (timeoutId !== undefined) {+ window.clearTimeout(timeoutId);+ attachmentAlertTimersRef.current.delete(id);+ }setAttachmentAlerts((prev) => prev.filter((item) => item.id !== id));}, []);@@ -518,6 +549,7 @@ export function InputArea({setAttachments([]);setAttachmentAlerts([]);setAttachmentMenuId(null);+ clearAttachmentAlertTimers(attachmentAlertTimersRef.current);}, []);const stopAttachmentMenuTimer = useCallback(() => {@@ -1383,28 +1415,29 @@ export function InputArea({const currentMode = AGENT_MODE_OPTIONS.find((item) => item.value === mode) ?? AGENT_MODE_OPTIONS[0];const evolutionLabel = getEvolutionPillLabel(mode, evolutionStatus, t);+ const attachmentAlertPortalTarget = inputRef.current?.closest<HTMLElement>('.chat-panel-shell');return (<>+ {attachmentAlerts.length > 0 && attachmentAlertPortalTarget && createPortal(+ <div className="chat-input-local-alerts" role="status" aria-live="polite">+ {attachmentAlerts.map((alert) => (+ <div className="chat-input-local-alert" key={alert.id}>+ <CircleX size={16} strokeWidth={2.2} aria-hidden="true" />+ <span>{alert.message}</span>+ <button+ type="button"+ onClick={() => dismissAttachmentAlert(alert.id)}+ aria-label={t('common.close')}+ >+ <X size={15} strokeWidth={2} aria-hidden="true" />+ </button>+ </div>+ ))}+ </div>,+ attachmentAlertPortalTarget,+ )}<div className="chat-input-frame">- {attachmentAlerts.length > 0 && (- <div className="chat-input-local-alerts" role="status" aria-live="polite">- {attachmentAlerts.map((alert) => (- <div className="chat-input-local-alert" key={alert.id}>- <CircleX size={16} strokeWidth={2.2} />- <span>{alert.message}</span>- <button- type="button"- onClick={() => dismissAttachmentAlert(alert.id)}- aria-label="关闭提示"- >- <X size={15} strokeWidth={2} />- </button>- </div>- ))}- </div>- )}-<divclassName={cx('chat-input-container',diff --git a/jiuwenswarm/channels/web/frontend/src/index.css b/jiuwenswarm/channels/web/frontend/src/index.cssindex 35cde244d4..d072550b41 100644--- a/jiuwenswarm/channels/web/frontend/src/index.css+++ b/jiuwenswarm/channels/web/frontend/src/index.css@@ -957,6 +957,7 @@ select {--chat-page-max-width: 920px;--chat-page-gutter: clamp(12px, 3vw, 40px);--chat-content-width: min(var(--chat-page-max-width), calc(100% - (var(--chat-page-gutter) * 2)));+ position: relative;}.chat-scroll {