From 378c86427756d3de7ace3297d04c32f4d9e023e8 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 25 Jun 2025 16:45:29 +0800 Subject: [PATCH] perf: email quote, text/plain --- src/actions/EmailActions.js | 4 ++-- src/config.js | 2 +- src/hooks/useEmail.js | 14 +++++--------- src/utils/indexedDB.js | 14 +++++++------- src/views/NewEmail.jsx | 9 +++++---- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/actions/EmailActions.js b/src/actions/EmailActions.js index ddc5008..4885a54 100644 --- a/src/actions/EmailActions.js +++ b/src/actions/EmailActions.js @@ -1,5 +1,5 @@ import { fetchJSON, postForm, postJSON } from '@/utils/request'; -import { API_HOST, API_HOST_V3, DATE_FORMAT, DATEEND_FORMAT, DATETIME_FORMAT, EMAIL_HOST } from '@/config'; +import { API_HOST, API_HOST_V3, DATE_FORMAT, DATEEND_FORMAT, DATETIME_FORMAT, EMAIL_HOST, EMAIL_HOST_v3 } from '@/config'; import { buildTree, groupBy, isEmpty, objectMapper, omitEmpty, uniqWith } from '@/utils/commons'; import { readIndexDB, writeIndexDB } from '@/utils/indexedDB'; import dayjs from 'dayjs'; @@ -455,7 +455,7 @@ export const getReminderEmailTemplateAction = async (params = { coli_sn: 0, lgc: * @param {boolean} [isDraft=false] - Whether the email is a draft. */ export const saveEmailDraftOrSendAction = async (body, isDraft = false) => { - const url = isDraft !== false ? `${API_HOST_V3}/email_draft_save` : `${EMAIL_HOST}/sendmail`; + const url = isDraft !== false ? `${API_HOST_V3}/email_draft_save` : `${EMAIL_HOST_v3}/sendmail`; const { attaList=[], atta, content, ...bodyData } = body; bodyData.ordertype = 227001; const formData = new FormData(); diff --git a/src/config.js b/src/config.js index 6f6c568..12b2f4b 100644 --- a/src/config.js +++ b/src/config.js @@ -9,7 +9,7 @@ export const API_HOST = 'http://202.103.68.144:8889/v2'; export const API_HOST_V3 = 'http://202.103.68.144:8889/v3'; // export const WS_URL = 'ws://202.103.68.144:8888'; -// export const EMAIL_HOST = 'http://202.103.68.231:888/service-mail'; +export const EMAIL_HOST_v3 = 'http://202.103.68.144:888/service-mail'; // export const WAI_HOST = 'http://47.83.248.120/api/v1'; // 香港服务器 export const WAI_HOST = 'http://47.254.53.81/api/v1'; // 美国服务器 // export const WAI_HOST = 'http://localhost:3031/api/v1'; // 美国服务器 diff --git a/src/hooks/useEmail.js b/src/hooks/useEmail.js index ff09eb5..99822e6 100644 --- a/src/hooks/useEmail.js +++ b/src/hooks/useEmail.js @@ -132,16 +132,12 @@ export const useEmailDetail = (mai_sn=0, data={}, oid=0, markRead=false) => { } const postEmailSaveOrSend = async (body, isDraft) => { - try { - const { id: savedID } = await saveEmailDraftOrSendAction(body, isDraft) - setMaiSN(savedID) - if (isDraft) { - refresh() - } - return savedID - } catch (error) { - console.error(error); + const { id: savedID } = await saveEmailDraftOrSendAction(body, isDraft) + setMaiSN(savedID) + if (isDraft) { + refresh() } + return savedID }; return { loading, mailData, orderDetail, postEmailResend, postEmailSaveOrSend } diff --git a/src/utils/indexedDB.js b/src/utils/indexedDB.js index 9c60007..5d57ec2 100644 --- a/src/utils/indexedDB.js +++ b/src/utils/indexedDB.js @@ -104,7 +104,7 @@ export const clearWebsocketLog = () => { export const createIndexedDBStore = (tables, database) => { var open = indexedDB.open(database, INDEXED_DB_VERSION) open.onupgradeneeded = function () { - console.log('readIndexDB onupgradeneeded', database, ) + // console.log('readIndexDB onupgradeneeded', database, ) var db = open.result // 数据库是否存在 for (const table of tables) { @@ -124,7 +124,7 @@ export const createIndexedDBStore = (tables, database) => { export const writeIndexDB = (rows, table, database) => { var open = indexedDB.open(database, INDEXED_DB_VERSION) open.onupgradeneeded = function () { - console.log('readIndexDB onupgradeneeded', table, ) + // console.log('readIndexDB onupgradeneeded', table, ) var db = open.result // 数据库是否存在 if (!db.objectStoreNames.contains(table)) { @@ -170,7 +170,7 @@ export const readIndexDB = (keys=null, table, database) => { return new Promise((resolve, reject) => { let openRequest = indexedDB.open(database) openRequest.onupgradeneeded = function () { - console.log('readIndexDB onupgradeneeded', table, ) + // console.log('readIndexDB onupgradeneeded', table, ) var db = openRequest.result // 数据库是否存在 if (!db.objectStoreNames.contains(table)) { @@ -208,7 +208,7 @@ export const readIndexDB = (keys=null, table, database) => { // console.log(`💾Found record with key ${key}:`, result); innerResolve([key, result]); // Resolve with [key, data] tuple } else { - console.log(`No record found with key ${key}.`); + // console.log(`No record found with key ${key}.`); innerResolve(void 0); // Resolve with undefined for non-existent keys } }; @@ -241,7 +241,7 @@ export const readIndexDB = (keys=null, table, database) => { // console.log(`💾Found record with key ${keys}:`, result); resolve(result); } else { - console.log(`No record found with key ${keys}.`); + // console.log(`No record found with key ${keys}.`); resolve(); } }; @@ -258,10 +258,10 @@ export const readIndexDB = (keys=null, table, database) => { allData.forEach(item => { resultMap.set(item.key, item); }); - console.log(`💾Found all records:`, resultMap); + // console.log(`💾Found all records:`, resultMap); resolve(resultMap); } else { - console.log(`No records found.`); + // console.log(`No records found.`); resolve(resultMap); // Resolve with an empty Map if no records } }; diff --git a/src/views/NewEmail.jsx b/src/views/NewEmail.jsx index 8e7e43d..6813f7f 100644 --- a/src/views/NewEmail.jsx +++ b/src/views/NewEmail.jsx @@ -70,7 +70,7 @@ const generateQuoteContent = (mailData, isRichText = true) => { return isRichText ? html : parseHTMLText(html) } -const generateMailContent = (mailData) => `${mailData.content}
` +const generateMailContent = (mailData) => mailData.info?.MAI_ContentType === 'text/html' ? `${mailData.content}
` : `

${mailData.content.replace(/\r\n/g, '
')}

` /** * 独立窗口编辑器 @@ -260,7 +260,7 @@ const NewEmail = () => { mai_sn: pageParam.quoteid, ..._form2 } - readyToInitialContent = '
'+ generateMailContent(mailData) + readyToInitialContent = generateMailContent(mailData) setFileList(mailData.attachments.map(ele => ({ uid: ele.ATI_SN, name: ele.ATI_Name, url: ele.ATI_ServerFile, fullPath: `${EMAIL_ATTA_HOST}${ele.ATI_ServerFile}` }))) break case 'new': @@ -271,8 +271,9 @@ const NewEmail = () => { subject: `${info.MAI_Subject || templateFormValues.subject || ''}`, ..._form2, } - readyToInitialContent = generateMailContent({ content: templateContent.bodycontent || readyToInitialContent || `
${signatureBody}` || '' }) - setFileList(mailData.attachments.map(ele => ({ uid: ele.ATI_SN, name: ele.ATI_Name, url: ele.ATI_ServerFile, fullPath: `${EMAIL_ATTA_HOST}${ele.ATI_ServerFile}` }))) + readyToInitialContent = generateMailContent({ content: templateContent.bodycontent || readyToInitialContent || `


${signatureBody}` || '' }) + // setFileList(mailData.attachments.map(ele => ({ uid: ele.ATI_SN, name: ele.ATI_Name, url: ele.ATI_ServerFile, fullPath: `${EMAIL_ATTA_HOST}${ele.ATI_ServerFile}` }))) + setIsRichText(true) break default: