From 68594a2a7631c2fbb4549988cb7824b75d8655ad Mon Sep 17 00:00:00 2001 From: BTMuli Date: Mon, 27 Oct 2025 12:33:09 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E5=89=94=E9=99=A4=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E6=8D=A2=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/app/t-postcard.vue | 2 +- src/utils/annoParser.ts | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/app/t-postcard.vue b/src/components/app/t-postcard.vue index 33c87af5..28b814fe 100644 --- a/src/components/app/t-postcard.vue +++ b/src/components/app/t-postcard.vue @@ -114,7 +114,7 @@ > {{ props.modelValue.post.post_id }} diff --git a/src/utils/annoParser.ts b/src/utils/annoParser.ts index 382e60f7..700f6619 100644 --- a/src/utils/annoParser.ts +++ b/src/utils/annoParser.ts @@ -1,7 +1,6 @@ /** - * @file src/utils/annoParser.ts - * @description 解析游戏内公告数据 - * @since Beta v0.7.6 + * 解析游戏内公告数据 + * @since Beta v0.8.4 */ import TpText from "@comp/viewPost/tp-text.vue"; @@ -38,18 +37,22 @@ function handleAnnoContent(data: string): string { } /** - * @description 解析公告内容,转换为结构化数据 - * @since Beta v0.5.3 + * 解析公告内容,转换为结构化数据 + * @since Beta v0.8.4 * @param {TGApp.BBS.Announcement.AnnoDetail} anno - 公告内容 - * @returns {TGApp.BBS.SctPost.Base[]} 结构化数据 + * @returns {Array} 结构化数据 */ function parseAnnoContent(anno: TGApp.BBS.Announcement.AnnoDetail): Array { const parser = new DOMParser(); const first = handleAnnoContent(anno.content); const doc = parser.parseFromString(first, "text/html"); - const children: Array = []; + let children: Array = []; if (anno.banner !== "") children.push({ insert: { image: anno.banner } }); doc.body.childNodes.forEach((child) => children.push(...parseAnnoNode(child))); + // 剔除 attributes 为空且内容为 "\n\n" 的节点 + children = children.filter((child) => { + return !(child.attributes === undefined && child.insert === "\n\n"); + }); return children; }