fix(share): 太阳码区域 flex 居中
This commit is contained in:
@@ -33,9 +33,9 @@ function supportsWxMiniProgramShare(): boolean {
|
|||||||
} catch { return false; }
|
} catch { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 模块级状态:避免构建压缩时变量名不一致导致 ReferenceError */
|
/** 模块级状态:避免构建压缩时变量名不一致导致 ReferenceError */
|
||||||
const _wp = { url: null as string | null, tick: 0 };
|
const _wp = { url: null as string | null, tick: 0 };
|
||||||
export function SharePage() {
|
export function SharePage() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { reportId } = useParams();
|
const { reportId } = useParams();
|
||||||
@@ -137,15 +137,20 @@ export function SharePage() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// html-to-image: 将 DOM 节点转为 PNG data URL
|
// html-to-image: 将 DOM 节点转为 PNG data URL
|
||||||
const dataUrl = await toPng(cardRef.current, {
|
// 注意:不能用 cacheBust,会破坏 blob: URL
|
||||||
cacheBust: true,
|
const dataUrl = await Promise.race([
|
||||||
pixelRatio: 2, // 2x 高清
|
toPng(cardRef.current, {
|
||||||
backgroundColor: "#ffffff",
|
pixelRatio: 2, // 2x 高清
|
||||||
style: {
|
backgroundColor: "#ffffff",
|
||||||
// 确保截图时移除圆角阴影的裁切问题
|
style: {
|
||||||
borderRadius: "0",
|
// 确保截图时移除圆角阴影的裁切问题
|
||||||
},
|
borderRadius: "0",
|
||||||
});
|
},
|
||||||
|
}),
|
||||||
|
new Promise<null>((_, reject) =>
|
||||||
|
setTimeout(() => reject(new Error("截图超时")), 10000)
|
||||||
|
),
|
||||||
|
]);
|
||||||
return dataUrl;
|
return dataUrl;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("生成图片失败:", err);
|
console.error("生成图片失败:", err);
|
||||||
@@ -675,6 +680,9 @@ function ShareCardContent({
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
paddingTop: "20px",
|
paddingTop: "20px",
|
||||||
borderTop: "1px dashed #e5e7eb",
|
borderTop: "1px dashed #e5e7eb",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
@@ -682,6 +690,7 @@ function ShareCardContent({
|
|||||||
alt="扫码下载孕育无忧"
|
alt="扫码下载孕育无忧"
|
||||||
crossOrigin="anonymous"
|
crossOrigin="anonymous"
|
||||||
style={{
|
style={{
|
||||||
|
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 200,
|
height: 200,
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
|
|||||||
Reference in New Issue
Block a user