From 70333d1aca50fdbf96bf6045e999f7dc704d031c Mon Sep 17 00:00:00 2001
From: PanicNotPanic <935915822@qq.com>
Date: Thu, 5 Jun 2025 22:42:56 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E7=AB=A0=E8=8A=82=E5=86=85=E5=AE=B9?=
=?UTF-8?q?=E5=AD=98=E5=9C=A8=E5=A4=9A=E5=BC=A0=E5=9B=BE=E7=89=87=E5=92=8C?=
=?UTF-8?q?=E6=96=87=E6=9C=AC=E6=97=B6=EF=BC=8Cweb=E6=9C=8D=E5=8A=A1?=
=?UTF-8?q?=E4=B9=A6=E6=9E=B6=E4=B8=AD=E8=AF=BB=E4=B9=A6=E6=97=A0=E6=B3=95?=
=?UTF-8?q?=E6=AD=A3=E7=A1=AE=E6=B8=B2=E6=9F=93=E5=9B=BE=E7=89=87(?=
=?UTF-8?q?=E5=85=BC=E5=AE=B9=E7=89=88)=20(#5126)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix: 章节内容存在多张图片和文本时,web服务书架中读书无法正确渲染图片
* fix: 章节内容存在多张图片和文本时,web服务书架中读书无法正确渲染图片(兼容版)
* fix: 修改String.prototype.replaceAll为String.prototype.replace
---------
Co-authored-by: 17683954109@163.com <17683954109@163.com>
---
modules/web/src/components/ChapterContent.vue | 2 +-
modules/web/src/views/BookChapter.vue | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/web/src/components/ChapterContent.vue b/modules/web/src/components/ChapterContent.vue
index c0b3633f7..1be09befa 100644
--- a/modules/web/src/components/ChapterContent.vue
+++ b/modules/web/src/components/ChapterContent.vue
@@ -59,7 +59,7 @@ const calculateWordCount = (paragraph: string) => {
const imgPattern = /
]*src="[^"]*(?:"[^>]+\})?"[^>]*>/g
//内嵌图片文字为1
const imagePlaceHolder = ' '
- return paragraph.replaceAll(imgPattern, imagePlaceHolder).length
+ return paragraph.replace(imgPattern, imagePlaceHolder).length
}
const chapterPos = computed(() => {
let pos = -1
diff --git a/modules/web/src/views/BookChapter.vue b/modules/web/src/views/BookChapter.vue
index 4bc24f33a..b2792ddbc 100644
--- a/modules/web/src/views/BookChapter.vue
+++ b/modules/web/src/views/BookChapter.vue
@@ -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*
]*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 })