fix: miss logs
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: rgba(255, 255, 255, 70%);
|
color: rgba(255, 255, 255, 100%);
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
|
|
||||||
.ant-btn:hover {
|
.ant-btn:hover {
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ant-btn {
|
.ant-btn {
|
||||||
background-color: rgba(71, 71, 71, 50%) !important;
|
background-color: rgba(71, 71, 71, 100%) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pages {
|
.pages {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { split, throttle } from 'lodash';
|
import { throttle } from 'lodash';
|
||||||
import qs from 'query-string';
|
import qs from 'query-string';
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
|
|
||||||
@@ -21,53 +21,52 @@ const useSetChunkFetch = () => {
|
|||||||
const readTextEventStreamData = async (
|
const readTextEventStreamData = async (
|
||||||
reader: ReadableStreamDefaultReader<Uint8Array>,
|
reader: ReadableStreamDefaultReader<Uint8Array>,
|
||||||
decoder: TextDecoder,
|
decoder: TextDecoder,
|
||||||
callback: (data: any) => void
|
callback: (data: any) => void,
|
||||||
|
delay = 200
|
||||||
) => {
|
) => {
|
||||||
const throttledCallback = throttle((data: any) => {
|
class BufferManager {
|
||||||
callback(data);
|
private buffer: any[] = [];
|
||||||
}, 200);
|
|
||||||
|
public add(data: any) {
|
||||||
|
this.buffer.push(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public flush() {
|
||||||
|
if (this.buffer.length > 0) {
|
||||||
|
const currentBuffer = [...this.buffer];
|
||||||
|
this.buffer = [];
|
||||||
|
currentBuffer.forEach((item) => callback(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getBuffer() {
|
||||||
|
return this.buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const bufferManager = new BufferManager();
|
||||||
|
|
||||||
|
const throttledCallback = throttle(() => {
|
||||||
|
bufferManager.flush();
|
||||||
|
}, delay);
|
||||||
|
|
||||||
|
let isReading = true;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const { done, value } = await reader.read();
|
const { done, value } = await reader.read();
|
||||||
|
|
||||||
if (done) {
|
if (done) {
|
||||||
|
isReading = false;
|
||||||
|
bufferManager.flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const chunk = decoder.decode(value, { stream: true });
|
try {
|
||||||
throttledCallback(chunk);
|
const chunk = decoder.decode(value, { stream: true });
|
||||||
}
|
bufferManager.add(chunk);
|
||||||
};
|
throttledCallback();
|
||||||
|
} catch (error) {
|
||||||
const readTextEventStreamDataByLine = async (
|
console.log('error:', error);
|
||||||
reader: ReadableStreamDefaultReader<Uint8Array>,
|
}
|
||||||
decoder: TextDecoder,
|
|
||||||
callback: (data: any) => void
|
|
||||||
) => {
|
|
||||||
const { done, value } = await reader.read();
|
|
||||||
if (done) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bufferCacheRef.current += decoder.decode(value, { stream: true });
|
|
||||||
const lines = split(bufferCacheRef.current, /\r?\n/);
|
|
||||||
bufferCacheRef.current = lines.pop();
|
|
||||||
for (const line of lines) {
|
|
||||||
callback(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
await readTextEventStreamDataByLine(reader, decoder, callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
const readTextEventStreamDataByLineWithBuffer = async (
|
|
||||||
reader: ReadableStreamDefaultReader<Uint8Array>,
|
|
||||||
decoder: TextDecoder,
|
|
||||||
callback: (data: any) => void
|
|
||||||
) => {
|
|
||||||
await readTextEventStreamDataByLine(reader, decoder, callback);
|
|
||||||
|
|
||||||
if (bufferCacheRef.current.length > 0) {
|
|
||||||
callback(bufferCacheRef.current);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,13 @@ export const imageSizeOptions: {
|
|||||||
width: 0,
|
width: 0,
|
||||||
height: 0
|
height: 0
|
||||||
},
|
},
|
||||||
{ label: '512x512', value: '512x512', width: 512, height: 512 },
|
{ label: '512x512(1:1)', value: '512x512', width: 512, height: 512 },
|
||||||
|
{ label: '512x1024(1:2)', value: '512x1024', width: 512, height: 1024 },
|
||||||
{ label: '768x1024(3:4)', value: '768x1024', width: 768, height: 1024 },
|
{ label: '768x1024(3:4)', value: '768x1024', width: 768, height: 1024 },
|
||||||
{ label: '1024x768(4:3)', value: '1024x768', width: 1024, height: 768 },
|
{ label: '1024x768(4:3)', value: '1024x768', width: 1024, height: 768 },
|
||||||
{ label: '1024x1024', value: '1024x1024', width: 1024, height: 1024 }
|
{ label: '1024x576(16:9)', value: '1024x768', width: 1024, height: 576 },
|
||||||
|
{ label: '576x1024(9:16)', value: '1024x768', width: 576, height: 1024 },
|
||||||
|
{ label: '1024x1024(1:1)', value: '1024x1024', width: 1024, height: 1024 }
|
||||||
];
|
];
|
||||||
|
|
||||||
export const TTSParamsConfig: ParamsSchema[] = [
|
export const TTSParamsConfig: ParamsSchema[] = [
|
||||||
|
|||||||
Reference in New Issue
Block a user