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:
co-authored by
17683954109@163.com <17683954109@163.com>
parent
dfc9ff9b31
commit
70333d1aca
@@ -59,7 +59,7 @@ const calculateWordCount = (paragraph: string) => {
|
|||||||
const imgPattern = /<img[^>]*src="[^"]*(?:"[^>]+\})?"[^>]*>/g
|
const imgPattern = /<img[^>]*src="[^"]*(?:"[^>]+\})?"[^>]*>/g
|
||||||
//内嵌图片文字为1
|
//内嵌图片文字为1
|
||||||
const imagePlaceHolder = ' '
|
const imagePlaceHolder = ' '
|
||||||
return paragraph.replaceAll(imgPattern, imagePlaceHolder).length
|
return paragraph.replace(imgPattern, imagePlaceHolder).length
|
||||||
}
|
}
|
||||||
const chapterPos = computed(() => {
|
const chapterPos = computed(() => {
|
||||||
let pos = -1
|
let pos = -1
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ const getContent = (index: number, reloadChapter = true, chapterPos = 0) => {
|
|||||||
const content = data.split(/\n+/)
|
const content = data.split(/\n+/)
|
||||||
for (let i = 0; i < content.length; i++) {
|
for (let i = 0; i < content.length; i++) {
|
||||||
if (!/^\s*<img[^>]*src[^>]+>$/.test(content[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 })
|
chapterData.value.push({ index, content, title })
|
||||||
|
|||||||
Reference in New Issue
Block a user