fix(style): image wraper full size
This commit is contained in:
@@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
.single-image {
|
.single-image {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
width: inherit;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -44,10 +44,6 @@ const SingleImage: React.FC<SingleImageProps> = (props) => {
|
|||||||
width: width,
|
width: width,
|
||||||
height: height
|
height: height
|
||||||
});
|
});
|
||||||
const [originSize, setOriginSize] = React.useState({
|
|
||||||
width: width,
|
|
||||||
height: height
|
|
||||||
});
|
|
||||||
|
|
||||||
const thumImgWrapStyle = React.useMemo(() => {
|
const thumImgWrapStyle = React.useMemo(() => {
|
||||||
return loading ? { width: '100%', height: '100%' } : {};
|
return loading ? { width: '100%', height: '100%' } : {};
|
||||||
@@ -76,7 +72,7 @@ const SingleImage: React.FC<SingleImageProps> = (props) => {
|
|||||||
newWidth = containerWidth;
|
newWidth = containerWidth;
|
||||||
newHeight = containerWidth / imageAspectRatio;
|
newHeight = containerWidth / imageAspectRatio;
|
||||||
}
|
}
|
||||||
|
console.log('size++++++++=', size, newWidth, newHeight);
|
||||||
setImgSize({
|
setImgSize({
|
||||||
width: newWidth,
|
width: newWidth,
|
||||||
height: newHeight
|
height: newHeight
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ const SpeechItem: React.FC<SpeechContentProps> = (props) => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="speech-item">
|
<div className="speech-item">
|
||||||
|
<div style={{}}></div>
|
||||||
<div
|
<div
|
||||||
className="wrapper"
|
className="wrapper"
|
||||||
style={{ height: 82, width: '100%' }}
|
style={{ height: 82, width: '100%' }}
|
||||||
@@ -127,7 +128,7 @@ const SpeechItem: React.FC<SpeechContentProps> = (props) => {
|
|||||||
onAudioprocess={handleOnAudioprocess}
|
onAudioprocess={handleOnAudioprocess}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
></AudioPlayer>
|
></AudioPlayer>
|
||||||
{/* {isPlay && (
|
{/* {!isPlay && (
|
||||||
<AudioAnimation
|
<AudioAnimation
|
||||||
maxBarCount={180}
|
maxBarCount={180}
|
||||||
height={82}
|
height={82}
|
||||||
|
|||||||
@@ -1,6 +1,40 @@
|
|||||||
import axiso from 'axios';
|
import axiso from 'axios';
|
||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
|
||||||
export default function useRequestToken() {
|
export default function useRequestToken() {
|
||||||
const { source } = axiso.CancelToken;
|
const { source } = axiso.CancelToken;
|
||||||
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useCancelToken() {
|
||||||
|
const { source } = axiso.CancelToken;
|
||||||
|
const requestToken = useRef<any>(null);
|
||||||
|
|
||||||
|
const updateCancelToken = () => {
|
||||||
|
if (requestToken.current) {
|
||||||
|
requestToken.current.cancel();
|
||||||
|
}
|
||||||
|
requestToken.current = source();
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancelRequest = () => {
|
||||||
|
if (requestToken.current) {
|
||||||
|
requestToken.current.cancel();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getCanceltToken = () => {
|
||||||
|
return requestToken.current.token;
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (requestToken.current) {
|
||||||
|
requestToken.current.cancel();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return { updateCancelToken, cancelRequest, getCanceltToken, source };
|
||||||
|
}
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ export default {
|
|||||||
'playground.image.prompt.random': 'Random Prompt',
|
'playground.image.prompt.random': 'Random Prompt',
|
||||||
'playground.audio.button.fast': 'Speed Up',
|
'playground.audio.button.fast': 'Speed Up',
|
||||||
'playground.audio.button.slow': 'Slow Down',
|
'playground.audio.button.slow': 'Slow Down',
|
||||||
|
'playground.audio.generating': 'Generating',
|
||||||
'playgorund.audio.voice.error':
|
'playgorund.audio.voice.error':
|
||||||
'Voices are unavailable. The model may still be initializing. Please refresh after a brief wait.'
|
'Voices are unavailable. The model may still be initializing. Please refresh after a brief wait.'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ export default {
|
|||||||
'playground.image.prompt.random': '随机提示词',
|
'playground.image.prompt.random': '随机提示词',
|
||||||
'playground.audio.button.fast': '快进',
|
'playground.audio.button.fast': '快进',
|
||||||
'playground.audio.button.slow': '慢放',
|
'playground.audio.button.slow': '慢放',
|
||||||
|
'playground.audio.generating': '生成中',
|
||||||
'playgorund.audio.voice.error':
|
'playgorund.audio.voice.error':
|
||||||
'声音无法使用。该模型可能仍在初始化。请稍候后刷新。'
|
'声音无法使用。该模型可能仍在初始化。请稍候后刷新。'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -410,6 +410,12 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
return null;
|
return null;
|
||||||
}, [size, intl]);
|
}, [size, intl]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
requestToken.current?.abort?.();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (size === 'custom') {
|
if (size === 'custom') {
|
||||||
form.current?.form?.setFieldsValue({
|
form.current?.form?.setFieldsValue({
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import CopyButton from '@/components/copy-button';
|
|||||||
import IconFont from '@/components/icon-font';
|
import IconFont from '@/components/icon-font';
|
||||||
import UploadAudio from '@/components/upload-audio';
|
import UploadAudio from '@/components/upload-audio';
|
||||||
import useOverlayScroller from '@/hooks/use-overlay-scroller';
|
import useOverlayScroller from '@/hooks/use-overlay-scroller';
|
||||||
|
import { useCancelToken } from '@/hooks/use-request-token';
|
||||||
import { readAudioFile } from '@/utils/load-audio-file';
|
import { readAudioFile } from '@/utils/load-audio-file';
|
||||||
import { SendOutlined } from '@ant-design/icons';
|
import { SendOutlined } from '@ant-design/icons';
|
||||||
import { useIntl, useSearchParams } from '@umijs/max';
|
import { useIntl, useSearchParams } from '@umijs/max';
|
||||||
@@ -56,7 +57,6 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [tokenResult, setTokenResult] = useState<any>(null);
|
const [tokenResult, setTokenResult] = useState<any>(null);
|
||||||
const [collapse, setCollapse] = useState(false);
|
const [collapse, setCollapse] = useState(false);
|
||||||
const controllerRef = useRef<any>(null);
|
|
||||||
const scroller = useRef<any>(null);
|
const scroller = useRef<any>(null);
|
||||||
const paramsRef = useRef<any>(null);
|
const paramsRef = useRef<any>(null);
|
||||||
const [audioPermissionOn, setAudioPermissionOn] = useState(true);
|
const [audioPermissionOn, setAudioPermissionOn] = useState(true);
|
||||||
@@ -67,6 +67,8 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
});
|
});
|
||||||
const [isRecording, setIsRecording] = useState(false);
|
const [isRecording, setIsRecording] = useState(false);
|
||||||
const formRef = useRef<any>(null);
|
const formRef = useRef<any>(null);
|
||||||
|
const { updateCancelToken, getCanceltToken, cancelRequest } =
|
||||||
|
useCancelToken();
|
||||||
|
|
||||||
const { initialize, updateScrollerPosition } = useOverlayScroller();
|
const { initialize, updateScrollerPosition } = useOverlayScroller();
|
||||||
const { initialize: innitializeParams } = useOverlayScroller();
|
const { initialize: innitializeParams } = useOverlayScroller();
|
||||||
@@ -88,7 +90,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleStopConversation = () => {
|
const handleStopConversation = () => {
|
||||||
controllerRef.current?.abort?.();
|
cancelRequest();
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -101,18 +103,22 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
setTokenResult(null);
|
setTokenResult(null);
|
||||||
setMessageList([]);
|
setMessageList([]);
|
||||||
|
|
||||||
controllerRef.current?.abort?.();
|
cancelRequest();
|
||||||
controllerRef.current = new AbortController();
|
updateCancelToken();
|
||||||
const signal = controllerRef.current.signal;
|
|
||||||
const params = {
|
const params = {
|
||||||
...parameters,
|
...parameters,
|
||||||
file: new File([audioData.data], audioData.name, {
|
file: new File([audioData.data], audioData.name, {
|
||||||
type: audioData.type
|
type: audioData.type
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
const result: any = await speechToText({
|
const result: any = await speechToText(
|
||||||
data: params
|
{
|
||||||
});
|
data: params
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cancelToken: getCanceltToken()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
setTokenResult({
|
setTokenResult({
|
||||||
@@ -242,9 +248,6 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
|
||||||
console.log('parameters:', parameters);
|
|
||||||
}, [parameters]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (scroller.current) {
|
if (scroller.current) {
|
||||||
@@ -315,32 +318,26 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={intl.formatMessage({
|
title={
|
||||||
id: 'playground.audio.button.generate'
|
loading
|
||||||
})}
|
? intl.formatMessage({
|
||||||
|
id: 'playground.audio.generating'
|
||||||
|
})
|
||||||
|
: intl.formatMessage({
|
||||||
|
id: 'playground.audio.button.generate'
|
||||||
|
})
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{loading ? (
|
{
|
||||||
<Button
|
|
||||||
disabled={!audioData}
|
|
||||||
type="primary"
|
|
||||||
shape="circle"
|
|
||||||
onClick={handleStopConversation}
|
|
||||||
icon={
|
|
||||||
<IconFont
|
|
||||||
type="icon-stop1"
|
|
||||||
className="font-size-14"
|
|
||||||
></IconFont>
|
|
||||||
}
|
|
||||||
></Button>
|
|
||||||
) : (
|
|
||||||
<Button
|
<Button
|
||||||
disabled={!audioData}
|
disabled={!audioData}
|
||||||
|
loading={loading}
|
||||||
type="primary"
|
type="primary"
|
||||||
shape="circle"
|
shape="circle"
|
||||||
onClick={handleOnGenerate}
|
onClick={handleOnGenerate}
|
||||||
icon={<SendOutlined></SendOutlined>}
|
icon={<SendOutlined></SendOutlined>}
|
||||||
></Button>
|
></Button>
|
||||||
)}
|
}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user