chore: support editing the model repoID, filename, model path

This commit is contained in:
jialin
2024-12-10 15:43:29 +08:00
parent acf99a6a9e
commit f64e696f7a
12 changed files with 122 additions and 43 deletions
@@ -66,8 +66,10 @@ const RawAudioPlayer: React.FC<AudioPlayerProps> = forwardRef((props, ref) => {
audioRef.current.addEventListener('loadeddata', () => {
initEnvents();
initAudioContext();
generateVisualData();
if (!audioContext.current) {
initAudioContext();
generateVisualData();
}
props.onLoadedData?.();
});
@@ -107,12 +109,6 @@ const RawAudioPlayer: React.FC<AudioPlayerProps> = forwardRef((props, ref) => {
});
};
const handleAudioOnPlay = () => {
audioRef.current?.play();
};
const handleLoadedMetadata = () => {};
useImperativeHandle(ref, () => ({
play: () => {
audioRef.current?.play();
@@ -124,6 +120,8 @@ const RawAudioPlayer: React.FC<AudioPlayerProps> = forwardRef((props, ref) => {
useEffect(() => {
if (audioRef.current) {
console.log('audioRef.current', audioRef.current, props.url);
initEnvents();
}
return () => {
if (audioContext.current) {
@@ -150,12 +148,15 @@ const RawAudioPlayer: React.FC<AudioPlayerProps> = forwardRef((props, ref) => {
return (
<audio
width={props.width || 300}
height={props.height || 40}
controls
autoPlay={autoplay}
src={props.url}
ref={audioRef}
style={{
position: 'absolute',
left: '-9999px',
opacity: 0
}}
preload="metadata"
></audio>
);
@@ -0,0 +1,4 @@
.dropdown-button.middle {
height: 28px;
width: 28px;
}
+10 -2
View File
@@ -1,8 +1,10 @@
import { MoreOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button, Dropdown, Tooltip, type MenuProps } from 'antd';
import classNames from 'classnames';
import _ from 'lodash';
import { memo } from 'react';
import './index.less';
interface DropdownButtonsProps {
items: MenuProps['items'];
@@ -12,7 +14,7 @@ interface DropdownButtonsProps {
const DropdownButtons: React.FC<DropdownButtonsProps> = ({
items,
size = 'small',
size = 'middle',
onSelect
}) => {
const intl = useIntl();
@@ -81,12 +83,18 @@ const DropdownButtons: React.FC<DropdownButtonsProps> = ({
key="leftButton"
>
<Button
className={classNames('dropdown-button', size)}
onClick={handleButtonClick}
size={size}
icon={_.head(items)?.icon}
></Button>
</Tooltip>,
<Button icon={<MoreOutlined />} size={size} key="menu"></Button>
<Button
icon={<MoreOutlined />}
size={size}
key="menu"
className={classNames('dropdown-button', size)}
></Button>
]}
></Dropdown.Button>
)}
@@ -62,14 +62,6 @@ const TableRow: React.FC<
}
}, [rowSelection]);
// useEffect(() => {
// if (expandedRowKeys?.includes(record[rowKey])) {
// setExpanded(true);
// } else {
// setExpanded(false);
// }
// }, [expandedRowKeys]);
useEffect(() => {
return () => {
if (pollTimer.current) {
@@ -160,8 +152,6 @@ const TableRow: React.FC<
pollTimer.current = setInterval(() => {
handlePolling();
}, 1000);
} else {
handleLoadChildren();
}
};
@@ -179,6 +169,20 @@ const TableRow: React.FC<
}
};
useEffect(() => {
if (expandedRowKeys?.includes(record[rowKey])) {
setExpanded(true);
} else {
setExpanded(false);
}
}, [expandedRowKeys]);
useEffect(() => {
if (expanded) {
handleLoadChildren();
}
}, [expanded]);
useEffect(() => {
if (!firstLoad && expanded) {
cacheDataListRef.current = childrenData;
+14 -1
View File
@@ -64,6 +64,7 @@ const SpeechItem: React.FC<SpeechContentProps> = (props) => {
}, [ref.current]);
const handleOnAnalyse = useCallback((data: any, analyser: any) => {
console.log('data+++++++++++++++++=:', data);
setAudioChunks((pre: any) => {
return {
data: data,
@@ -88,6 +89,7 @@ const SpeechItem: React.FC<SpeechContentProps> = (props) => {
const handleOnAudioprocess = useCallback(
(current: number) => {
console.log('current:', current);
throttleUpdateCurrentTime(current);
},
[throttleUpdateCurrentTime]
@@ -119,7 +121,7 @@ const SpeechItem: React.FC<SpeechContentProps> = (props) => {
};
const handleReady = useCallback((duration: number) => {
console.log('duration:', duration);
console.log('ready+++++++++++++++', duration);
setDuration(duration);
}, []);
@@ -159,6 +161,17 @@ const SpeechItem: React.FC<SpeechContentProps> = (props) => {
onAudioprocess={handleOnAudioprocess}
ref={ref}
></AudioPlayer>
{/* <RawAudioPlayer
{...props}
url={props.audioUrl}
onReady={handleReady}
onEnded={handleOnFinish}
onPlay={handleOnPlay}
onPause={handleOnPause}
onAnalyse={handleOnAnalyse}
onAudioProcess={handleOnAudioprocess}
ref={ref}
></RawAudioPlayer> */}
{isPlay && (
<AudioAnimation
maxBarCount={100}