CatalogItem.vue 783 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <div class="wrapper">
  3. <div
  4. v-for="cata in catas"
  5. class="cata-text"
  6. :key="cata.url"
  7. :class="{ selected: isSelected(cata.index) }"
  8. @click="gotoChapter(cata)"
  9. >
  10. {{ cata.title }}
  11. </div>
  12. </div>
  13. </template>
  14. <script setup>
  15. const props = defineProps([
  16. "index",
  17. "source",
  18. "gotoChapter",
  19. "currentChapterIndex",
  20. ]);
  21. const isSelected = (idx) => {
  22. return idx == props.currentChapterIndex;
  23. };
  24. const catas = computed(() => {
  25. return props.source?.catas ?? [props.source];
  26. });
  27. </script>
  28. <style lang="scss" scoped>
  29. .selected {
  30. color: #eb4259;
  31. }
  32. .wrapper {
  33. display: flex;
  34. .cata-text {
  35. width: 100%;
  36. margin-right: 26px;
  37. overflow: hidden;
  38. white-space: nowrap;
  39. text-overflow: ellipsis;
  40. }
  41. }
  42. </style>