fix: audio uploader has cache issue

main
jialin 10 months ago
parent fd3d7a6f29
commit 547f49a978

@ -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<HeaderPrefixProps> = (props) => {
expandable
)}
</span>
<Tooltip
destroyTooltipOnHide
fresh={true}
defaultOpen={false}
title={
indeterminate && (
<Button
size="small"
type="text"
variant="filled"
color="default"
icon={<ClearOutlined />}
onClick={handleUnCheckAll}
>
{intl.formatMessage({ id: 'common.button.clearSelection' })}
</Button>
)
}
overlayClassName="light-downloading-tooltip"
overlayInnerStyle={{
backgroundColor: 'var(--color-spotlight-bg)'
}}
>
<Checkbox
onChange={onSelectAll}
indeterminate={indeterminate}
checked={selectAll}
disabled={disabled}
></Checkbox>
</Tooltip>
<Checkbox
onChange={onSelectAll}
indeterminate={indeterminate}
checked={selectAll}
disabled={disabled}
></Checkbox>
</div>
);
}

@ -20,12 +20,10 @@ const UploadAudio: React.FC<UploadAudioProps> = (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 (
<Tooltip
overlayInnerStyle={{ maxWidth: 290, width: 'max-content' }}

@ -32,7 +32,7 @@ export default {
iconSize: 16,
iconMarginInlineEnd: 12,
itemBorderRadius: 4,
itemHeight: 44,
itemHeight: 36,
itemSelectedColor: '#007BFF',
darkItemSelectedBg: '#141414',
darkItemHoverBg: 'rgba(255, 255, 255, 0.03)',

@ -6,5 +6,5 @@ export const colorPrimary = '#007BFF';
export default {
light,
dark,
colorPrimary: '#007BFF'
colorPrimary: colorPrimary
};

@ -105,7 +105,7 @@ export default {
'common.button.addfile': 'Add File',
'common.logout.msg': 'Log out succeeded',
'common.button.logout': 'Log out',
'common.form.rule.select': 'please select {name}',
'common.form.rule.select': 'Please select a {name}',
'common.form.rule.input': '{name} is required',
'common.form.key': 'the same key exists',
'common.date.utc': 'UTC time',

@ -152,5 +152,5 @@ export default {
'1. After selection, no further masking can be drawn; therefore, you should draw the mask first and then check the option.\n 2. Once a mask image is uploaded, no further masks can be generated.',
'playground.model.noavailable.tips2':
'If the expected model isnt showing up, make sure its running and correctly categorized. If the category is incorrect, you can manually adjust it in the models settings.',
'playground.rerank.query.validate': 'Please enter something to search.'
'playground.rerank.query.validate': 'The query is required.'
};

@ -155,9 +155,9 @@ export default {
'1. 選択後は追加のマスクを描画できません。そのため、最初にマスクを描画してからオプションを選択してください。\n 2. マスク画像をアップロードすると、追加のマスクを生成することはできません。',
'playground.model.noavailable.tips2':
'期待するモデルが表示されない場合は、モデルが実行中で正しく分類されていることを確認してください。カテゴリが間違っている場合は、モデルの設定で手動で調整できます。',
'playground.rerank.query.validate': 'Please enter something to search.'
'playground.rerank.query.validate': 'The query is required.'
};
// ========== To-Do: Translate Keys (Remove After Translation) ==========
// 1. 'playground.rerank.query.validate': 'Please enter something to search.'
// 1. 'playground.rerank.query.validate': 'The query is required.'
// ========== End of To-Do List ==========

@ -149,9 +149,9 @@ export default {
'1. После выделения области создание маски станет недоступным; поэтому сначала нарисуйте маску, а затем активируйте опцию. \n 2. После загрузки изображения маски создание новых масок невозможно.',
'playground.model.noavailable.tips2':
'Если нужная модель не отображается, убедитесь, что она запущена и ей присвоена правильная категория. Если категория указана неверно, её можно изменить вручную в настройках модели.',
'playground.rerank.query.validate': 'Please enter something to search.'
'playground.rerank.query.validate': 'The query is required.'
};
// ========== To-Do: Translate Keys (Remove After Translation) ==========
// 1. 'playground.rerank.query.validate': 'Please enter something to search.'
// 1. 'playground.rerank.query.validate': 'The query is required.'
// ========== End of To-Do List ==========

@ -146,5 +146,5 @@ export default {
'1. 选择后,将不可再绘制遮罩;因此,你应该先绘制遮罩然后再勾选.\n 2. 当上传了遮罩图片,将不可再生成遮罩',
'playground.model.noavailable.tips2':
'若预期的模型未显示,请检查模型是否已正常运行并被正确分类。如分类不正确,请编辑模型并手动调整其类别。',
'playground.rerank.query.validate': '请输入搜索内容'
'playground.rerank.query.validate': '查询内容不能为空'
};

@ -248,6 +248,7 @@ const GroundReranker: React.FC<MessageProps> = 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<MessageProps> = forwardRef((props, ref) => {
setIsEmptyText(false);
setLoading(true);
setMessageId();
setTokenResult(null);
requestToken.current?.cancel?.();
requestToken.current = requestSource();

@ -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<MessageActionsProps> = ({
}) => {
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;

Loading…
Cancel
Save