From 88925937518696115212aa00609e8ceb7eb78be9 Mon Sep 17 00:00:00 2001 From: 18154758993 <605281283@qq.com> Date: Thu, 4 Dec 2025 16:37:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=8F=91=E9=80=81=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../routine/NotificationManagement/index.vue | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/views/routine/NotificationManagement/index.vue b/src/views/routine/NotificationManagement/index.vue index 7a582d7..93c1783 100644 --- a/src/views/routine/NotificationManagement/index.vue +++ b/src/views/routine/NotificationManagement/index.vue @@ -236,7 +236,10 @@ export default { // 创建一个临时div来提取纯文本 const tempDiv = document.createElement('div') tempDiv.innerHTML = this.form.content - const plainText = tempDiv.textContent || tempDiv.innerText || '' + // 将可能存在的 a 标签转换为 markdown 链接,其他标签去除 + const html = this.form.content || '' + const md = this.convertHtmlLinkToMarkdown(html) + const plainText = md !== null ? md : (tempDiv.textContent || tempDiv.innerText || '') // 提取标题的纯文本 const titleDiv = document.createElement('div') @@ -244,8 +247,8 @@ export default { const plainTitle = titleDiv.textContent || titleDiv.innerText || '' const data = { - title: plainTitle, // 添加标题字段 - content: plainText, // 使用纯文本 + title: plainTitle, + content: plainText, selectedGrades: this.form.selectedGrades } sendNotificationByGrades(data).then(response => { @@ -268,6 +271,32 @@ export default { this.$modal.msgSuccess('删除成功') }).catch(() => { }) }, + convertHtmlLinkToMarkdown(html){ + const lower = (html || '').toLowerCase() + if (!lower.includes('=0 && (sq<0 || dq=0) { qs=sq; qe=lower.indexOf("'", sq+1) } + if (qs<0 || qe<0) return null + const url = html.substring(qs+1, qe).trim() + const textStart = lower.indexOf('>', qe)+1 + const textEnd = lower.indexOf('', textStart) + if (textStart<=0 || textEnd<=textStart) return null + const text = html.substring(textStart, textEnd).trim() + const before = html.substring(0, aStart).replace(/<[^>]+>/g, '') + const after = html.substring(textEnd+4).replace(/<[^>]+>/g, '') + const mdLink = `[${text || url}](${url})` + return before + mdLink + after + }catch(e){ + return null + } + }, /** 导出按钮操作 */ handleExport() { this.download('NotificationManagement/NotificationManagement/export', {