|
|
|
@ -297,14 +297,24 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, fromUser, fromOrder, toEma
|
|
|
|
|
setFileList(newFileList);
|
|
|
|
|
},
|
|
|
|
|
onPreview: (file) => {
|
|
|
|
|
// console.log('pn preview', file);
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
const reader = new FileReader();
|
|
|
|
|
reader.onloadend = (e) => {
|
|
|
|
|
var dataURL = e.target.result;
|
|
|
|
|
if (file.size > 1.5 * 1024 * 1024) {
|
|
|
|
|
message.info('附件太大,无法预览')
|
|
|
|
|
// message.info('附件太大,无法预览, 请下载后查看')
|
|
|
|
|
// var downloadLink = document.createElement('a');
|
|
|
|
|
// downloadLink.href = e.target.result;
|
|
|
|
|
// downloadLink.download = file.name;
|
|
|
|
|
// downloadLink.click();
|
|
|
|
|
resolve(e.target.result);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var win = window.open("", "_blank");
|
|
|
|
|
win.document.body.style.margin = '0';
|
|
|
|
|
if (file.type.startsWith('image/')) {
|
|
|
|
|
win.document.write("<img src='" + e.target.result + "' />");
|
|
|
|
|
win.document.write("<img src='" + e.target.result + "' style=\"max-width: 100%;\" />");
|
|
|
|
|
} else if (file.type.startsWith('text/') || file.type === 'application/html' || file.type === 'application/xhtml+xml') {
|
|
|
|
|
var iframe = win.document.createElement('iframe');
|
|
|
|
|
iframe.srcdoc = e.target.result;
|
|
|
|
@ -318,9 +328,9 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, fromUser, fromOrder, toEma
|
|
|
|
|
win.document.write("<embed src='" + e.target.result + "' width='100%' height='100%' style=\"border:none\"></embed>");
|
|
|
|
|
win.document.body.style.margin = '0';
|
|
|
|
|
} else if (file.type.startsWith('audio/')) {
|
|
|
|
|
win.document.write("<audio controls src='" + e.target.result + "'></audio>");
|
|
|
|
|
win.document.write("<audio controls src='" + e.target.result + "' style=\"max-width: 100%;\"></audio>");
|
|
|
|
|
} else if (file.type.startsWith('video/')) {
|
|
|
|
|
win.document.write("<video controls src='" + e.target.result + "'></video>");
|
|
|
|
|
win.document.write("<video controls src='" + e.target.result + "' style=\"max-width: 100%;\"></video>");
|
|
|
|
|
} else {
|
|
|
|
|
win.document.write("<h2>Preview not available for this file type</h2>");
|
|
|
|
|
}
|
|
|
|
|