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