From 69157ea00871c7232045615a7e7ed81a3a5879d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Fri, 2 Aug 2024 13:14:25 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E5=85=AC?= =?UTF-8?q?=E5=91=8A=E6=97=B6=E9=97=B4=E8=8E=B7=E5=8F=96=E5=BC=82=E5=B8=B8?= =?UTF-8?q?&=E5=86=85=E5=AE=B9=E6=B8=B2=E6=9F=93=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/Announcements.vue | 9 +++++++++ src/web/utils/parseAnno.ts | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/pages/common/Announcements.vue b/src/pages/common/Announcements.vue index 1c1dfe9f..ef2360b1 100644 --- a/src/pages/common/Announcements.vue +++ b/src/pages/common/Announcements.vue @@ -212,6 +212,15 @@ function getAnnoTime(content: string): string | false { } if (content.match(regexes[3])) { const res = content.match(regexes[3]); + try { + const span1 = document.createElement("span"); + span1.innerHTML = res?.[1] ?? ""; + const span2 = document.createElement("span"); + span2.innerHTML = res?.[2] ?? ""; + return `${span1.innerText} ~ ${span2.innerText}`; + } catch (e) { + console.error(e); + } return `${res?.[1]} ~ ${res?.[2]}`; } if (content.match(regexes[4])) { diff --git a/src/web/utils/parseAnno.ts b/src/web/utils/parseAnno.ts index 163fda29..6aaead96 100644 --- a/src/web/utils/parseAnno.ts +++ b/src/web/utils/parseAnno.ts @@ -1,7 +1,7 @@ /** * @file web/utils/parseAnno.ts * @description 解析游戏内公告数据 - * @since Beta v0.5.0 + * @since Beta v0.5.2 */ import { saveImgLocal } from "../../utils/TGShare.js"; @@ -30,7 +30,7 @@ function parseAnnoA(a: HTMLAnchorElement): HTMLAnchorElement { /** * @description 解析 p - * @since Beta v0.4.7 + * @since Beta v0.5.2 * @param {HTMLParagraphElement} p p 元素 * @returns {HTMLParagraphElement} 解析后的 p 元素 */ @@ -40,6 +40,7 @@ function parseAnnoP(p: HTMLParagraphElement): HTMLParagraphElement { } else { p.querySelectorAll("*").forEach((child) => { child.innerHTML = decodeRegExp(child.innerHTML); + child.querySelectorAll("span").forEach((span) => parseAnnoSpan(span)); }); } return p;