diff --git a/modules/web/src/components/ChapterContent.vue b/modules/web/src/components/ChapterContent.vue
index 405a4f368..8c41941b7 100644
--- a/modules/web/src/components/ChapterContent.vue
+++ b/modules/web/src/components/ChapterContent.vue
@@ -13,7 +13,7 @@
@error.once="proxyImage"
loading="lazy"
/>
-
+
@@ -25,6 +25,7 @@ import type { webReadConfig } from '@/web'
const store = useBookStore()
const readWidth = computed(() => store.config.readWidth)
+const fontSize = computed(() => store.config.fontSize)
const bookUrl = computed(() => store.readingBook.bookUrl)
const props = defineProps<{
@@ -36,14 +37,29 @@ const props = defineProps<{
fontSize: string
}>()
+const imgPattern = /
]*src=['"]([^'"]*(?:['"][^>]+\})?)['"][^>]*>/g
+
+const replaceImage = (content: string) => {
+ return content.replace(imgPattern, (match, src) => {
+ if (isLegadoUrl(src)) {
+ const proxySrc = API.getProxyImageUrl(
+ bookUrl.value,
+ src,
+ fontSize.value,
+ )
+ return match.replace(src, proxySrc)
+ }
+ return match
+ })
+}
+
const getImageSrc = (content: string) => {
- const imgPattern = /
]*src="([^"]*(?:"[^>]+\})?)"[^>]*>/
const src = content.match(imgPattern)![1] //reg tested in template
if (isLegadoUrl(src))
return API.getProxyImageUrl(
bookUrl.value,
src,
- useBookStore().config.readWidth,
+ readWidth.value,
)
return src
}
@@ -82,7 +98,6 @@ const handleImgLoadError = (event: Event) => {
}
const calculateWordCount = (paragraph: string) => {
- const imgPattern = /
]*src="[^"]*(?:"[^>]+\})?"[^>]*>/g
//内嵌图片文字为1
const imagePlaceHolder = ' '
return paragraph.replace(imgPattern, imagePlaceHolder).length