🐛 修复公告时间获取异常&内容渲染异常

This commit is contained in:
目棃
2024-08-02 13:14:25 +08:00
parent db00765f7b
commit 69157ea008
2 changed files with 12 additions and 2 deletions

View File

@@ -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])) {

View File

@@ -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;