BookView.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 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. }
  30. };
  31. class BookView {
  32. _options = componentOptions;
  33. _props = {
  34. book: Object,
  35. genreTree: Array,
  36. };
  37. created() {
  38. }
  39. get bookSize() {
  40. let size = this.book.size/1024;
  41. let unit = 'KB';
  42. if (size > 1024) {
  43. size = size/1024;
  44. unit = 'MB';
  45. }
  46. return `${size.toFixed(0)}${unit}`;
  47. }
  48. get bookGenre() {
  49. let result = [];
  50. const genre = new Set(this.book.genre.split(','));
  51. for (const section of this.genreTree) {
  52. for (const g of section.value)
  53. if (genre.has(g.value))
  54. result.push(g.name);
  55. }
  56. return `(${result.join(', ')})`;
  57. }
  58. selectTitle() {
  59. this.$emit('bookEvent', {action: 'titleClick', book: this.book});
  60. }
  61. download() {
  62. }
  63. copyLink() {
  64. }
  65. }
  66. export default vueComponent(BookView);
  67. //-----------------------------------------------------------------------------
  68. </script>
  69. <style scoped>
  70. .clickable {
  71. color: blue;
  72. cursor: pointer;
  73. }
  74. .clickable2 {
  75. cursor: pointer;
  76. }
  77. </style>