fix: keep latest image quality params in canvas send payload
This commit is contained in:
parent
afd231dde0
commit
b3ce87ca2b
@ -808,10 +808,13 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
||||
const [videoSlotUploading, setVideoSlotUploading] = useState<number | null>(null);
|
||||
const [lastImageModelId, setLastImageModelId] = useState<string | null>(null);
|
||||
const [lastVideoModelId, setLastVideoModelId] = useState<string | null>(null);
|
||||
const imageParamsRef = useRef(imageParams);
|
||||
const videoParamsRef = useRef(videoParams);
|
||||
|
||||
// 🆕 保存图片参数到 localStorage
|
||||
const handleImageParamsChange = (params: ImageGenerationParams) => {
|
||||
setImageParams(params);
|
||||
imageParamsRef.current = params;
|
||||
try {
|
||||
localStorage.setItem("canvas-image-params", JSON.stringify(params));
|
||||
} catch (e) {
|
||||
@ -825,7 +828,11 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
||||
const saved = localStorage.getItem("canvas-image-params");
|
||||
if (saved) {
|
||||
const parsed = JSON.parse(saved);
|
||||
setImageParams(prev => ({ ...prev, ...parsed }));
|
||||
setImageParams((prev) => {
|
||||
const next = { ...prev, ...parsed };
|
||||
imageParamsRef.current = next;
|
||||
return next;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to load image params:", e);
|
||||
@ -834,6 +841,7 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
||||
|
||||
const handleVideoParamsChange = (params: VideoGenerationParams) => {
|
||||
setVideoParams(params);
|
||||
videoParamsRef.current = params;
|
||||
try {
|
||||
localStorage.setItem("canvas-video-params", JSON.stringify(params));
|
||||
} catch (e) {
|
||||
@ -845,7 +853,9 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
||||
try {
|
||||
const saved = localStorage.getItem("canvas-video-params");
|
||||
if (saved) {
|
||||
setVideoParams(JSON.parse(saved));
|
||||
const parsed = JSON.parse(saved);
|
||||
setVideoParams(parsed);
|
||||
videoParamsRef.current = parsed;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to load video params:", e);
|
||||
@ -1103,10 +1113,14 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
||||
}
|
||||
|
||||
if (parsed.imageParams && typeof parsed.imageParams === "object") {
|
||||
setImageParams((prev) => ({
|
||||
...prev,
|
||||
...parsed.imageParams,
|
||||
}));
|
||||
setImageParams((prev) => {
|
||||
const next = {
|
||||
...prev,
|
||||
...parsed.imageParams,
|
||||
};
|
||||
imageParamsRef.current = next;
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
@ -1584,8 +1598,6 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
||||
}, [isDetailGenerationMode]);
|
||||
|
||||
const currentModelIdRef = useRef(selectedModelId);
|
||||
const imageParamsRef = useRef(imageParams);
|
||||
const videoParamsRef = useRef(videoParams);
|
||||
const isVideoModelRef = useRef(isVideoModel);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user