feat: 附件上传前预览

dev/emitter
Lei OT 10 months ago
parent 7ec40fb669
commit 54c67d5428

@ -302,6 +302,7 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, fromUser, fromOrder, toEma
reader.onloadend = (e) => {
var dataURL = e.target.result;
var win = window.open("", "_blank");
win.document.body.style.margin = '0';
if (file.type.startsWith('image/')) {
win.document.write("<img src='" + e.target.result + "' />");
} else if (file.type.startsWith('text/') || file.type === 'application/html' || file.type === 'application/xhtml+xml') {
@ -311,14 +312,16 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, fromUser, fromOrder, toEma
iframe.style.height = '100%';
iframe.style.border = 'none';
win.document.body.appendChild(iframe);
win.document.body.style.margin = '0';
} else if (file.type === 'application/pdf') {
win.document.write("<iframe src='" + e.target.result + "' width='100%' height='100%' style=\"border:none\"></iframe>");
win.document.write("<iframe src='" + e.target.result + "' width='100%' height='100%' style=\"border:none\"></iframe>");
win.document.body.style.margin = '0';
} else if (file.type.startsWith('audio/')) {
win.document.write("<audio controls src='" + e.target.result + "'></audio>");
} else if (file.type.startsWith('video/')) {
win.document.write("<video controls src='" + e.target.result + "'></video>");
} else {
win.document.write("<p>Preview not available for this file type</p>");
win.document.write("<h2>Preview not available for this file type</h2>");
}
// win.document.write("<iframe src='" + dataURL + "' width='100%' height='100%' style=\"border:none\"></iframe>");
resolve(reader.result)

Loading…
Cancel
Save