BookView.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div class="row items-center">
  3. <div class="q-my-sm clickable2" @click="selectTitle">
  4. {{ book.serno ? `${book.serno}. ` : '' }}
  5. <span class="text-blue-10">{{ book.title }}</span>
  6. </div>
  7. <div class="q-ml-sm">
  8. {{ bookSize }}, {{ book.ext }}
  9. </div>
  10. <div class="q-ml-sm clickable" @click="download">
  11. (скачать)
  12. </div>
  13. <div class="q-ml-sm clickable" @click="copyLink">
  14. <q-icon name="la la-copy" size="20px" />
  15. </div>
  16. <div v-if="showGenres" class="q-ml-sm">
  17. {{ bookGenre }}
  18. </div>
  19. {{ book.src1 }}
  20. </div>
  21. </template>
  22. <script>
  23. //-----------------------------------------------------------------------------
  24. import vueComponent from '../../vueComponent.js';
  25. const componentOptions = {
  26. components: {
  27. },
  28. watch: {
  29. settings() {
  30. this.loadSettings();
  31. },
  32. }
  33. };
  34. class BookView {
  35. _options = componentOptions;
  36. _props = {
  37. book: Object,
  38. genreTree: Array,
  39. };
  40. showGenres = true;
  41. created() {
  42. this.loadSettings();
  43. }
  44. loadSettings() {
  45. const settings = this.settings;
  46. this.showGenres = settings.showGenres;
  47. }
  48. get settings() {
  49. return this.$store.state.settings;
  50. }
  51. get bookSize() {
  52. let size = this.book.size/1024;
  53. let unit = 'KB';
  54. if (size > 1024) {
  55. size = size/1024;
  56. unit = 'MB';
  57. }
  58. return `${size.toFixed(0)}${unit}`;
  59. }
  60. get bookGenre() {
  61. let result = [];
  62. const genre = new Set(this.book.genre.split(','));
  63. for (const section of this.genreTree) {
  64. for (const g of section.value)
  65. if (genre.has(g.value))
  66. result.push(g.name);
  67. }
  68. return `(${result.join(' / ')})`;
  69. }
  70. selectTitle() {
  71. this.$emit('bookEvent', {action: 'titleClick', book: this.book});
  72. }
  73. download() {
  74. this.$emit('bookEvent', {action: 'download', book: this.book});
  75. }
  76. copyLink() {
  77. this.$emit('bookEvent', {action: 'copyLink', book: this.book});
  78. }
  79. }
  80. export default vueComponent(BookView);
  81. //-----------------------------------------------------------------------------
  82. </script>
  83. <style scoped>
  84. .clickable {
  85. color: blue;
  86. cursor: pointer;
  87. }
  88. .clickable2 {
  89. cursor: pointer;
  90. }
  91. </style>