fix: do not init audio model
This commit is contained in:
@@ -89,7 +89,7 @@ const useSetChunkFetch = () => {
|
||||
|
||||
let isReading = true;
|
||||
|
||||
while (true) {
|
||||
while (isReading) {
|
||||
const { done, value } = await reader.read();
|
||||
|
||||
if (done) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { message } from 'antd';
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
export default function useDownloadStream() {
|
||||
const chunkRequedtRef = useRef<any>(null);
|
||||
const chunkRequestRef = useRef<any>(null);
|
||||
const logParseWorker = useRef<any>(null);
|
||||
const clearScreen = useRef(false);
|
||||
const filename = useRef('log');
|
||||
@@ -26,19 +26,13 @@ export default function useDownloadStream() {
|
||||
};
|
||||
|
||||
const updateContent = (data: string, options?: HandlerOptions) => {
|
||||
const { isComplete } = options || {};
|
||||
|
||||
downloadNotificationRef.current?.({
|
||||
...options,
|
||||
duration: isComplete ? 1 : null,
|
||||
filename: filename.current
|
||||
});
|
||||
const { isComplete, percent } = options || {};
|
||||
|
||||
logParseWorker.current?.postMessage({
|
||||
inputStr: data,
|
||||
page: 1,
|
||||
reset: clearScreen.current,
|
||||
isComplete: isComplete,
|
||||
percent: percent,
|
||||
chunked: false
|
||||
});
|
||||
clearScreen.current = false;
|
||||
@@ -72,13 +66,9 @@ export default function useDownloadStream() {
|
||||
downloadNotificationRef.current = props.downloadNotification;
|
||||
const { params, url } = props;
|
||||
|
||||
downloadNotificationRef.current?.({
|
||||
filename: filename.current
|
||||
});
|
||||
chunkRequestRef.current?.current?.abort?.();
|
||||
|
||||
chunkRequedtRef.current?.current?.abort?.();
|
||||
|
||||
chunkRequedtRef.current = setChunkFetch({
|
||||
chunkRequestRef.current = setChunkFetch({
|
||||
url,
|
||||
params,
|
||||
watch: false,
|
||||
@@ -86,6 +76,11 @@ export default function useDownloadStream() {
|
||||
errorHandler: handleError,
|
||||
handler: updateContent
|
||||
});
|
||||
downloadNotificationRef.current?.({
|
||||
filename: filename.current,
|
||||
duration: null,
|
||||
chunkRequestRef: chunkRequestRef.current
|
||||
});
|
||||
} catch (error) {
|
||||
//
|
||||
downloadNotificationRef.current?.({
|
||||
@@ -108,8 +103,24 @@ export default function useDownloadStream() {
|
||||
);
|
||||
|
||||
logParseWorker.current.onmessage = (event: any) => {
|
||||
const { result } = event.data;
|
||||
downloadFile(result);
|
||||
const { result, isComplete, percent } = event.data;
|
||||
|
||||
const isAborted = chunkRequestRef.current?.current?.signal?.aborted;
|
||||
if (!isComplete && !isAborted) {
|
||||
downloadNotificationRef.current?.({
|
||||
percent: percent,
|
||||
duration: null,
|
||||
filename: filename.current,
|
||||
chunkRequestRef: chunkRequestRef.current
|
||||
});
|
||||
} else if (isComplete && !isAborted) {
|
||||
downloadNotificationRef.current?.({
|
||||
duration: 1,
|
||||
percent: 100,
|
||||
filename: filename.current
|
||||
});
|
||||
downloadFile(result);
|
||||
}
|
||||
};
|
||||
|
||||
return () => {
|
||||
|
||||
Reference in New Issue
Block a user