mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
perf: limit notice length in preview
This commit is contained in:
@@ -44,7 +44,7 @@ export async function loadHomePage() {
|
|||||||
const homeContainer = document.getElementById("home-root");
|
const homeContainer = document.getElementById("home-root");
|
||||||
if (!homeContainer) return;
|
if (!homeContainer) return;
|
||||||
|
|
||||||
const skeletonStructure = stringToHTML(`
|
const skeletonStructure = stringToHTML(/* html */`
|
||||||
<div class="home-container" id="home-container">
|
<div class="home-container" id="home-container">
|
||||||
<div class="border shortcut-container">
|
<div class="border shortcut-container">
|
||||||
<div class="border shortcuts" id="shortcuts"></div>
|
<div class="border shortcuts" id="shortcuts"></div>
|
||||||
@@ -420,9 +420,14 @@ function processNoticeColor(colour: string): string | undefined {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createNoticeElement(notice: any, colour: string | undefined): Node {
|
function createNoticeElement(notice: any, colour: string | undefined): Node {
|
||||||
const cleanContent = notice.contents
|
const textPreview = notice.contents
|
||||||
|
.replace(/<[^>]*>/g, "")
|
||||||
.replace(/\[\[[\w]+[:][\w]+[\]\]]+/g, "")
|
.replace(/\[\[[\w]+[:][\w]+[\]\]]+/g, "")
|
||||||
.replace(/ +/, " ");
|
.replace(/\s+/g, " ")
|
||||||
|
.trim()
|
||||||
|
.substring(0, 150)
|
||||||
|
+ (notice.contents.length > 150 ? "..." : "");
|
||||||
|
|
||||||
const noticeId = `notice-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
const noticeId = `notice-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
||||||
|
|
||||||
const htmlContent = `
|
const htmlContent = `
|
||||||
@@ -437,7 +442,7 @@ function createNoticeElement(notice: any, colour: string | undefined): Node {
|
|||||||
<button class="notice-close-btn" style="opacity: 0; pointer-events: none;">×</button>
|
<button class="notice-close-btn" style="opacity: 0; pointer-events: none;">×</button>
|
||||||
</div>
|
</div>
|
||||||
<h2 class="notice-content-title">${notice.title}</h2>
|
<h2 class="notice-content-title">${notice.title}</h2>
|
||||||
<div class="notice-content-body">${cleanContent}</div>
|
<div class="notice-content-body">${textPreview}</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
const element = stringToHTML(htmlContent).firstChild as HTMLElement;
|
const element = stringToHTML(htmlContent).firstChild as HTMLElement;
|
||||||
|
|||||||
Reference in New Issue
Block a user