fix: image display new image

This commit is contained in:
jialin
2025-01-15 21:37:28 +08:00
parent 4240bad627
commit c599cab14a
3 changed files with 14 additions and 31 deletions
+5 -4
View File
@@ -79,7 +79,7 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = ({
); );
const getTransformLineWidth = useCallback((lineWidth: number) => { const getTransformLineWidth = useCallback((lineWidth: number) => {
return lineWidth; return lineWidth / autoScale.current;
}, []); }, []);
const setCanvasTransformOrigin = (e: React.MouseEvent<HTMLCanvasElement>) => { const setCanvasTransformOrigin = (e: React.MouseEvent<HTMLCanvasElement>) => {
@@ -518,7 +518,7 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = ({
if (strokesRef.current.length) { if (strokesRef.current.length) {
redrawStrokes(strokesRef.current); redrawStrokes(strokesRef.current);
} }
}, [drawImage, onReset, redrawStrokes, imguid, imageStatus]); }, [drawImage, onReset, redrawStrokes, imguid]);
const updateZoom = (scaleChange: number, mouseX: number, mouseY: number) => { const updateZoom = (scaleChange: number, mouseX: number, mouseY: number) => {
const newScale = _.round(autoScale.current + scaleChange, 2); const newScale = _.round(autoScale.current + scaleChange, 2);
@@ -574,14 +574,15 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = ({
setTransform(); setTransform();
overlayCanvasRef.current!.style.transform = `scale(${autoScale.current})`; overlayCanvasRef.current!.style.transform = `scale(${autoScale.current})`;
canvasRef.current!.style.transform = `scale(${autoScale.current})`; canvasRef.current!.style.transform = `scale(${autoScale.current})`;
setActiveScale(autoScale.current);
updateCursorSize(); updateCursorSize();
redrawStrokes(strokesRef.current); redrawStrokes(strokesRef.current);
}; };
const handleBrushSizeChange = (value: number) => { const handleBrushSizeChange = (value: number) => {
setLineWidth(value); setLineWidth(value);
cursorRef.current!.style.width = `${value * autoScale.current}px`; cursorRef.current!.style.width = `${value}px`;
cursorRef.current!.style.height = `${value * autoScale.current}px`; cursorRef.current!.style.height = `${value}px`;
}; };
useEffect(() => { useEffect(() => {
initializeImage(); initializeImage();
@@ -274,32 +274,15 @@ const AddModal: React.FC<AddModalProps> = (props) => {
return groupList[item.value]; return groupList[item.value];
}); });
const list72B = const list = _.sortBy(res.items, 'size');
_.toLower(current.name) === 'qwen2.5'
? _.filter(res.items, (item: CatalogSpec) => {
return item.size === 72;
})
: [];
let defaultSpec: any = {}; const defaultSpec =
_.find(list, (item: CatalogSpec) => {
if (list72B.length) { return getDefaultQuant({
defaultSpec = category: _.get(current, 'categories.0', ''),
_.find(list72B, (item: CatalogSpec) => { quantOption: item.quantization
return getDefaultQuant({ });
category: _.get(current, 'categories.0', ''), }) || _.get(res.items, `0`, {});
quantOption: item.quantization
});
}) || _.get(list72B, `0`, {});
} else {
defaultSpec =
_.find(res.items, (item: CatalogSpec) => {
return getDefaultQuant({
category: _.get(current, 'categories.0', ''),
quantOption: item.quantization
});
}) || _.get(res.items, `0`, {});
}
selectSpecRef.current = defaultSpec; selectSpecRef.current = defaultSpec;
setSourceList(sources); setSourceList(sources);
@@ -218,7 +218,6 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
const imageFile = useMemo(() => { const imageFile = useMemo(() => {
if (!image) return null; if (!image) return null;
console.log('image>>>>>>>>>>>>>>', image);
return base64ToFile(image, 'image'); return base64ToFile(image, 'image');
}, [image]); }, [image]);
@@ -283,6 +282,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
try { try {
await form.current?.form?.validateFields(); await form.current?.form?.validateFields();
if (!parameters.model) return; if (!parameters.model) return;
doneImage.current = false;
const size: any = setImageSize(); const size: any = setImageSize();
setLoading(true); setLoading(true);
setMessageId(); setMessageId();
@@ -688,7 +688,6 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
}, [image, loading, imageStatus, handleOnSave, handleUpdateImageList]); }, [image, loading, imageStatus, handleOnSave, handleUpdateImageList]);
const handleOnImgClick = useCallback((item: any, isOrigin: boolean) => { const handleOnImgClick = useCallback((item: any, isOrigin: boolean) => {
console.log('item:99', item);
if (item.progress < 100) { if (item.progress < 100) {
return; return;
} }