PopCatalog.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <div class="cata-wrapper" :style="popupTheme">
  3. <div class="title">目录</div>
  4. <div
  5. class="data-wrapper"
  6. ref="cataData"
  7. :class="{ night: isNight, day: !isNight }"
  8. >
  9. <div class="cata">
  10. <div
  11. class="log"
  12. v-for="(note, index) in catalog"
  13. :class="{ selected: isSelected(index) }"
  14. :key="note.durChapterIndex"
  15. @click="gotoChapter(note)"
  16. ref="cata"
  17. >
  18. <div class="log-text">
  19. {{ note.title }}
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script setup>
  27. import jump from "../plugins/jump";
  28. import settings from "../plugins/config";
  29. import "../assets/fonts/popfont.css";
  30. const store = useBookStore();
  31. const isNight = ref(false);
  32. const { index } = toRefs(store.readingBook);
  33. const { catalog, popCataVisible } = storeToRefs(store);
  34. const theme = computed(() => {
  35. return store.config.theme;
  36. });
  37. const popupTheme = computed(() => {
  38. return {
  39. background: settings.themes[theme.value].popup,
  40. };
  41. });
  42. watchEffect(() => {
  43. isNight.value = theme.value == 6;
  44. });
  45. const cata = ref();
  46. const cataData = ref();
  47. watch(popCataVisible, () => {
  48. nextTick(() => {
  49. let wrapper = cataData.value;
  50. jump(cata.value[index.value], { container: wrapper, duration: 0 });
  51. });
  52. });
  53. const isSelected = (idx) => {
  54. return idx == index.value;
  55. };
  56. const emit = defineEmits(["getContent"]);
  57. const gotoChapter = (note) => {
  58. index.value = catalog.value.indexOf(note);
  59. store.setPopCataVisible(false);
  60. store.setContentLoading(true);
  61. emit("getContent", index.value);
  62. };
  63. </script>
  64. <style lang="scss" scoped>
  65. .cata-wrapper {
  66. margin: -16px;
  67. padding: 18px 0 24px 25px;
  68. // background: #ede7da url('../assets/imgs/themes/popup_1.png') repeat;
  69. .title {
  70. font-size: 18px;
  71. font-weight: 400;
  72. font-family: FZZCYSK;
  73. margin: 0 0 20px 0;
  74. color: #ed4259;
  75. width: fit-content;
  76. border-bottom: 1px solid #ed4259;
  77. }
  78. .data-wrapper {
  79. height: 300px;
  80. overflow: auto;
  81. .cata {
  82. display: flex;
  83. flex-direction: row;
  84. flex-wrap: wrap;
  85. justify-content: space-between;
  86. .selected {
  87. color: #eb4259;
  88. }
  89. .log {
  90. width: 50%;
  91. height: 40px;
  92. cursor: pointer;
  93. float: left;
  94. font: 16px / 40px PingFangSC-Regular, HelveticaNeue-Light,
  95. "Helvetica Neue Light", "Microsoft YaHei", sans-serif;
  96. .log-text {
  97. margin-right: 26px;
  98. overflow: hidden;
  99. white-space: nowrap;
  100. text-overflow: ellipsis;
  101. }
  102. }
  103. }
  104. }
  105. .night {
  106. :deep(.log) {
  107. border-bottom: 1px solid #666;
  108. }
  109. }
  110. .day {
  111. :deep(.log) {
  112. border-bottom: 1px solid #f2f2f2;
  113. }
  114. }
  115. }
  116. @media screen and (max-width: 500px) {
  117. .cata-wrapper .data-wrapper .cata .log {
  118. width: 100%;
  119. }
  120. }
  121. </style>