mirror of
https://github.com/gedoor/legado.git
synced 2024-07-19 01:17:25 +08:00
perf(web): 减少重复字数计算
This commit is contained in:
parent
39e291c947
commit
fe01efbf85
@ -3,7 +3,7 @@
|
|||||||
<div
|
<div
|
||||||
v-for="(para, index) in contents"
|
v-for="(para, index) in contents"
|
||||||
:key="index"
|
:key="index"
|
||||||
:wordCount="calculateWordCount(para)"
|
:wordCount="wordCounts[index]"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
class="full"
|
class="full"
|
||||||
@ -43,6 +43,10 @@ const calculateWordCount = (paragraph) => {
|
|||||||
const imagePlaceHolder = " ";
|
const imagePlaceHolder = " ";
|
||||||
return paragraph.replaceAll(imgPattern, imagePlaceHolder).length;
|
return paragraph.replaceAll(imgPattern, imagePlaceHolder).length;
|
||||||
};
|
};
|
||||||
|
const wordCounts = computed(() => {
|
||||||
|
return Array.from(props.contents, content => calculateWordCount(content));
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
Loading…
Reference in New Issue
Block a user