From 547f49a978cd6aaeac761b6fe1fb9630a4ea29fe Mon Sep 17 00:00:00 2001 From: jialin Date: Mon, 23 Jun 2025 16:23:19 +0800 Subject: [PATCH] fix: audio uploader has cache issue --- .../seal-table/components/header-prefix.tsx | 40 ++++--------------- src/components/upload-audio/index.tsx | 10 ++--- src/config/theme/dark.ts | 2 +- src/config/theme/index.ts | 2 +- src/locales/en-US/common.ts | 2 +- src/locales/en-US/playground.ts | 2 +- src/locales/ja-JP/playground.ts | 4 +- src/locales/ru-RU/playground.ts | 4 +- src/locales/zh-CN/playground.ts | 2 +- .../playground/components/ground-reranker.tsx | 3 +- .../multiple-chat/message-actions.tsx | 25 ++++++------ 11 files changed, 35 insertions(+), 61 deletions(-) diff --git a/src/components/seal-table/components/header-prefix.tsx b/src/components/seal-table/components/header-prefix.tsx index 935d547c..245f5ca6 100644 --- a/src/components/seal-table/components/header-prefix.tsx +++ b/src/components/seal-table/components/header-prefix.tsx @@ -1,7 +1,7 @@ import IconFont from '@/components/icon-font'; -import { ClearOutlined, RightOutlined } from '@ant-design/icons'; +import { RightOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; -import { Button, Checkbox, Tooltip } from 'antd'; +import { Button, Checkbox } from 'antd'; import _ from 'lodash'; import React from 'react'; @@ -77,36 +77,12 @@ const HeaderPrefix: React.FC = (props) => { expandable )} - } - onClick={handleUnCheckAll} - > - {intl.formatMessage({ id: 'common.button.clearSelection' })} - - ) - } - overlayClassName="light-downloading-tooltip" - overlayInnerStyle={{ - backgroundColor: 'var(--color-spotlight-bg)' - }} - > - - + ); } diff --git a/src/components/upload-audio/index.tsx b/src/components/upload-audio/index.tsx index 13399ba1..0319475a 100644 --- a/src/components/upload-audio/index.tsx +++ b/src/components/upload-audio/index.tsx @@ -20,12 +20,10 @@ const UploadAudio: React.FC = (props) => { return false; }; - const handleOnChange = React.useCallback( - (data: { file: any; fileList: any }) => { - props.onChange?.(data); - }, - [] - ); + const handleOnChange = (data: { file: any; fileList: any }) => { + props.onChange?.(data); + }; + return ( = forwardRef((props, ref) => { const submitMessage = async (query: string) => { try { setIsEmptyQuery(!queryValue); + setTokenResult(null); await formRef.current?.form.validateFields(); if (!parameters.model || !queryValue) return; @@ -262,7 +263,7 @@ const GroundReranker: React.FC = forwardRef((props, ref) => { setIsEmptyText(false); setLoading(true); setMessageId(); - setTokenResult(null); + requestToken.current?.cancel?.(); requestToken.current = requestSource(); diff --git a/src/pages/playground/components/multiple-chat/message-actions.tsx b/src/pages/playground/components/multiple-chat/message-actions.tsx index fe854a9a..03492839 100644 --- a/src/pages/playground/components/multiple-chat/message-actions.tsx +++ b/src/pages/playground/components/multiple-chat/message-actions.tsx @@ -9,7 +9,7 @@ import { import { useIntl } from '@umijs/max'; import { Button, Tooltip } from 'antd'; import _ from 'lodash'; -import React, { useCallback } from 'react'; +import React from 'react'; import { Roles } from '../../config'; import { AudioFormat, @@ -43,18 +43,17 @@ const MessageActions: React.FC = ({ }) => { const intl = useIntl(); - const handleUpdateImgList = useCallback( - (list: { uid: number | string; dataUrl: string }[]) => { - updateMessage?.({ - role: data.role, - content: data.content, - uid: data.uid, - audio: data.audio || [], - imgs: [...(data.imgs || []), ...list] - }); - }, - [data, updateMessage] - ); + const handleUpdateImgList = ( + list: { uid: number | string; dataUrl: string }[] + ) => { + updateMessage?.({ + role: data.role, + content: data.content, + uid: data.uid, + audio: data.audio || [], + imgs: [...(data.imgs || []), ...list] + }); + }; const handleUploadAudioChange = async (audio: { file: any;