mirror of
https://github.com/responsively-org/responsively-app
synced 2024-09-21 06:41:55 +00:00
Merge pull request #960 from Ryan0204/main
bug fix: screenshot in transparent website
This commit is contained in:
commit
3fd5e7e4be
1 changed files with 19 additions and 2 deletions
|
@ -22,11 +22,28 @@ export interface ScreenshotAllArgs {
|
|||
export interface ScreenshotResult {
|
||||
done: boolean;
|
||||
}
|
||||
|
||||
const captureImage = async (
|
||||
webContentsId: number
|
||||
): Promise<Electron.NativeImage | undefined> => {
|
||||
const Image = await webContents.fromId(webContentsId)?.capturePage();
|
||||
const WebContents = webContents.fromId(webContentsId);
|
||||
|
||||
const isExecuted = await WebContents?.executeJavaScript(`
|
||||
if (window.isExecuted) {
|
||||
true;
|
||||
}
|
||||
`);
|
||||
|
||||
if (!isExecuted) {
|
||||
await WebContents?.executeJavaScript(`
|
||||
const bgColor = window.getComputedStyle(document.body).backgroundColor;
|
||||
if (bgColor === 'rgba(0, 0, 0, 0)') {
|
||||
document.body.style.backgroundColor = 'white';
|
||||
}
|
||||
window.isExecuted = true;
|
||||
`);
|
||||
}
|
||||
|
||||
const Image = await WebContents?.capturePage();
|
||||
return Image;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue