修复微信二维码展示
This commit is contained in:
@@ -94,12 +94,40 @@ export async function extractQqQrState(page) {
|
||||
}
|
||||
|
||||
try {
|
||||
const qrVisible = await frame
|
||||
.locator('#qrlogin_img')
|
||||
.first()
|
||||
.isVisible()
|
||||
.catch(() => false)
|
||||
const bodyText = String(await frame.locator('body').textContent()).replace(/\s+/g, ' ').trim()
|
||||
const { qrVisible, bodyText } = await frame
|
||||
.evaluate(() => {
|
||||
const isVisible = (element) => {
|
||||
if (!(element instanceof HTMLElement)) {
|
||||
return false
|
||||
}
|
||||
|
||||
const style = window.getComputedStyle(element)
|
||||
const rect = element.getBoundingClientRect()
|
||||
return (
|
||||
style.display !== 'none' &&
|
||||
style.visibility !== 'hidden' &&
|
||||
style.opacity !== '0' &&
|
||||
rect.width > 0 &&
|
||||
rect.height > 0
|
||||
)
|
||||
}
|
||||
|
||||
const qrImage = document.querySelector('#qrlogin_img')
|
||||
const bodyText = String(document.body?.textContent || '').replace(/\s+/g, ' ').trim()
|
||||
|
||||
return {
|
||||
qrVisible:
|
||||
qrImage instanceof HTMLImageElement &&
|
||||
isVisible(qrImage) &&
|
||||
Number(qrImage.naturalWidth || 0) > 0 &&
|
||||
Number(qrImage.naturalHeight || 0) > 0,
|
||||
bodyText,
|
||||
}
|
||||
})
|
||||
.catch(() => ({
|
||||
qrVisible: false,
|
||||
bodyText: '',
|
||||
}))
|
||||
|
||||
return {
|
||||
visible: true,
|
||||
|
||||
Reference in New Issue
Block a user