mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🐛 修复公告时间获取异常&内容渲染异常
This commit is contained in:
@@ -212,6 +212,15 @@ function getAnnoTime(content: string): string | false {
|
|||||||
}
|
}
|
||||||
if (content.match(regexes[3])) {
|
if (content.match(regexes[3])) {
|
||||||
const res = 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]}`;
|
return `${res?.[1]} ~ ${res?.[2]}`;
|
||||||
}
|
}
|
||||||
if (content.match(regexes[4])) {
|
if (content.match(regexes[4])) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file web/utils/parseAnno.ts
|
* @file web/utils/parseAnno.ts
|
||||||
* @description 解析游戏内公告数据
|
* @description 解析游戏内公告数据
|
||||||
* @since Beta v0.5.0
|
* @since Beta v0.5.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { saveImgLocal } from "../../utils/TGShare.js";
|
import { saveImgLocal } from "../../utils/TGShare.js";
|
||||||
@@ -30,7 +30,7 @@ function parseAnnoA(a: HTMLAnchorElement): HTMLAnchorElement {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 解析 p
|
* @description 解析 p
|
||||||
* @since Beta v0.4.7
|
* @since Beta v0.5.2
|
||||||
* @param {HTMLParagraphElement} p p 元素
|
* @param {HTMLParagraphElement} p p 元素
|
||||||
* @returns {HTMLParagraphElement} 解析后的 p 元素
|
* @returns {HTMLParagraphElement} 解析后的 p 元素
|
||||||
*/
|
*/
|
||||||
@@ -40,6 +40,7 @@ function parseAnnoP(p: HTMLParagraphElement): HTMLParagraphElement {
|
|||||||
} else {
|
} else {
|
||||||
p.querySelectorAll("*").forEach((child) => {
|
p.querySelectorAll("*").forEach((child) => {
|
||||||
child.innerHTML = decodeRegExp(child.innerHTML);
|
child.innerHTML = decodeRegExp(child.innerHTML);
|
||||||
|
child.querySelectorAll("span").forEach((span) => parseAnnoSpan(span));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
|
|||||||
Reference in New Issue
Block a user