fix: playground parameters area resizable

This commit is contained in:
jialin
2025-05-20 19:33:10 +08:00
parent 174f93fe11
commit 1c11e73ff8
11 changed files with 82 additions and 21 deletions
@@ -95,7 +95,7 @@ export default function useChatCompletion(
};
const handleStopConversation = () => {
controllerRef.current?.abort?.();
controllerRef.current?.abort?.('stop');
setLoading(false);
setTokenResult(null);
};
@@ -117,7 +117,7 @@ export default function useChatCompletion(
const { current, parameters, system } = params;
controllerRef.current?.abort?.();
controllerRef.current?.abort?.('cancel');
controllerRef.current = new AbortController();
const signal = controllerRef.current.signal;
currentMessageRef.current = current
@@ -0,0 +1,20 @@
import breakpoints from '@/config/breakpoints';
import useWindowResize from '@/hooks/use-window-resize';
import { useEffect } from 'react';
export default function useCollapseLayout(options: {
handler: () => void;
triggeredRef: {
collapse: boolean;
};
}) {
const { size } = useWindowResize();
useEffect(() => {
if (size.width < breakpoints.lg) {
if (!options.triggeredRef?.collapse) {
options.handler();
}
}
}, [size.width]);
}
+4 -4
View File
@@ -107,7 +107,7 @@ export default function useTextImage(props: any) {
});
setImageList(newImageList);
requestToken.current?.abort?.();
requestToken.current?.abort?.('cancel');
requestToken.current = new AbortController();
let result: any = {};
@@ -172,7 +172,7 @@ export default function useTextImage(props: any) {
});
} catch (error) {
console.log('error:', error);
requestToken.current?.abort?.();
requestToken.current?.abort?.('cancel');
setImageList([]);
} finally {
setLoading(false);
@@ -186,14 +186,14 @@ export default function useTextImage(props: any) {
};
const handleStopConversation = () => {
requestToken.current?.abort?.();
requestToken.current?.abort?.('stop');
setImageList([]);
setLoading(false);
};
useEffect(() => {
return () => {
requestToken.current?.abort?.();
requestToken.current?.abort?.('cancel');
};
}, []);