Skip to content

Commit

Permalink
🐛 修复公告时间获取异常&内容渲染异常
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Aug 2, 2024
1 parent db00765 commit 69157ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/pages/common/Announcements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down
5 changes: 3 additions & 2 deletions src/web/utils/parseAnno.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 元素
*/
Expand All @@ -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;
Expand Down

0 comments on commit 69157ea

Please sign in to comment.