fix: audio error message

This commit is contained in:
jialin
2024-12-03 17:33:49 +08:00
parent 83294abaf0
commit 20f809740c
10 changed files with 47 additions and 17 deletions
+8 -2
View File
@@ -5,6 +5,7 @@ import './index.less';
interface AudioAnimationProps {
width: number;
height: number;
maxWidth?: number;
scaleFactor?: number;
maxBarCount?: number;
fixedHeight?: boolean;
@@ -18,6 +19,7 @@ const AudioAnimation: React.FC<AudioAnimationProps> = (props) => {
const {
scaleFactor = 1.2,
maxBarCount = 128,
maxWidth,
fixedHeight = true,
analyserData,
width: initialWidth,
@@ -133,12 +135,16 @@ const AudioAnimation: React.FC<AudioAnimationProps> = (props) => {
React.useEffect(() => {
if (size) {
setWidth(size?.width || 0);
if (maxWidth) {
setWidth(Math.min(size.width, maxWidth));
} else {
setWidth(size?.width || 0);
}
if (!fixedHeight) {
setHeight(size?.height || 0);
}
}
}, [size]);
}, [size, maxWidth]);
useEffect(() => {
if (!canvasRef.current) return;
@@ -140,6 +140,7 @@ const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
const updateContent = useCallback(
(inputStr: string) => {
console.log('inputStr===', inputStr);
const data = inputStr.replace(replaceLineRegex, '\n');
if (isClean(data)) {
cacheDataRef.current = data;
@@ -124,6 +124,11 @@ const SpeechItem: React.FC<SpeechContentProps> = (props) => {
debounceSeek(value);
};
const handlOnChangeComplete = useCallback((value: number) => {
ref.current?.seekTo(value / duration);
setCurrentTime(value);
}, []);
const onDownload = useCallback(() => {
const url = props.audioUrl || '';
const filename = `audio-${dayjs().format('YYYYMMDDHHmmss')}.${props.format}`;