mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
fix: 章节内容存在多张图片和文本时,web服务书架中读书无法正确渲染图片(兼容版) (#5126)
* fix: 章节内容存在多张图片和文本时,web服务书架中读书无法正确渲染图片 * fix: 章节内容存在多张图片和文本时,web服务书架中读书无法正确渲染图片(兼容版) * fix: 修改String.prototype.replaceAll为String.prototype.replace --------- Co-authored-by: 17683954109@163.com <17683954109@163.com>
This commit is contained in:
@@ -59,7 +59,7 @@ const calculateWordCount = (paragraph: string) => {
|
||||
const imgPattern = /<img[^>]*src="[^"]*(?:"[^>]+\})?"[^>]*>/g
|
||||
//内嵌图片文字为1
|
||||
const imagePlaceHolder = ' '
|
||||
return paragraph.replaceAll(imgPattern, imagePlaceHolder).length
|
||||
return paragraph.replace(imgPattern, imagePlaceHolder).length
|
||||
}
|
||||
const chapterPos = computed(() => {
|
||||
let pos = -1
|
||||
|
||||
@@ -307,7 +307,7 @@ const getContent = (index: number, reloadChapter = true, chapterPos = 0) => {
|
||||
const content = data.split(/\n+/)
|
||||
for (let i = 0; i < content.length; i++) {
|
||||
if (!/^\s*<img[^>]*src[^>]+>$/.test(content[i])) {
|
||||
content[i] = content[i].replaceAll('img src="', `img src="/image?url=${bookUrl}&path=`);
|
||||
content[i] = content[i].replace(new RegExp('img src="', 'g'), `img src="/image?url=${bookUrl}&path=`);
|
||||
}
|
||||
}
|
||||
chapterData.value.push({ index, content, title })
|
||||
|
||||
Reference in New Issue
Block a user