Skip to content

Commit

Permalink
🐛 fix transparent bg
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Mar 6, 2024
1 parent 5b93c1c commit e168a34
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/utils/TGClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,20 +852,27 @@ class TGClient {
var scale = 1.5;
var option = {
debug: true,
backgroundColor: "white",
height: shareDom.scrollHeight * scale,
width: shareDom.scrollWidth * scale,
style: {
transform: "scale(" + scale + ")",
transformOrigin: "top left"
}
};
var pictures = shareDom.querySelectorAll("picture","div picture");
pictures.forEach(picture => {
var img = picture.querySelector("img");
if (img !== null) {
picture.replaceWith(img);
}
// 等待3s,让图片充分加载
await new Promise((resolve) => {
setTimeout(resolve, 3000);
});
var pictures = shareDom.querySelectorAll("picture");
if(pictures !== null && pictures.length > 0) {
pictures.forEach(picture => {
var img = picture.querySelector("img");
if(img !== null) {
picture.parentNode.replaceChild(img, picture);
}
});
}
var img = await modernScreenshot.domToPng(shareDom, option);
var buffer = new Uint8Array(atob(img.split(",")[1]).split("").map(function(item) {
return item.charCodeAt(0);
Expand All @@ -884,7 +891,7 @@ class TGClient {
});
alert("保存成功");
}
mhyWebBridge('${arg.callback}', {});
mhyWebBridge("${arg.callback}", {});
})();`;
await invoke("execute_js", { label: "mhy_client", js: executeJS });
return;
Expand Down

0 comments on commit e168a34

Please sign in to comment.