diff --git a/mail-vue/src/components/email-scroll/index.vue b/mail-vue/src/components/email-scroll/index.vue index afaa04f..164ed05 100644 --- a/mail-vue/src/components/email-scroll/index.vue +++ b/mail-vue/src/components/email-scroll/index.vue @@ -25,7 +25,7 @@
- +
@@ -274,18 +274,26 @@ function htmlToText(email) { tempDiv.innerHTML = email.content; const scriptsAndStyles = tempDiv.querySelectorAll('script, style, title'); scriptsAndStyles.forEach(el => el.remove()); - const text = tempDiv.textContent || tempDiv.innerText || ''; - return text.replace(/\s+/g, ' ').trim(); + let text = tempDiv.textContent || tempDiv.innerText || ''; + text = text.replace(/\s+/g, ' ').trim(); + return cleanSpace(text) } if (email.text) { - return email.text + return cleanSpace(email.text) } else { return '' } } +function cleanSpace(text) { + return text + .replace(/[\u200B-\u200F\uFEFF]/g, '') // 移除零宽空格、ZWNJ、ZWJ、LRM、RLM、BOM + .replace(/\s+/g, ' ') // 多空白合并成一个空格 + .trim(); +} + function starChange(email) { diff --git a/mail-vue/src/components/shadow-html/index.vue b/mail-vue/src/components/shadow-html/index.vue index 5fba995..f02c3c2 100644 --- a/mail-vue/src/components/shadow-html/index.vue +++ b/mail-vue/src/components/shadow-html/index.vue @@ -32,8 +32,17 @@ function loadFontInShadow() { } function updateContent() { - if (!shadowRoot) return + if (!shadowRoot) return; + // 1. 提取 的 style 属性(如果存在) + const bodyStyleRegex = /]*style="([^"]*)"[^>]*>/i; + const bodyStyleMatch = props.html.match(bodyStyleRegex); + const bodyStyle = bodyStyleMatch ? bodyStyleMatch[1] : ''; + + // 2. 移除 标签(保留内容) + const cleanedHtml = props.html.replace(/<\/?body[^>]*>/gi, ''); + + // 3. 将 body 的 style 应用到 .shadow-content shadowRoot.innerHTML = `
- ${props.html} + ${cleanedHtml}
- ` + `; } function autoScale() { @@ -109,6 +118,7 @@ onMounted(() => { shadowRoot = container.value.attachShadow({ mode: 'open' }) updateContent() autoScale() + console.log(props.html) }) watch(() => props.html, () => { diff --git a/mail-vue/src/layout/main/index.vue b/mail-vue/src/layout/main/index.vue index 5c652ab..47c8994 100644 --- a/mail-vue/src/layout/main/index.vue +++ b/mail-vue/src/layout/main/index.vue @@ -96,7 +96,7 @@ const handleResize = () => { .main-box-show { display: grid; - grid-template-columns: 250px 1fr; + grid-template-columns: 260px 1fr; height: calc(100% - 60px); @media (max-width: 1200px) { grid-template-columns: 250px 1fr; diff --git a/mail-vue/src/views/login/index.vue b/mail-vue/src/views/login/index.vue index dcd60c5..9f5f5e9 100644 --- a/mail-vue/src/views/login/index.vue +++ b/mail-vue/src/views/login/index.vue @@ -11,8 +11,8 @@
{{settingStore.settings.title}} - 请输入你的账号信息以开始使用邮箱系统 - 请输入你的账号密码以开始注册邮箱系统 + 请输入账号信息以开始使用邮箱系统 + 请输入账号密码以开始注册邮箱系统