style: image display ratio
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 658 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 644 KiB |
@@ -3,9 +3,11 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
canvas {
|
canvas {
|
||||||
display: block;
|
display: block;
|
||||||
|
width: 100%;
|
||||||
image-rendering: crisp-edges;
|
image-rendering: crisp-edges;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import useResizeObserver from '@/components/logs-viewer/use-size';
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
@@ -5,24 +6,31 @@ interface AudioAnimationProps {
|
|||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
scaleFactor?: number;
|
scaleFactor?: number;
|
||||||
|
maxBarCount?: number;
|
||||||
analyserData: {
|
analyserData: {
|
||||||
data: Uint8Array;
|
data: Uint8Array;
|
||||||
analyser: any;
|
analyser: any;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const AudioAnimation: React.FC<AudioAnimationProps> = ({
|
const AudioAnimation: React.FC<AudioAnimationProps> = (props) => {
|
||||||
width,
|
const {
|
||||||
height,
|
scaleFactor = 1.2,
|
||||||
scaleFactor = 1.2,
|
maxBarCount = 128,
|
||||||
analyserData
|
analyserData,
|
||||||
}) => {
|
width,
|
||||||
|
height
|
||||||
|
} = props;
|
||||||
const canvasRef = React.useRef<HTMLCanvasElement>(null);
|
const canvasRef = React.useRef<HTMLCanvasElement>(null);
|
||||||
const animationId = React.useRef<number>(0);
|
const animationId = React.useRef<number>(0);
|
||||||
const isScaled = React.useRef<boolean>(false);
|
const isScaled = React.useRef<boolean>(false);
|
||||||
const oscillationOffset = React.useRef(0);
|
const oscillationOffset = React.useRef(0);
|
||||||
const direction = React.useRef(1);
|
const direction = React.useRef(1);
|
||||||
const maxBarCount = 128;
|
// const [width, setWidth] = useState(props.width);
|
||||||
|
// const [height, setHeight] = useState(props.height);
|
||||||
|
const containerRef = React.useRef<any>(null);
|
||||||
|
|
||||||
|
const size = useResizeObserver(containerRef);
|
||||||
|
|
||||||
const calculateJitter = (
|
const calculateJitter = (
|
||||||
i: number,
|
i: number,
|
||||||
@@ -120,7 +128,29 @@ const AudioAnimation: React.FC<AudioAnimationProps> = ({
|
|||||||
draw(performance.now());
|
draw(performance.now());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// const handleResizeThrottle = React.useCallback(
|
||||||
|
// throttle(() => {
|
||||||
|
// console.log('size:', size);
|
||||||
|
// if (size.width && size.width !== width) {
|
||||||
|
// setWidth(size.width);
|
||||||
|
// }
|
||||||
|
// if (size.height && size.height !== height) {
|
||||||
|
// setHeight(size.height);
|
||||||
|
// }
|
||||||
|
// }, 100),
|
||||||
|
// [size, width, height]
|
||||||
|
// );
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// handleResizeThrottle();
|
||||||
|
// window.addEventListener('resize', handleResizeThrottle);
|
||||||
|
// return () => {
|
||||||
|
// handleResizeThrottle.cancel();
|
||||||
|
// };
|
||||||
|
// }, [size, width, height]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!canvasRef.current) return;
|
||||||
const clearCanvas = () => {
|
const clearCanvas = () => {
|
||||||
if (canvasRef.current) {
|
if (canvasRef.current) {
|
||||||
const ctx = canvasRef.current.getContext('2d');
|
const ctx = canvasRef.current.getContext('2d');
|
||||||
@@ -145,6 +175,7 @@ const AudioAnimation: React.FC<AudioAnimationProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
ref={containerRef}
|
||||||
className="canvas-wrap"
|
className="canvas-wrap"
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ const AutoImage: React.FC<
|
|||||||
handleOnLoad();
|
handleOnLoad();
|
||||||
}, [handleOnLoad]);
|
}, [handleOnLoad]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setWidth(w || 0);
|
||||||
|
}, [w]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AntImage
|
<AntImage
|
||||||
{...rest}
|
{...rest}
|
||||||
|
|||||||
@@ -51,7 +51,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.single-image {
|
.single-image {
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -59,6 +58,11 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: var(--border-radius-base);
|
border-radius: var(--border-radius-base);
|
||||||
|
|
||||||
|
&.loading {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
&.auto-bg-color {
|
&.auto-bg-color {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { CloseCircleOutlined } from '@ant-design/icons';
|
|||||||
import { Progress } from 'antd';
|
import { Progress } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import * as Vibrant from 'node-vibrant';
|
import * as Vibrant from 'node-vibrant';
|
||||||
|
import ResizeObserver from 'rc-resize-observer';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import AutoImage from './index';
|
import AutoImage from './index';
|
||||||
import './single-image.less';
|
import './single-image.less';
|
||||||
@@ -39,10 +40,14 @@ const SingleImage: React.FC<SingleImageProps> = (props) => {
|
|||||||
|
|
||||||
const [color, setColor] = React.useState({});
|
const [color, setColor] = React.useState({});
|
||||||
const imgWrapper = React.useRef<HTMLSpanElement>(null);
|
const imgWrapper = React.useRef<HTMLSpanElement>(null);
|
||||||
|
const [imgSize, setImgSize] = React.useState({
|
||||||
|
width: width,
|
||||||
|
height: height
|
||||||
|
});
|
||||||
|
|
||||||
const thumImgWrapStyle = React.useMemo(() => {
|
const thumImgWrapStyle = React.useMemo(() => {
|
||||||
return loading ? { width: width, height: height } : {};
|
return loading ? { width: '100%', height: '100%' } : {};
|
||||||
}, [loading, width, height]);
|
}, [loading, imgSize]);
|
||||||
|
|
||||||
const handleOnLoad = React.useCallback(async () => {
|
const handleOnLoad = React.useCallback(async () => {
|
||||||
if (!autoBgColor) {
|
if (!autoBgColor) {
|
||||||
@@ -73,76 +78,114 @@ const SingleImage: React.FC<SingleImageProps> = (props) => {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const handleResize = React.useCallback(
|
||||||
|
(size: { width: number; height: number }) => {
|
||||||
|
if (!autoSize) return;
|
||||||
|
|
||||||
|
const { width: containerWidth, height: containerHeight } = size;
|
||||||
|
const { width: originalWidth, height: originalHeight } = props;
|
||||||
|
|
||||||
|
if (!originalWidth || !originalHeight) return;
|
||||||
|
|
||||||
|
const imageAspectRatio = originalWidth / originalHeight;
|
||||||
|
const containerAspectRatio = containerWidth / containerHeight;
|
||||||
|
|
||||||
|
let newWidth, newHeight;
|
||||||
|
|
||||||
|
if (containerAspectRatio > imageAspectRatio) {
|
||||||
|
newHeight = containerHeight;
|
||||||
|
newWidth = containerHeight * imageAspectRatio;
|
||||||
|
} else {
|
||||||
|
newWidth = containerWidth;
|
||||||
|
newHeight = containerWidth / imageAspectRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
setImgSize({
|
||||||
|
width: newWidth,
|
||||||
|
height: newHeight
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[autoSize, props]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<ResizeObserver onResize={handleResize}>
|
||||||
key={uid}
|
<div
|
||||||
className={classNames('single-image', { 'auto-bg-color': autoBgColor })}
|
key={uid}
|
||||||
>
|
className={classNames('single-image', {
|
||||||
{autoBgColor && (
|
'auto-bg-color': autoBgColor,
|
||||||
<div
|
'auto-size': autoSize,
|
||||||
className="mask"
|
loading: loading
|
||||||
style={{
|
})}
|
||||||
background: `url(${dataUrl}) center center / cover no-repeat`
|
|
||||||
}}
|
|
||||||
></div>
|
|
||||||
)}
|
|
||||||
<span
|
|
||||||
className="thumb-img"
|
|
||||||
style={{
|
|
||||||
...thumImgWrapStyle
|
|
||||||
}}
|
|
||||||
ref={imgWrapper}
|
|
||||||
>
|
>
|
||||||
<>
|
{autoBgColor && (
|
||||||
{loading ? (
|
<div
|
||||||
<span
|
className="mask"
|
||||||
className="progress-wrap"
|
style={{
|
||||||
style={{
|
background: `url(${dataUrl}) center center / cover no-repeat`
|
||||||
width: '100%',
|
}}
|
||||||
height: '100%',
|
></div>
|
||||||
display: 'flex',
|
)}
|
||||||
border: '1px solid var(--ant-color-split)',
|
<span
|
||||||
borderRadius: 'var(--border-radius-base)',
|
className="thumb-img"
|
||||||
justifyContent: 'center',
|
style={{
|
||||||
alignItems: 'center',
|
...thumImgWrapStyle
|
||||||
padding: '10px',
|
}}
|
||||||
overflow: 'hidden'
|
ref={imgWrapper}
|
||||||
}}
|
>
|
||||||
>
|
<>
|
||||||
<Progress
|
{loading ? (
|
||||||
percent={progress}
|
<span
|
||||||
type="dashboard"
|
className="progress-wrap"
|
||||||
steps={{ count: 50, gap: 2 }}
|
style={{
|
||||||
format={() => <span className="font-size-20">{progress}%</span>}
|
width: '100%',
|
||||||
trailColor="var(--ant-color-fill-secondary)"
|
height: '100%',
|
||||||
/>
|
display: 'flex',
|
||||||
</span>
|
border: '1px solid var(--ant-color-split)',
|
||||||
) : (
|
borderRadius: 'var(--border-radius-base)',
|
||||||
<span
|
justifyContent: 'center',
|
||||||
className="img"
|
alignItems: 'center',
|
||||||
style={{
|
padding: '10px',
|
||||||
maxHeight: `min(${maxHeight}, 100%)`,
|
overflow: 'hidden'
|
||||||
maxWidth: `min(${maxWidth}, 100%)`
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<Progress
|
||||||
<AutoImage
|
percent={progress}
|
||||||
autoSize={autoSize}
|
type="dashboard"
|
||||||
src={dataUrl}
|
steps={{ count: 50, gap: 2 }}
|
||||||
width={width || 100}
|
format={() => (
|
||||||
height={height || 100}
|
<span className="font-size-20">{progress}%</span>
|
||||||
onLoad={handleOnLoad}
|
)}
|
||||||
/>
|
trailColor="var(--ant-color-fill-secondary)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span
|
||||||
|
className="img"
|
||||||
|
style={{
|
||||||
|
maxHeight: `min(${maxHeight}, 100%)`,
|
||||||
|
maxWidth: `min(${maxWidth}, 100%)`
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<AutoImage
|
||||||
|
autoSize={autoSize}
|
||||||
|
src={dataUrl}
|
||||||
|
width={imgSize.width || 100}
|
||||||
|
height={imgSize.height || 100}
|
||||||
|
onLoad={handleOnLoad}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
|
||||||
|
{editable && (
|
||||||
|
<span className="del" onClick={() => handleOnDelete(uid)}>
|
||||||
|
<CloseCircleOutlined />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</>
|
</span>
|
||||||
|
</div>
|
||||||
{editable && (
|
</ResizeObserver>
|
||||||
<span className="del" onClick={() => handleOnDelete(uid)}>
|
|
||||||
<CloseCircleOutlined />
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,27 @@
|
|||||||
import useResizeObserver from '@react-hook/resize-observer';
|
import { useEffect, useState } from 'react';
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
export default function useSize(target: any) {
|
const useResizeObserver = (ref: React.RefObject<HTMLElement>) => {
|
||||||
const [size, setSize] = React.useState();
|
const [size, setSize] = useState({ width: 0, height: 0 });
|
||||||
|
|
||||||
React.useLayoutEffect(() => {
|
useEffect(() => {
|
||||||
setSize(target.current?.getBoundingClientRect());
|
const element = ref.current;
|
||||||
}, [target]);
|
if (!element) return;
|
||||||
|
|
||||||
|
const observer = new ResizeObserver((entries) => {
|
||||||
|
if (entries[0]) {
|
||||||
|
const { width, height } = entries[0].contentRect;
|
||||||
|
setSize({ width, height });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
observer.observe(element);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
observer.disconnect();
|
||||||
|
};
|
||||||
|
}, [ref]);
|
||||||
|
|
||||||
useResizeObserver(target, (entry: any) => setSize(entry?.contentRect));
|
|
||||||
return size;
|
return size;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export default useResizeObserver;
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ interface AudioPlayerProps {
|
|||||||
ref?: any;
|
ref?: any;
|
||||||
height?: number;
|
height?: number;
|
||||||
width?: number;
|
width?: number;
|
||||||
onReady?: () => void;
|
onReady?: (duration: number) => void;
|
||||||
onClick?: (value: number) => void;
|
onClick?: (value: number) => void;
|
||||||
onFinish?: () => void;
|
onFinish?: () => void;
|
||||||
onAnalyse?: (analyseData: any, frequencyBinCount: any) => void;
|
onAnalyse?: (analyseData: any, frequencyBinCount: any) => void;
|
||||||
|
onAudioprocess?: (current: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AudioPlayer: React.FC<
|
const AudioPlayer: React.FC<
|
||||||
@@ -29,7 +30,6 @@ const AudioPlayer: React.FC<
|
|||||||
const audioContext = useRef<any>(null);
|
const audioContext = useRef<any>(null);
|
||||||
const analyser = useRef<any>(null);
|
const analyser = useRef<any>(null);
|
||||||
const dataArray = useRef<any>(null);
|
const dataArray = useRef<any>(null);
|
||||||
const audioStream = useRef<any>(null);
|
|
||||||
const mediaElement = useRef<any>(null);
|
const mediaElement = useRef<any>(null);
|
||||||
|
|
||||||
const initAudioContext = useCallback(() => {
|
const initAudioContext = useCallback(() => {
|
||||||
@@ -50,8 +50,8 @@ const AudioPlayer: React.FC<
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const listenEvents = () => {
|
const listenEvents = () => {
|
||||||
wavesurfer.current?.on('ready', () => {
|
wavesurfer.current?.on('ready', (duration: number) => {
|
||||||
props.onReady?.();
|
props.onReady?.(duration);
|
||||||
});
|
});
|
||||||
|
|
||||||
wavesurfer.current?.on('click', (value) => {
|
wavesurfer.current?.on('click', (value) => {
|
||||||
@@ -60,9 +60,13 @@ const AudioPlayer: React.FC<
|
|||||||
wavesurfer.current?.on('finish', () => {
|
wavesurfer.current?.on('finish', () => {
|
||||||
props.onFinish?.();
|
props.onFinish?.();
|
||||||
});
|
});
|
||||||
|
wavesurfer.current?.on('audioprocess', (current: number) => {
|
||||||
|
console.log('audioprocess==========:', current);
|
||||||
|
props.onAudioprocess?.(current);
|
||||||
|
});
|
||||||
wavesurfer.current?.on('play', () => {
|
wavesurfer.current?.on('play', () => {
|
||||||
// analyser.current?.getByteFrequencyData(dataArray.current);
|
analyser.current?.getByteFrequencyData(dataArray.current);
|
||||||
// props.onAnalyse?.(dataArray.current, analyser);
|
props.onAnalyse?.(dataArray.current, analyser);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import IconFont from '@/components/icon-font';
|
import useResizeObserver from '@/components/logs-viewer/use-size';
|
||||||
import { formatTime } from '@/utils/index';
|
|
||||||
import {
|
import {
|
||||||
DownloadOutlined,
|
DownloadOutlined,
|
||||||
PauseCircleOutlined,
|
PauseCircleOutlined,
|
||||||
@@ -8,7 +7,8 @@ import {
|
|||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Button, Tooltip } from 'antd';
|
import { Button, Tooltip } from 'antd';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import React, { useRef, useState } from 'react';
|
import _ from 'lodash';
|
||||||
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import AudioPlayer from './audio-player';
|
import AudioPlayer from './audio-player';
|
||||||
import './styles/index.less';
|
import './styles/index.less';
|
||||||
|
|
||||||
@@ -36,16 +36,19 @@ interface SpeechContentProps {
|
|||||||
}
|
}
|
||||||
const SpeechItem: React.FC<SpeechContentProps> = (props) => {
|
const SpeechItem: React.FC<SpeechContentProps> = (props) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [collapsed, setCollapsed] = useState(false);
|
|
||||||
const [isPlay, setIsPlay] = useState(props.autoplay);
|
const [isPlay, setIsPlay] = useState(props.autoplay);
|
||||||
const [duration, setDuration] = useState(0);
|
const [duration, setDuration] = useState(0);
|
||||||
|
const [animationSize, setAnimationSize] = useState({ width: 900, height: 0 });
|
||||||
const [currentTime, setCurrentTime] = useState(0);
|
const [currentTime, setCurrentTime] = useState(0);
|
||||||
const [audioChunks, setAudioChunks] = useState<any>({
|
const [audioChunks, setAudioChunks] = useState<any>({
|
||||||
data: [],
|
data: new Uint8Array(128),
|
||||||
analyser: null
|
analyser: null
|
||||||
});
|
});
|
||||||
|
const wrapper = useRef<any>(null);
|
||||||
const ref = useRef<any>(null);
|
const ref = useRef<any>(null);
|
||||||
|
|
||||||
|
const size = useResizeObserver(wrapper);
|
||||||
|
|
||||||
const handlePlay = () => {
|
const handlePlay = () => {
|
||||||
if (isPlay) {
|
if (isPlay) {
|
||||||
ref.current?.pause();
|
ref.current?.pause();
|
||||||
@@ -56,24 +59,44 @@ const SpeechItem: React.FC<SpeechContentProps> = (props) => {
|
|||||||
setIsPlay(true);
|
setIsPlay(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnAnalyse = (data: any, analyser: any) => {
|
const handleOnAnalyse = useCallback((data: any, analyser: any) => {
|
||||||
setAudioChunks((pre: any) => {
|
setAudioChunks((pre: any) => {
|
||||||
return {
|
return {
|
||||||
data: data,
|
data: data,
|
||||||
analyser: analyser
|
analyser: analyser
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
const handleReay = () => {
|
const handleOnFinish = useCallback(() => {
|
||||||
const duration = ref.current?.duration?.();
|
setIsPlay(false);
|
||||||
setDuration(duration < 1 ? 1 : duration);
|
}, []);
|
||||||
};
|
|
||||||
|
|
||||||
const handleOnClick = (value: number) => {
|
const handleOnAudioprocess = useCallback((current: number) => {
|
||||||
|
setCurrentTime(() => current);
|
||||||
|
console.log('current:', current, duration);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleReay = useCallback((duration: number) => {
|
||||||
|
setIsPlay(props.autoplay);
|
||||||
|
setDuration(duration);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleOnClick = useCallback((value: number) => {
|
||||||
console.log('current:', value);
|
console.log('current:', value);
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
|
const handleAnimationResize = useCallback((size: any) => {
|
||||||
|
console.log('size:=======', size);
|
||||||
|
setAnimationSize({
|
||||||
|
width: size.width,
|
||||||
|
height: size.height
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
console.log('width:', size);
|
||||||
|
}, [size]);
|
||||||
const onDownload = () => {
|
const onDownload = () => {
|
||||||
const url = props.audioUrl || '';
|
const url = props.audioUrl || '';
|
||||||
const filename = `audio-${dayjs().format('YYYYMMDDHHmmss')}.${props.format}`;
|
const filename = `audio-${dayjs().format('YYYYMMDDHHmmss')}.${props.format}`;
|
||||||
@@ -89,33 +112,37 @@ const SpeechItem: React.FC<SpeechContentProps> = (props) => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="speech-item">
|
<div className="speech-item">
|
||||||
{/* {isPlay && (
|
<div
|
||||||
<AudioAnimation
|
className="wrapper"
|
||||||
height={82}
|
style={{ height: 82, width: '100%' }}
|
||||||
width={500}
|
ref={wrapper}
|
||||||
analyserData={audioChunks}
|
>
|
||||||
></AudioAnimation>
|
|
||||||
)} */}
|
|
||||||
<div className="voice">
|
|
||||||
<IconFont type="icon-user_voice" className="font-size-16" />
|
|
||||||
</div>
|
|
||||||
<div className="wrapper">
|
|
||||||
<AudioPlayer
|
<AudioPlayer
|
||||||
{...props}
|
{...props}
|
||||||
audioUrl={props.audioUrl}
|
audioUrl={props.audioUrl}
|
||||||
onReady={handleReay}
|
onReady={handleReay}
|
||||||
onClick={handleOnClick}
|
onClick={handleOnClick}
|
||||||
onFinish={() => setIsPlay(false)}
|
onFinish={handleOnFinish}
|
||||||
onAnalyse={handleOnAnalyse}
|
onAnalyse={handleOnAnalyse}
|
||||||
|
onAudioprocess={handleOnAudioprocess}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
></AudioPlayer>
|
></AudioPlayer>
|
||||||
|
{/* {isPlay && (
|
||||||
|
<AudioAnimation
|
||||||
|
maxBarCount={180}
|
||||||
|
height={82}
|
||||||
|
width={800}
|
||||||
|
analyserData={audioChunks}
|
||||||
|
></AudioAnimation>
|
||||||
|
)} */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/* <Slider value={currentTime} max={duration} step={0.01}></Slider> */}
|
||||||
<div className="speech-actions">
|
<div className="speech-actions">
|
||||||
<span className="tags">
|
<span className="tags">
|
||||||
<span className="item">{props.format}</span>
|
<span className="item">{props.format}</span>
|
||||||
</span>
|
</span>
|
||||||
<span className="duration">{formatTime(duration)}</span>
|
<span className="duration">{_.round(duration, 2)}</span>
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={
|
title={
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
.voice {
|
.voice {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
@@ -55,7 +56,7 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
padding-left: 80px;
|
// padding-left: 80px;
|
||||||
|
|
||||||
.actions {
|
.actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -263,8 +263,8 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
const progress = _.round(item.progress, 0);
|
const progress = _.round(item.progress, 0);
|
||||||
newImageList[item.index] = {
|
newImageList[item.index] = {
|
||||||
dataUrl: imgItem.dataUrl,
|
dataUrl: imgItem.dataUrl,
|
||||||
height: '100%',
|
height: imgSize[1],
|
||||||
width: '100%',
|
width: imgSize[0],
|
||||||
maxHeight: `${imgSize[1]}px`,
|
maxHeight: `${imgSize[1]}px`,
|
||||||
maxWidth: `${imgSize[0]}px`,
|
maxWidth: `${imgSize[0]}px`,
|
||||||
uid: imgItem.uid,
|
uid: imgItem.uid,
|
||||||
|
|||||||
@@ -212,7 +212,6 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
const res = await queryModelVoices({
|
const res = await queryModelVoices({
|
||||||
model: value
|
model: value
|
||||||
});
|
});
|
||||||
console.log('res:', res);
|
|
||||||
if (res?.error) {
|
if (res?.error) {
|
||||||
setVoiceError({
|
setVoiceError({
|
||||||
error: true,
|
error: true,
|
||||||
@@ -235,6 +234,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
const newList = sortVoiceList(locale, list);
|
const newList = sortVoiceList(locale, list);
|
||||||
|
|
||||||
setVoiceList(newList);
|
setVoiceList(newList);
|
||||||
|
setVoiceError(null);
|
||||||
setParams((pre: any) => {
|
setParams((pre: any) => {
|
||||||
return {
|
return {
|
||||||
...pre,
|
...pre,
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import AutoImage from '@/components/auto-image';
|
|
||||||
import SingleImage from '@/components/auto-image/single-image';
|
import SingleImage from '@/components/auto-image/single-image';
|
||||||
import { CloseCircleOutlined } from '@ant-design/icons';
|
import { Col, Row } from 'antd';
|
||||||
import { Col, Progress, Row } from 'antd';
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import '../style/thumb-img.less';
|
import '../style/thumb-img.less';
|
||||||
@@ -38,57 +36,6 @@ const ThumbImg: React.FC<{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderImageItem = (item: any) => {
|
|
||||||
const thumImgWrapStyle = item.loading
|
|
||||||
? { width: item.width, height: item.height }
|
|
||||||
: {};
|
|
||||||
return (
|
|
||||||
<span key={item.uid} className="thumb-img" style={thumImgWrapStyle}>
|
|
||||||
<>
|
|
||||||
{item.loading ? (
|
|
||||||
<span
|
|
||||||
className="progress-wrap"
|
|
||||||
style={{
|
|
||||||
width: '100%',
|
|
||||||
height: '100%',
|
|
||||||
display: 'flex',
|
|
||||||
border: '1px solid var(--ant-color-split)',
|
|
||||||
borderRadius: 'var(--border-radius-base)',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
padding: '10px',
|
|
||||||
overflow: 'hidden'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Progress percent={item.progress} type="circle" />
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
<span
|
|
||||||
className="img"
|
|
||||||
style={{
|
|
||||||
maxHeight: `min(${item.maxHeight}, 100%)`,
|
|
||||||
maxWidth: `min(${item.maxWidth}, 100%)`
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<AutoImage
|
|
||||||
autoSize={autoSize}
|
|
||||||
src={item.dataUrl}
|
|
||||||
width={item.width || 100}
|
|
||||||
height={item.height || 100}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
|
|
||||||
{editable && (
|
|
||||||
<span className="del" onClick={() => handleOnDelete(item.uid)}>
|
|
||||||
<CloseCircleOutlined />
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{
|
{
|
||||||
@@ -147,6 +94,7 @@ const ThumbImg: React.FC<{
|
|||||||
>
|
>
|
||||||
<SingleImage
|
<SingleImage
|
||||||
{...item}
|
{...item}
|
||||||
|
loading={item.loading}
|
||||||
autoSize={autoSize}
|
autoSize={autoSize}
|
||||||
editable={editable}
|
editable={editable}
|
||||||
autoBgColor={autoBgColor}
|
autoBgColor={autoBgColor}
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ export const ImageAdvancedParamsConfig: ParamsSchema[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'Input',
|
type: 'Input',
|
||||||
name: 'negative_prompt',
|
name: 'negative_prompt', //ng_deepnegative_v1_75t,(badhandv4:1.2),EasyNegative,(worst quality:2),
|
||||||
label: {
|
label: {
|
||||||
text: 'playground.image.params.negativePrompt',
|
text: 'playground.image.params.negativePrompt',
|
||||||
isLocalized: true
|
isLocalized: true
|
||||||
|
|||||||
@@ -1,39 +1,44 @@
|
|||||||
|
// import Img01 from '@/assets/images/img_01.png';
|
||||||
|
import Img02 from '@/assets/images/img_02.png';
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
dataUrl:
|
// dataUrl:
|
||||||
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
// 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
||||||
height: 'auto',
|
dataUrl: Img02,
|
||||||
width: 'auto',
|
height: 1024,
|
||||||
|
width: 512,
|
||||||
uid: 0,
|
uid: 0,
|
||||||
span: 12,
|
span: 24,
|
||||||
loading: true,
|
loading: false,
|
||||||
progress: 30
|
progress: 30
|
||||||
},
|
|
||||||
{
|
|
||||||
dataUrl:
|
|
||||||
'https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp',
|
|
||||||
height: 'auto',
|
|
||||||
width: 'auto',
|
|
||||||
uid: 1,
|
|
||||||
span: 12,
|
|
||||||
progress: 15
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataUrl:
|
|
||||||
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
||||||
height: 'auto',
|
|
||||||
width: 'auto',
|
|
||||||
uid: 3,
|
|
||||||
span: 12,
|
|
||||||
progress: 10
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataUrl:
|
|
||||||
'https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp',
|
|
||||||
height: 'auto',
|
|
||||||
width: 'auto',
|
|
||||||
uid: 4,
|
|
||||||
span: 12,
|
|
||||||
progress: 15
|
|
||||||
}
|
}
|
||||||
|
// {
|
||||||
|
// // dataUrl:
|
||||||
|
// // 'https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp',
|
||||||
|
// dataUrl: Img02,
|
||||||
|
// height: 1024,
|
||||||
|
// width: 512,
|
||||||
|
// uid: 1,
|
||||||
|
// span: 12,
|
||||||
|
// progress: 15
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
// dataUrl:
|
||||||
|
// 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
||||||
|
// height: 'auto',
|
||||||
|
// width: 'auto',
|
||||||
|
// uid: 3,
|
||||||
|
// span: 12,
|
||||||
|
// progress: 10
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// dataUrl:
|
||||||
|
// 'https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp',
|
||||||
|
// height: 'auto',
|
||||||
|
// width: 'auto',
|
||||||
|
// uid: 4,
|
||||||
|
// span: 12,
|
||||||
|
// progress: 15
|
||||||
|
// }
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
.del {
|
.del {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -4px;
|
top: 2px;
|
||||||
right: -2px;
|
right: 2px;
|
||||||
font-size: var(--font-size-middle);
|
font-size: var(--font-size-middle);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-color: var(--color-white-1);
|
background-color: var(--color-white-1);
|
||||||
|
|||||||
+2
-2
@@ -137,6 +137,6 @@ export const isHTMLDocumentString = (str: string) => {
|
|||||||
// generate a random number between 0 and 64 bit
|
// generate a random number between 0 and 64 bit
|
||||||
|
|
||||||
export const generateRandomNumber = () => {
|
export const generateRandomNumber = () => {
|
||||||
// 0x100000000
|
// 16: 0x1000;32:0x100000000
|
||||||
return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
|
return Math.floor(Math.random() * 0x100000000);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user