perf: 邮件内容: 图片点击预览

main
Lei OT 3 months ago
parent 22674fe498
commit 535aa38775

@ -1,3 +1,4 @@
import { POPUP_FEATURES } from '@/config'
import React, { useState, useEffect, useRef } from 'react' import React, { useState, useEffect, useRef } from 'react'
const EmailContent = ({ id, content: MailContent, className='', ...props }) => { const EmailContent = ({ id, content: MailContent, className='', ...props }) => {
@ -31,11 +32,12 @@ const EmailContent = ({ id, content: MailContent, className='', ...props }) => {
width: 900px; width: 900px;
max-width: 100%; max-width: 100%;
} }
img { img {
max-width: 90%; max-width: 90%;
height: auto; height: auto;
object-fit: contain; object-fit: contain;
} }
img:not(a img){ cursor: pointer;}
</style> </style>
</head> </head>
<body> <body>
@ -58,6 +60,15 @@ const EmailContent = ({ id, content: MailContent, className='', ...props }) => {
links.forEach((link) => { links.forEach((link) => {
link.setAttribute('target', '_blank') link.setAttribute('target', '_blank')
}) })
const imgs = doc.querySelectorAll('img:not(a img)')
imgs.forEach((img) => {
// open img in new tab
img.addEventListener('click', (e) => {
// e.preventDefault()
img.style.cursor = 'pointer'
window.open(img.src, img.src, POPUP_FEATURES)
})
})
} catch (e) { } catch (e) {
// console.error('Could not access iframe content due to Same-Origin Policy or other error:', e) // console.error('Could not access iframe content due to Same-Origin Policy or other error:', e)
} }

Loading…
Cancel
Save