fix bug: 深色模式对话导出渲染不正确

This commit is contained in:
eeee0717 2025-02-25 17:36:47 +08:00 committed by 亢奋猫
parent 653b133327
commit b04f02ea96

View File

@ -306,7 +306,18 @@ export const captureScrollableDiv = async (divRef: React.RefObject<HTMLDivElemen
allowTaint: true, // Allow cross-origin images
logging: false, // Disable logging
imageTimeout: 0, // Disable image timeout
backgroundColor: null,
onclone: (clonedDoc) => {
// 克隆时保留原始样式
if (div.id) {
const clonedDiv = clonedDoc.querySelector(`#${div.id}`) as HTMLElement
if (clonedDiv) {
const computedStyle = getComputedStyle(div)
clonedDiv.style.backgroundColor = computedStyle.backgroundColor
clonedDiv.style.color = computedStyle.color
}
}
// Ensure all images in cloned document are loaded
const images = clonedDoc.getElementsByTagName('img')
return Promise.all(