modules 添加web

This commit is contained in:
Xwite
2023-04-07 20:28:21 +08:00
parent 3447e46176
commit 57e2c3a418
88 changed files with 5784 additions and 0 deletions
@@ -0,0 +1,61 @@
<template>
<div v-for="(para, index) in props.carray" :key="index">
<img
class="full"
v-if="/^\s*<img[^>]*src[^>]+>$/.test(para)"
:src="getImageSrc(para)"
loading="lazy"
/>
<p v-else :style="style" v-html="para" />
</div>
</template>
<script setup>
import config from "../plugins/config";
const store = useBookStore();
const props = defineProps(["carray"]);
const fontFamily = computed(() => {
if (store.config.font >= 0) {
return config.fonts[store.config.font];
}
return { fontFamily: store.config.customFontName };
});
const fontSize = computed(() => {
return store.config.fontSize + "px";
});
const style = computed(() => {
let style = fontFamily.value;
style.fontSize = fontSize.value;
return style;
});
function getImageSrc(content) {
const imgPattern = /<img[^>]*src="([^"]*(?:"[^>]+\})?)"[^>]*>/;
return content.match(imgPattern)[1];
}
watch(fontSize, () => {
store.setShowContent(false);
nextTick(() => {
store.setShowContent(true);
});
});
</script>
<style lang="scss" scoped>
p {
display: block;
word-wrap: break-word;
word-break: break-all;
:deep(img) {
height: 1em;
}
}
.full {
display: block;
width: 100%;
}
</style>