fix: retranslate loadmore text (issue #257)

This commit is contained in:
Gabe
2025-08-09 20:55:04 +08:00
parent 3a3f1fabe1
commit 45b294a121
2 changed files with 24 additions and 14 deletions

View File

@@ -250,3 +250,20 @@ export const blobToBase64 = (blob) => {
reader.readAsDataURL(blob);
});
};
/**
* 获取html内的文本
* @param {*} htmlStr
* @param {*} skipTag
* @returns
*/
export const getHtmlText = (htmlStr, skipTag = "") => {
const parser = new DOMParser();
const doc = parser.parseFromString(htmlStr, "text/html");
if (skipTag) {
doc.querySelectorAll(skipTag).forEach((el) => el.remove());
}
return doc.body.innerText.trim();
};