|
|
|
@ -1,13 +1,13 @@
|
|
|
|
|
import { fetchJSON, postForm } from '@/utils/request';
|
|
|
|
|
import { API_HOST, EMAIL_HOST } from '@/config';
|
|
|
|
|
|
|
|
|
|
const parseHTMLString = (html) => {
|
|
|
|
|
const parseHTMLString = (html, needText = false) => {
|
|
|
|
|
const parser = new DOMParser()
|
|
|
|
|
const doc = parser.parseFromString(html, 'text/html')
|
|
|
|
|
let bodyContent = doc.body.innerHTML
|
|
|
|
|
// bodyContent = bodyContent.replace(/<img/g, '<img onerror="this.onerror=null;this.src=\'https://hiana-crm.oss-accelerate.aliyuncs.com/WAMedia/afe412d4-3acf-4e79-a623-048aeb4d696a.png\';"')
|
|
|
|
|
|
|
|
|
|
return bodyContent
|
|
|
|
|
const bodyText = (doc.body.innerText);
|
|
|
|
|
return needText ? { bodyContent, bodyText } : bodyContent
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -84,9 +84,12 @@ export const getEmailDetailAction = async (params) => {
|
|
|
|
|
const delLinefeed = mailType === 'text/html' ? (result.MailContent||'').includes('<html') ? true : false : true;
|
|
|
|
|
const cleanContent = (result.MailContent || '').replace(/\r\n/g, delLinefeed ? '' : '<br>');
|
|
|
|
|
|
|
|
|
|
const { bodyContent, bodyText } = mailType === 'text/html' ? parseHTMLString(cleanContent, true) : { bodyContent: '', bodyText: '' };
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
info: { ...encodeEmailInfo(result.MailInfo?.[0] || {}), mailType },
|
|
|
|
|
content: mailType === 'text/html' ? parseHTMLString(cleanContent) : result.MailContent || '',
|
|
|
|
|
content: mailType === 'text/html' ? bodyContent : result.MailContent || '',
|
|
|
|
|
abstract: bodyText || result.MailContent || '',
|
|
|
|
|
attachments: result?.AttachList || [],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|