fix(modules/web): 重构阅读API;封面图片优先使用源站资源

- 添加图片代理接口API;API地址测试(3s超时)
This commit is contained in:
Xwite
2024-09-29 18:05:04 +08:00
parent ed5d13f455
commit bf91a6f206
12 changed files with 222 additions and 176 deletions

View File

@@ -18,7 +18,8 @@
</template>
<script setup>
import { getImageFromLegado, isLegadoUrl } from "@/utils/utils";
import { isLegadoUrl } from "@/utils/utils";
import API from "@api";
import jump from "@/plugins/jump";
const props = defineProps({
@@ -33,11 +34,11 @@ const props = defineProps({
const getImageSrc = (content) => {
const imgPattern = /<img[^>]*src="([^"]*(?:"[^>]+\})?)"[^>]*>/;
const src = content.match(imgPattern)[1];
if (isLegadoUrl(src)) return getImageFromLegado(src);
if (isLegadoUrl(src)) return API.getProxyImageUrl(src, useBookStore().config.readWidth)
return src;
};
const proxyImage = (event) => {
event.target.src = getImageFromLegado(event.target.src);
event.target.src = API.getProxyImageUrl(event.target.src, useBookStore().config.readWidth);
};
const calculateWordCount = (paragraph) => {